-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
549 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
api/python/quilt3/admin/_graphql_client/tabulator_get_open_query.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
api/python/quilt3/admin/_graphql_client/tabulator_set_open_query.py
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
catalog/app/containers/Admin/Settings/TabulatorSettings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import * as React from 'react' | ||
import * as M from '@material-ui/core' | ||
import * as Lab from '@material-ui/lab' | ||
import * as Sentry from '@sentry/react' | ||
|
||
import Skeleton from 'components/Skeleton' | ||
import { docs } from 'constants/urls' | ||
import * as Notifications from 'containers/Notifications' | ||
import * as GQL from 'utils/GraphQL' | ||
import StyledLink from 'utils/StyledLink' | ||
|
||
import OPEN_QUERY_QUERY from './gql/TabulatorOpenQuery.generated' | ||
import SET_OPEN_QUERY_MUTATION from './gql/SetTabulatorOpenQuery.generated' | ||
|
||
interface ToggleProps { | ||
checked: boolean | ||
} | ||
|
||
function Toggle({ checked }: ToggleProps) { | ||
const { push: notify } = Notifications.use() | ||
const mutate = GQL.useMutation(SET_OPEN_QUERY_MUTATION) | ||
const [mutation, setMutation] = React.useState<{ enabled: boolean } | null>(null) | ||
|
||
const handleChange = React.useCallback( | ||
async (_event, enabled: boolean) => { | ||
if (mutation) return | ||
setMutation({ enabled }) | ||
try { | ||
await mutate({ enabled }) | ||
} catch (e) { | ||
Sentry.captureException(e) | ||
notify(`Failed to update tabulator settings: ${e}`) | ||
} finally { | ||
setMutation(null) | ||
} | ||
}, | ||
[mutate, notify, mutation], | ||
) | ||
|
||
return ( | ||
<> | ||
<M.FormControlLabel | ||
control={ | ||
<M.Switch | ||
checked={mutation?.enabled ?? checked} | ||
onChange={handleChange} | ||
disabled={!!mutation} | ||
/> | ||
} | ||
label="Enable open querying of Tabulator tables" | ||
/> | ||
<M.FormHelperText> | ||
<b>CAUTION:</b> When enabled, Tabulator defers all access control to AWS and does | ||
not enforce any extra restrictions.{' '} | ||
<StyledLink | ||
href={`${docs}/advanced-features/tabulator#open-query`} | ||
target="_blank" | ||
> | ||
Learn more | ||
</StyledLink>{' '} | ||
in the documentation. | ||
</M.FormHelperText> | ||
</> | ||
) | ||
} | ||
|
||
export default function TabulatorSettings() { | ||
const query = GQL.useQuery(OPEN_QUERY_QUERY) | ||
|
||
return ( | ||
<M.FormGroup> | ||
{GQL.fold(query, { | ||
data: ({ admin }) => <Toggle checked={admin.tabulatorOpenQuery} />, | ||
fetching: () => ( | ||
<> | ||
<Skeleton width="40%" height={38} /> | ||
<Skeleton width="80%" height={20} mt="3px" /> | ||
</> | ||
), | ||
error: (e) => ( | ||
<Lab.Alert severity="error"> | ||
Could not fetch tabulator settings: | ||
<br /> | ||
{e.message} | ||
</Lab.Alert> | ||
), | ||
})} | ||
</M.FormGroup> | ||
) | ||
} |
Oops, something went wrong.