Skip to content
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

[DT-1171] Add auth domain to snapshot access #1752

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
anchor: null,
hasError: false,
errorMsg: '',
authDomain: undefined,

Check warning on line 98 in src/components/dataset/data/sidebar/panels/ShareSnapshot.jsx

View workflow job for this annotation

GitHub Actions / lint (20.x)

Unused state field: 'authDomain'
};
}

Expand All @@ -107,6 +108,10 @@
setIsSharing: PropTypes.func,
};

setAuthDomain = (domain) => {
this.setState({ authDomain: domain });

Check warning on line 112 in src/components/dataset/data/sidebar/panels/ShareSnapshot.jsx

View workflow job for this annotation

GitHub Actions / lint (20.x)

Unused state field: 'authDomain'
};

saveSnapshot = () => {
const { dispatch } = this.props;
dispatch(createSnapshot(undefined));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I pass authDomain to createSnapshot? It isn't clear to me.

Expand All @@ -124,7 +129,7 @@
<Typography variant="h6" className={classes.section}>
Share Snapshot
</Typography>
<SnapshotAccess createMode={true} />
<SnapshotAccess createMode={true} setParentAuthDomain={this.setAuthDomain} />
{!isModal && (
<div className={classes.bottom}>
<Button
Expand Down
6 changes: 5 additions & 1 deletion src/components/snapshot/SnapshotAccess.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ const mountSnapshotAccess = (userGroups: Array<ManagedGroupMembershipEntry>) =>
<Router history={history}>
<Provider store={store}>
<ThemeProvider theme={globalTheme}>
<SnapshotAccess />
<SnapshotAccess
setParentAuthDomain={() => {
/* no-op */
}}
/>
</ThemeProvider>
</Provider>
</Router>,
Expand Down
8 changes: 7 additions & 1 deletion src/components/snapshot/SnapshotAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type SnapshotAccessProps = {
userRoles: Array<string>;
createMode?: boolean;
userGroups: Array<ManagedGroupMembershipEntry>;
setParentAuthDomain: (domain: string) => void;
};

function SnapshotAccess({
Expand All @@ -48,6 +49,7 @@ function SnapshotAccess({
userRoles,
createMode,
userGroups,
setParentAuthDomain,
}: SnapshotAccessProps) {
const [selectedAuthDomain, setSelectedAuthDomain] = React.useState<string | undefined>(undefined);

Expand Down Expand Up @@ -181,7 +183,11 @@ function SnapshotAccess({
disabled={userGroups ? userGroups.length <= 1 : true}
options={userGroups ? userGroups.map((group) => group.groupName) : []}
name="authorization-domain"
onSelectedItem={(event) => setSelectedAuthDomain(event.target.value)}
onSelectedItem={(event) => {
const authDomain = event.target.value;
setParentAuthDomain(authDomain);
setSelectedAuthDomain(authDomain);
}}
value={selectedAuthDomain || ''}
/>
</>
Expand Down