-
Notifications
You must be signed in to change notification settings - Fork 3
🚩 Visa Tab should be enabled through configuration #235
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -12,6 +12,8 @@ export const EGO_CLIENT_ID = process.env.REACT_APP_EGO_CLIENT_ID; | |||
|
|||
export const PUBLIC_PATH = process.env.REACT_APP_PUBLIC_PATH; | |||
|
|||
export const PASSPORT_ENABLED = process.env.REACT_APP_PASSPORT_ENABLED === 'true' || false; | |||
|
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.
Passport flag disabled by default
@@ -4,7 +4,7 @@ import ajax from 'services/ajax'; | |||
const BLOCKED_KEYS = ['id', 'createdAt', 'lastLogin', 'groups', 'applications']; | |||
|
|||
export const createVisa = ({ item }) => { | |||
return ajax.post(`/visa`, _.omit(item, BLOCKED_KEYS)).then(r => { | |||
return ajax.post(`/visas`, _.omit(item, BLOCKED_KEYS)).then(r => { |
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.
fixing a typo..
@@ -4,3 +4,4 @@ REACT_APP_EGO_CLIENT_ID=ego | |||
# debug namespace, e.g. "app". See https://www.npmjs.com/package/debug | |||
REACT_APP_DEBUG=app | |||
REACT_APP_KEYCLOAK_ENABLED=false | |||
REACT_APP_PASSPORT_ENABLED=false |
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.
schema file defines the basic configuration variables needed to run this app, mentioned in .readme file
src/components/Login.tsx
Outdated
@@ -182,7 +182,7 @@ class Component extends React.Component<any, any> { | |||
? 'Or login with one of the following services' | |||
: 'Login with one of the following'} | |||
</h3> | |||
{providers.map(({ name, path, Icon }) => { | |||
{providers.filter(provider => !(provider.name === LoginProvider.Passport && !PASSPORT_ENABLED)).map(({ name, path, Icon }) => { |
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.
Hard to interpret this but I believe the logic is "remove Passport type providers if passport is not enabled"...
Can we simplify it to "all true when passport_enabled is true, otherwise not the passport providers":
{providers.filter(provider => !(provider.name === LoginProvider.Passport && !PASSPORT_ENABLED)).map(({ name, path, Icon }) => { | |
{providers.filter(provider => PASSPORT_ENABLED || provider.name !== LoginProvider.Passport).map(({ name, path, Icon }) => { |
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.
changed as suggested
src/components/Nav/Nav.tsx
Outdated
@@ -72,7 +74,7 @@ const Nav = ({ effects, state }) => { | |||
</Emblem> | |||
</div> | |||
<ul css={listStyles}> | |||
{Object.keys(pickBy(RESOURCE_MAP, (r) => r.isParent)).map((key) => { | |||
{Object.keys(pickBy(RESOURCE_MAP, (r) => r.isParent)).filter(key => !(key === VISAS && !PASSPORT_ENABLED)).map((key) => { |
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.
This filter is also a bit confusing. Since we know our keys and there is always exactly one named VISA would you consider:
{Object.keys(pickBy(RESOURCE_MAP, (r) => r.isParent)).filter(key => !(key === VISAS && !PASSPORT_ENABLED)).map((key) => { | |
{Object.keys(pickBy(RESOURCE_MAP, (r) => r.isParent)).map((key) => { | |
if(key === VISAS && !PASSPORT_ENABLED) { return null; } |
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.
changed as suggested
@@ -73,6 +75,7 @@ const Nav = ({ effects, state }) => { | |||
</div> | |||
<ul css={listStyles}> | |||
{Object.keys(pickBy(RESOURCE_MAP, (r) => r.isParent)).map((key) => { | |||
if(key === VISAS && !PASSPORT_ENABLED) { return null; } |
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.
Refactored condition as suggested
@@ -182,7 +182,7 @@ class Component extends React.Component<any, any> { | |||
? 'Or login with one of the following services' | |||
: 'Login with one of the following'} | |||
</h3> | |||
{providers.map(({ name, path, Icon }) => { | |||
{providers.filter(provider => PASSPORT_ENABLED || provider.name !== LoginProvider.Passport).map(({ name, path, Icon }) => { |
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.
Refactored condition as suggested for better readability
feature: #234