Skip to content

Commit

Permalink
VADC-862 feat/login (#1466)
Browse files Browse the repository at this point in the history
* feat: config for when to show dropdown when there is only one InCommon option

* fix: default value for dropdownSingleLogin

* feat: display dropdown only for InCommon

* feat: update with new approach of listing all IdPs that needs to have dropdown for one option

* feat: improve configuration option naming

* fix: formatting to make linter happy
  • Loading branch information
m0nhawk authored Dec 20, 2023
1 parent 9b35888 commit fda5507
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/portal_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ Below is an example, with inline comments describing what each JSON block config
// lacks support for search filter state, accessibility state, table state.
"explorerHideEmptyFilterSection": false, // optional, when filtering data hide FilterSection when they are empty.
"explorerFilterValuesToHide": ["array of strings"], // optional, Values set in array will be hidden in guppy filters. Intended use is to hide missing data category from filters, for this it should be set to the same as `missing_data_alias` in Guppy server config
"forceSingleLoginDropdownOptions": [], // optional, Values set in array will be used to force single login option dropdown for a list of IdPs. For example, if a single InCommon login needs to be shown as dropdown, this option will contain `["InCommon Login"]` and will be displayed as such.
"studyRegistration": true, // optional, whether to enable the study registration feature
"workspaceRegistration": true, // optional, whether to enable the workspace registration feature
"workspaceTokenServiceRefreshTokenAtLogin": true, // optional, whether to refresh the WTS token directly at portal login (recommended mode). If not set, this refresh happens only when the user enters the workspace section of the portal (default/old/previous mode).
Expand Down
8 changes: 6 additions & 2 deletions src/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import querystring from 'querystring';
import PropTypes from 'prop-types'; // see https://github.com/facebook/prop-types#prop-types
import Select, { createFilter } from 'react-select';
import Button from '@gen3/ui-component/dist/components/Button';
import { basename } from '../localconf';
import { basename, forceSingleLoginDropdownOptions } from '../localconf';
import { components } from '../params';

import './Login.less';

const getInitialState = (height) => ({ height });

const determineIfEntryLoginSelectShown = (name, loginOptionsLength) => ((forceSingleLoginDropdownOptions
&& forceSingleLoginDropdownOptions.includes(name))
|| loginOptionsLength > 1);

// Get a url for a given "location" (location object should have at least the .from attribute)
export const getUrlForRedirectLocation = (location) => {
// compose next according to location.from
Expand Down Expand Up @@ -157,7 +161,7 @@ class Login extends React.Component {
// over the login options' names (e.g. "The University of
// Chicago") and not the actual option values, which are
// URLs.
loginOptions[i].length > 1 && (
determineIfEntryLoginSelectShown(p.name, loginOptions[i].length) && (
<Select
isClearable
isSearchable
Expand Down
6 changes: 6 additions & 0 deletions src/localconf.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,11 @@ function buildConfig(opts) {
explorerFilterValuesToHide = config.featureFlags.explorerFilterValuesToHide;
}

let forceSingleLoginDropdownOptions = [];
if (config.featureFlags && config.featureFlags.forceSingleLoginDropdownOptions) {
forceSingleLoginDropdownOptions = config.featureFlags.forceSingleLoginDropdownOptions;
}

const enableResourceBrowser = !!config.resourceBrowser;
let resourceBrowserPublic = false;
if (config.resourceBrowser && config.resourceBrowser.public) {
Expand Down Expand Up @@ -547,6 +552,7 @@ function buildConfig(opts) {
explorerPublic,
explorerHideEmptyFilterSection,
explorerFilterValuesToHide,
forceSingleLoginDropdownOptions,
authzPath,
authzMappingPath,
enableResourceBrowser,
Expand Down

0 comments on commit fda5507

Please sign in to comment.