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

Catalog: Admin: Tabulator Settings (open query) + docs #4255

Merged
merged 28 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions catalog/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ where verb is one of

## Changes

- [Added] Admin: Tabulator Settings (open query) ([#4255](https://github.com/quiltdata/quilt/pull/4255))
- [Added] Visual editor for `quilt_summarize.json` ([#4254](https://github.com/quiltdata/quilt/pull/4254))
- [Added] Support "html" type in `quilt_summarize.json` ([#4252](https://github.com/quiltdata/quilt/pull/4252))
- [Fixed] Resolve caching issues where changes in `.quilt/{workflows,catalog}` were not applied ([#4245](https://github.com/quiltdata/quilt/pull/4245))
Expand Down
12 changes: 12 additions & 0 deletions catalog/app/containers/Admin/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import * as Form from '../Form'
import SearchSettings from './SearchSettings'
import TabulatorSettings from './TabulatorSettings'

Check warning on line 15 in catalog/app/containers/Admin/Settings/Settings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/Settings.tsx#L15

Added line #L15 was not covered by tests
import ThemeEditor from './ThemeEditor'

function useBeta(): [boolean, (b: boolean) => Promise<void>] {
Expand Down Expand Up @@ -273,6 +274,10 @@
title: {
margin: t.spacing(0, 0, 2),
padding: t.spacing(0, 2),

'* + &': {
marginTop: t.spacing(2),
},
},
}))

Expand Down Expand Up @@ -324,6 +329,13 @@
</M.Paper>
</M.Grid>
</M.Grid>

<M.Typography variant="h5" className={classes.title}>
Tabulator Settings
</M.Typography>
<M.Paper className={classes.group}>
<TabulatorSettings />
</M.Paper>
</div>
)
}
90 changes: 90 additions & 0 deletions catalog/app/containers/Admin/Settings/TabulatorSettings.tsx
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'

Check warning on line 4 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L1-L4

Added lines #L1 - L4 were not covered by tests

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'

Check warning on line 10 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L6-L10

Added lines #L6 - L10 were not covered by tests

import OPEN_QUERY_QUERY from './gql/TabulatorOpenQuery.generated'
import SET_OPEN_QUERY_MUTATION from './gql/SetTabulatorOpenQuery.generated'

Check warning on line 13 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L12-L13

Added lines #L12 - L13 were not covered by tests

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)

Check warning on line 22 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L19-L22

Added lines #L19 - L22 were not covered by tests

const handleChange = React.useCallback(
async (_event, enabled: boolean) => {

Check warning on line 25 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L24-L25

Added lines #L24 - L25 were not covered by tests
if (mutation) return
setMutation({ enabled })

Check warning on line 27 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L27

Added line #L27 was not covered by tests
try {
await mutate({ enabled })

Check warning on line 29 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L29

Added line #L29 was not covered by tests
} catch (e) {
Sentry.captureException(e)
notify(`Failed to update tabulator settings: ${e}`)

Check warning on line 32 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L31-L32

Added lines #L31 - L32 were not covered by tests
} finally {
setMutation(null)

Check warning on line 34 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L34

Added line #L34 was not covered by tests
}
},
[mutate, notify, mutation],
)

return (

Check warning on line 40 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L40

Added line #L40 was not covered by tests
<>
<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)

Check warning on line 68 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L67-L68

Added lines #L67 - L68 were not covered by tests

return (

Check warning on line 70 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L70

Added line #L70 was not covered by tests
<M.FormGroup>
{GQL.fold(query, {
data: ({ admin }) => <Toggle checked={admin.tabulatorOpenQuery} />,
fetching: () => (

Check warning on line 74 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L73-L74

Added lines #L73 - L74 were not covered by tests
<>
<Skeleton width="40%" height={38} />
<Skeleton width="80%" height={20} mt="3px" />
</>
),
error: (e) => (

Check warning on line 80 in catalog/app/containers/Admin/Settings/TabulatorSettings.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/TabulatorSettings.tsx#L80

Added line #L80 was not covered by tests
<Lab.Alert severity="error">
Could not fetch tabulator settings:
<br />
{e.message}
</Lab.Alert>
),
})}
</M.FormGroup>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* eslint-disable @typescript-eslint/naming-convention */
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'
import * as Types from '../../../../model/graphql/types.generated'

export type containers_Admin_Settings_gql_SetTabulatorOpenQueryMutationVariables =
Types.Exact<{
enabled: Types.Scalars['Boolean']
}>

export type containers_Admin_Settings_gql_SetTabulatorOpenQueryMutation = {
readonly __typename: 'Mutation'
} & {
readonly admin: { readonly __typename: 'AdminMutations' } & {
readonly setTabulatorOpenQuery: {
readonly __typename: 'TabulatorOpenQueryResult'
} & Pick<Types.TabulatorOpenQueryResult, 'tabulatorOpenQuery'>
}
}

export const containers_Admin_Settings_gql_SetTabulatorOpenQueryDocument = {

Check warning on line 20 in catalog/app/containers/Admin/Settings/gql/SetTabulatorOpenQuery.generated.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/gql/SetTabulatorOpenQuery.generated.ts#L20

Added line #L20 was not covered by tests
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'mutation',
name: {
kind: 'Name',
value: 'containers_Admin_Settings_gql_SetTabulatorOpenQuery',
},
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'enabled' } },
type: {
kind: 'NonNullType',
type: { kind: 'NamedType', name: { kind: 'Name', value: 'Boolean' } },
},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'admin' },
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'setTabulatorOpenQuery' },
arguments: [
{
kind: 'Argument',
name: { kind: 'Name', value: 'enabled' },
value: {
kind: 'Variable',
name: { kind: 'Name', value: 'enabled' },
},
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'tabulatorOpenQuery' },
},
],
},
},
],
},
},
],
},
},
],
} as unknown as DocumentNode<
containers_Admin_Settings_gql_SetTabulatorOpenQueryMutation,
containers_Admin_Settings_gql_SetTabulatorOpenQueryMutationVariables
>

