Skip to content

Commit fda5507

Browse files
authored
VADC-862 feat/login (#1466)
* 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
1 parent 9b35888 commit fda5507

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

docs/portal_config.md

+1
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ Below is an example, with inline comments describing what each JSON block config
192192
// lacks support for search filter state, accessibility state, table state.
193193
"explorerHideEmptyFilterSection": false, // optional, when filtering data hide FilterSection when they are empty.
194194
"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
195+
"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.
195196
"studyRegistration": true, // optional, whether to enable the study registration feature
196197
"workspaceRegistration": true, // optional, whether to enable the workspace registration feature
197198
"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).

src/Login/Login.jsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ import querystring from 'querystring';
33
import PropTypes from 'prop-types'; // see https://github.com/facebook/prop-types#prop-types
44
import Select, { createFilter } from 'react-select';
55
import Button from '@gen3/ui-component/dist/components/Button';
6-
import { basename } from '../localconf';
6+
import { basename, forceSingleLoginDropdownOptions } from '../localconf';
77
import { components } from '../params';
88

99
import './Login.less';
1010

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

13+
const determineIfEntryLoginSelectShown = (name, loginOptionsLength) => ((forceSingleLoginDropdownOptions
14+
&& forceSingleLoginDropdownOptions.includes(name))
15+
|| loginOptionsLength > 1);
16+
1317
// Get a url for a given "location" (location object should have at least the .from attribute)
1418
export const getUrlForRedirectLocation = (location) => {
1519
// compose next according to location.from
@@ -157,7 +161,7 @@ class Login extends React.Component {
157161
// over the login options' names (e.g. "The University of
158162
// Chicago") and not the actual option values, which are
159163
// URLs.
160-
loginOptions[i].length > 1 && (
164+
determineIfEntryLoginSelectShown(p.name, loginOptions[i].length) && (
161165
<Select
162166
isClearable
163167
isSearchable

src/localconf.js

+6
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,11 @@ function buildConfig(opts) {
291291
explorerFilterValuesToHide = config.featureFlags.explorerFilterValuesToHide;
292292
}
293293

294+
let forceSingleLoginDropdownOptions = [];
295+
if (config.featureFlags && config.featureFlags.forceSingleLoginDropdownOptions) {
296+
forceSingleLoginDropdownOptions = config.featureFlags.forceSingleLoginDropdownOptions;
297+
}
298+
294299
const enableResourceBrowser = !!config.resourceBrowser;
295300
let resourceBrowserPublic = false;
296301
if (config.resourceBrowser && config.resourceBrowser.public) {
@@ -547,6 +552,7 @@ function buildConfig(opts) {
547552
explorerPublic,
548553
explorerHideEmptyFilterSection,
549554
explorerFilterValuesToHide,
555+
forceSingleLoginDropdownOptions,
550556
authzPath,
551557
authzMappingPath,
552558
enableResourceBrowser,

0 commit comments

Comments
 (0)