Skip to content

Commit 4c9ff08

Browse files
authored
DT-1219: Allow un-selecting auth domains on snapshot create (#1753)
1 parent 9d63223 commit 4c9ff08

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

src/components/common/FullViewSnapshotButton.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ describe('FullViewSnapshotButton', () => {
9494

9595
it('allows selecting an auth domain', () => {
9696
cy.get('button').click();
97-
cy.get('#authorization-domain-select').parent().click();
97+
cy.get('#select-authorization-domain-select').parent().click();
9898
cy.get('[data-cy=menuItem-group2]').click();
99-
cy.get('#authorization-domain-select').should('have.value', 'group2');
99+
cy.get('#select-authorization-domain-select').should('have.value', 'group2');
100100
});
101101

102102
it('allows changing the name and description', () => {

src/components/common/FullViewSnapshotButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function FullViewSnapshotButton({
181181
<div style={{ marginTop: 8 }}>
182182
<FormLabel
183183
sx={{ fontWeight: 600, color: 'black' }}
184-
htmlFor="authorization-domain-select"
184+
htmlFor="select-authorization-domain-select"
185185
>
186186
Authorization Domain
187187
<span style={{ fontWeight: 400, color: 'black' }}> - (optional)</span>
@@ -191,9 +191,10 @@ function FullViewSnapshotButton({
191191
sx={{ height: '2.5rem' }}
192192
disabled={userGroups ? userGroups.length <= 1 : true}
193193
options={userGroups ? userGroups.map((group) => group.groupName) : []}
194-
name="authorization-domain"
194+
name="Select Authorization Domain"
195195
onSelectedItem={(event) => setSelectedAuthDomain(event.target.value)}
196196
value={selectedAuthDomain || ''}
197+
includeNoneOption={true}
197198
/>
198199
<div>
199200
Authorization Domains restrict data access to only specified individuals in a group and

src/components/dataset/data/JadeDropdown.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import _ from 'lodash';
3-
import { MenuItem, FormControl, Select, SelectChangeEvent } from '@mui/material';
3+
import { MenuItem, FormControl, Select, SelectChangeEvent, Box } from '@mui/material';
44

55
type IProps<T> = {
66
disabled: boolean;
@@ -9,9 +9,18 @@ type IProps<T> = {
99
options: T[];
1010
value: T;
1111
sx?: React.CSSProperties;
12+
includeNoneOption?: boolean;
1213
};
1314

14-
function JadeDropdown({ disabled, name, onSelectedItem, options, value, sx }: IProps<string>) {
15+
function JadeDropdown({
16+
disabled,
17+
name,
18+
onSelectedItem,
19+
options,
20+
value,
21+
sx,
22+
includeNoneOption,
23+
}: IProps<string>) {
1524
return (
1625
<form autoComplete="off">
1726
<FormControl disabled={disabled} variant="outlined" fullWidth>
@@ -20,13 +29,18 @@ function JadeDropdown({ disabled, name, onSelectedItem, options, value, sx }: IP
2029
onChange={(event) => onSelectedItem(event)}
2130
inputProps={{
2231
name,
23-
id: `${name}-select`,
32+
id: `${_.kebabCase(name)}-select`,
2433
}}
2534
displayEmpty
2635
renderValue={(val) => (!val ? name : val)}
2736
data-cy={_.camelCase(name)}
2837
sx={sx}
2938
>
39+
{includeNoneOption && (
40+
<MenuItem key="None" value="">
41+
<Box sx={{ fontStyle: 'italic' }}>None</Box>
42+
</MenuItem>
43+
)}
3044
{options.map((opt) => (
3145
<MenuItem key={opt} value={opt} data-cy={`menuItem-${opt}`}>
3246
{opt}

0 commit comments

Comments
 (0)