export { containers_Admin_Settings_gql_SetTabulatorOpenQueryDocument as default }

Check warning on line 84 in catalog/app/containers/Admin/Settings/gql/SetTabulatorOpenQuery.generated.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/gql/SetTabulatorOpenQuery.generated.ts#L84

Added line #L84 was not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mutation($enabled: Boolean!) {
admin {
setTabulatorOpenQuery(enabled: $enabled) {
tabulatorOpenQuery
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* eslint-disable @typescript-eslint/naming-convention */
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'
import * as Types from '../../../../model/graphql/types.generated'

export type containers_Admin_Settings_gql_TabulatorOpenQueryQueryVariables = Types.Exact<{
[key: string]: never
}>

export type containers_Admin_Settings_gql_TabulatorOpenQueryQuery = {
readonly __typename: 'Query'
} & {
readonly admin: { readonly __typename: 'AdminQueries' } & Pick<
Types.AdminQueries,
'tabulatorOpenQuery'
>
}

export const containers_Admin_Settings_gql_TabulatorOpenQueryDocument = {

Check warning on line 18 in catalog/app/containers/Admin/Settings/gql/TabulatorOpenQuery.generated.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/gql/TabulatorOpenQuery.generated.ts#L18

Added line #L18 was not covered by tests
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: { kind: 'Name', value: 'containers_Admin_Settings_gql_TabulatorOpenQuery' },
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'admin' },
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'tabulatorOpenQuery' } },
],
},
},
],
},
},
],
} as unknown as DocumentNode<
containers_Admin_Settings_gql_TabulatorOpenQueryQuery,
containers_Admin_Settings_gql_TabulatorOpenQueryQueryVariables
>

export { containers_Admin_Settings_gql_TabulatorOpenQueryDocument as default }

Check warning on line 47 in catalog/app/containers/Admin/Settings/gql/TabulatorOpenQuery.generated.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/gql/TabulatorOpenQuery.generated.ts#L47

Added line #L47 was not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query {
admin {
tabulatorOpenQuery
}
}
63 changes: 59 additions & 4 deletions catalog/app/model/graphql/schema.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,37 @@ export default {
},
],
},
{
name: 'setTabulatorOpenQuery',
type: {
kind: 'NON_NULL',
ofType: {
kind: 'OBJECT',
name: 'TabulatorOpenQueryResult',
ofType: null,
},
},
args: [
{
name: 'enabled',
type: {
kind: 'NON_NULL',
ofType: {
kind: 'SCALAR',
name: 'Boolean',
ofType: null,
},
},
},
],
},
],
interfaces: [],
},
{
kind: 'SCALAR',
name: 'Boolean',
},
{
kind: 'OBJECT',
name: 'AdminQueries',
Expand Down Expand Up @@ -280,13 +308,21 @@ export default {
},
args: [],
},
{
name: 'tabulatorOpenQuery',
type: {
kind: 'NON_NULL',
ofType: {
kind: 'SCALAR',
name: 'Boolean',
ofType: null,
},
},
args: [],
},
],
interfaces: [],
},
{
kind: 'SCALAR',
name: 'Boolean',
},
{
kind: 'OBJECT',
name: 'BooleanPackageUserMetaFacet',
Expand Down Expand Up @@ -5437,6 +5473,25 @@ export default {
},
],
},
{
kind: 'OBJECT',
name: 'TabulatorOpenQueryResult',
fields: [
{
name: 'tabulatorOpenQuery',
type: {
kind: 'NON_NULL',
ofType: {
kind: 'SCALAR',
name: 'Boolean',
ofType: null,
},
},
args: [],
},
],
interfaces: [],
},
{
kind: 'OBJECT',
name: 'TabulatorTable',
Expand Down
Loading
Loading