-
Notifications
You must be signed in to change notification settings - Fork 262
feat: implement SHOW_REGISTRATION_LINKS setting #1066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -39,6 +39,7 @@ const Logistration = (props) => { | |||||||||||||||||
| const [key, setKey] = useState(''); | ||||||||||||||||||
| const navigate = useNavigate(); | ||||||||||||||||||
| const disablePublicAccountCreation = getConfig().ALLOW_PUBLIC_ACCOUNT_CREATION === false; | ||||||||||||||||||
| const hideRegistrationLink = getConfig().SHOW_REGISTRATION_LINKS === false; | ||||||||||||||||||
|
|
||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||
| const authService = getAuthService(); | ||||||||||||||||||
|
|
@@ -116,7 +117,7 @@ const Logistration = (props) => { | |||||||||||||||||
| <Tab title={tabTitle} eventKey={selectedPage === LOGIN_PAGE ? LOGIN_PAGE : REGISTER_PAGE} /> | ||||||||||||||||||
| </Tabs> | ||||||||||||||||||
| ) | ||||||||||||||||||
| : (!isValidTpaHint() && ( | ||||||||||||||||||
| : (!isValidTpaHint() && !hideRegistrationLink && ( | ||||||||||||||||||
| <Tabs defaultActiveKey={selectedPage} id="controlled-tab" onSelect={handleOnSelect}> | ||||||||||||||||||
| <Tab title={formatMessage(messages['logistration.register'])} eventKey={REGISTER_PAGE} /> | ||||||||||||||||||
| <Tab title={formatMessage(messages['logistration.sign.in'])} eventKey={LOGIN_PAGE} /> | ||||||||||||||||||
|
Comment on lines
+120
to
123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Instead of adding a new h3 element, can we hide/show register tab based on the flag and url, something like above. This way users have a way to go to sign-in page from register page like they would normally do if both tabs are enabled.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @navinkarkera Thanks for the review. Well spotted! You put your finger on the dilemma I was facing before opting for the new h3 element. My decision was motivated by the following:
However, your suggestion makes the code cleaner and is easier to reason about. I am happy to go either way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@CefBoud Ahh, makes sense. I did not notice that before. Thanks for the detailed explanantion. I agree with your approach so propose to keep the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @navinkarkera Ok, great. Thank you for taking the time. |
||||||||||||||||||
|
|
@@ -126,6 +127,11 @@ const Logistration = (props) => { | |||||||||||||||||
| <Navigate to={updatePathWithQueryParams(key)} replace /> | ||||||||||||||||||
| )} | ||||||||||||||||||
| <div id="main-content" className="main-content"> | ||||||||||||||||||
| {!institutionLogin && !isValidTpaHint() && hideRegistrationLink && ( | ||||||||||||||||||
| <h3 className="mb-4.5"> | ||||||||||||||||||
| {formatMessage(messages[selectedPage === LOGIN_PAGE ? 'logistration.sign.in' : 'logistration.register'])} | ||||||||||||||||||
| </h3> | ||||||||||||||||||
| )} | ||||||||||||||||||
|
Comment on lines
+130
to
+134
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If my suggestion above makes sense, we can remove this part. |
||||||||||||||||||
| {selectedPage === LOGIN_PAGE | ||||||||||||||||||
| ? <LoginPage institutionLogin={institutionLogin} handleInstitutionLogin={handleInstitutionLogin} /> | ||||||||||||||||||
| : ( | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ import Logistration from './Logistration'; | |
| import { clearThirdPartyAuthContextErrorMessage } from '../common-components/data/actions'; | ||
| import { RenderInstitutionButton } from '../common-components/InstitutionLogistration'; | ||
| import { | ||
| COMPLETE_STATE, LOGIN_PAGE, | ||
| COMPLETE_STATE, LOGIN_PAGE, REGISTER_PAGE, | ||
| } from '../data/constants'; | ||
| import { backupRegistrationForm } from '../register/data/actions'; | ||
|
|
||
|
|
@@ -111,10 +111,31 @@ describe('Logistration', () => { | |
| expect(logistration.find('#main-content').find('LoginPage').exists()).toBeTruthy(); | ||
| }); | ||
|
|
||
| it('should render login/register headings when show registration links is disabled', () => { | ||
| mergeConfig({ | ||
| SHOW_REGISTRATION_LINKS: false, | ||
| }); | ||
|
|
||
| let props = { selectedPage: LOGIN_PAGE }; | ||
| let logistration = mount(reduxWrapper(<IntlLogistration {...props} />)); | ||
|
|
||
| // verifying sign in heading | ||
| expect(logistration.find('#main-content').find('h3').text()).toEqual('Sign in'); | ||
|
|
||
| // register page is still accessible when SHOW_REGISTRATION_LINKS is false | ||
| // but it needs to be accessed directly | ||
| props = { selectedPage: REGISTER_PAGE }; | ||
| logistration = mount(reduxWrapper(<IntlLogistration {...props} />)); | ||
|
|
||
| // verifying register heading | ||
| expect(logistration.find('#main-content').find('h3').text()).toEqual('Register'); | ||
|
Comment on lines
+114
to
+131
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test will also need to be updated if my suggestion makes sense. |
||
| }); | ||
|
|
||
| it('should render only login page when public account creation is disabled', () => { | ||
| mergeConfig({ | ||
| ALLOW_PUBLIC_ACCOUNT_CREATION: false, | ||
| DISABLE_ENTERPRISE_LOGIN: 'true', | ||
| SHOW_REGISTRATION_LINKS: 'true', | ||
| }); | ||
|
|
||
| store = mockStore({ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
SHOW_REGISTRATION_LINKSflag in src/config/index.js to utilize this flag usinggetConfigThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mubbsharanwar Done. I'd like to point out that because the default value of this param is
trueand AFAIK there is no way to specify a boolean as an env variable, I resorted to using an explicit comparison with the string'false'.