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 12 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
5 changes: 3 additions & 2 deletions .github/workflows/deploy-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- tabulator-feature-flag # FIXME: revert
paths:
- '.github/workflows/deploy-catalog.yaml'
- 'catalog/**'
Expand Down Expand Up @@ -64,5 +65,5 @@ jobs:
-t $ECR_REGISTRY_MP/$ECR_REPOSITORY_MP:$IMAGE_TAG \
.
docker push $ECR_REGISTRY_PROD/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY_GOVCLOUD/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY_MP/$ECR_REPOSITORY_MP:$IMAGE_TAG
# docker push $ECR_REGISTRY_GOVCLOUD/$ECR_REPOSITORY:$IMAGE_TAG
# docker push $ECR_REGISTRY_MP/$ECR_REPOSITORY_MP:$IMAGE_TAG
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 (unrestricted access) ([#4255](https://github.com/quiltdata/quilt/pull/4255))
- [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))
- [Added] A shortcut to enable adding files to a package from the current bucket ([#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 UNRESTRICTED_QUERY from './gql/TabulatorUnrestricted.generated'
import SET_UNRESTRICTED_MUTATION from './gql/SetTabulatorUnrestricted.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_UNRESTRICTED_MUTATION)
const [mutation, setMutation] = React.useState<{ value: 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, value: 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({ value })

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({ value })

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?.value ?? checked}
onChange={handleChange}
disabled={!!mutation}
/>
}
label="Enable unrestricted access"
/>
<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#unrestricted-access`}
target="_blank"
>
Learn more
</StyledLink>{' '}
in the documentation.
</M.FormHelperText>
</>
)
}

export default function TabulatorSettings() {
const query = GQL.useQuery(UNRESTRICTED_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.tabulatorUnrestricted} />,
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,81 @@
/* 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_SetTabulatorUnrestrictedMutationVariables =
Types.Exact<{
value: Types.Scalars['Boolean']
}>

export type containers_Admin_Settings_gql_SetTabulatorUnrestrictedMutation = {
readonly __typename: 'Mutation'
} & {
readonly admin: { readonly __typename: 'AdminMutations' } & {
readonly setTabulatorUnrestricted: {
readonly __typename: 'TabulatorUnrestrictedResult'
} & Pick<Types.TabulatorUnrestrictedResult, 'tabulatorUnrestricted'>
}
}

export const containers_Admin_Settings_gql_SetTabulatorUnrestrictedDocument = {

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

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/gql/SetTabulatorUnrestricted.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_SetTabulatorUnrestricted',
},
variableDefinitions: [
{
kind: 'VariableDefinition',
variable: { kind: 'Variable', name: { kind: 'Name', value: 'value' } },
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: 'setTabulatorUnrestricted' },
arguments: [
{
kind: 'Argument',
name: { kind: 'Name', value: 'value' },
value: { kind: 'Variable', name: { kind: 'Name', value: 'value' } },
},
],
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'tabulatorUnrestricted' },
},
],
},
},
],
},
},
],
},
},
],
} as unknown as DocumentNode<
containers_Admin_Settings_gql_SetTabulatorUnrestrictedMutation,
containers_Admin_Settings_gql_SetTabulatorUnrestrictedMutationVariables
>

export { containers_Admin_Settings_gql_SetTabulatorUnrestrictedDocument as default }

Check warning on line 81 in catalog/app/containers/Admin/Settings/gql/SetTabulatorUnrestricted.generated.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/gql/SetTabulatorUnrestricted.generated.ts#L81

Added line #L81 was not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mutation($value: Boolean!) {
admin {
setTabulatorUnrestricted(value: $value) {
tabulatorUnrestricted
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* 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_TabulatorUnrestrictedQueryVariables =
Types.Exact<{ [key: string]: never }>

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

export const containers_Admin_Settings_gql_TabulatorUnrestrictedDocument = {

Check warning on line 17 in catalog/app/containers/Admin/Settings/gql/TabulatorUnrestricted.generated.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/gql/TabulatorUnrestricted.generated.ts#L17

Added line #L17 was not covered by tests
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: {
kind: 'Name',
value: 'containers_Admin_Settings_gql_TabulatorUnrestricted',
},
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'admin' },
selectionSet: {
kind: 'SelectionSet',
selections: [
{ kind: 'Field', name: { kind: 'Name', value: 'tabulatorUnrestricted' } },
],
},
},
],
},
},
],
} as unknown as DocumentNode<
containers_Admin_Settings_gql_TabulatorUnrestrictedQuery,
containers_Admin_Settings_gql_TabulatorUnrestrictedQueryVariables
>

export { containers_Admin_Settings_gql_TabulatorUnrestrictedDocument as default }

Check warning on line 49 in catalog/app/containers/Admin/Settings/gql/TabulatorUnrestricted.generated.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Admin/Settings/gql/TabulatorUnrestricted.generated.ts#L49

Added line #L49 was not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query {
admin {
tabulatorUnrestricted
}
}
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: 'setTabulatorUnrestricted',
type: {
kind: 'NON_NULL',
ofType: {
kind: 'OBJECT',
name: 'TabulatorUnrestrictedResult',
ofType: null,
},
},
args: [
{
name: 'value',
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: 'tabulatorUnrestricted',
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 @@ -5468,6 +5504,25 @@ export default {
],
interfaces: [],
},
{
kind: 'OBJECT',
name: 'TabulatorUnrestrictedResult',
fields: [
{
name: 'tabulatorUnrestricted',
type: {
kind: 'NON_NULL',
ofType: {
kind: 'SCALAR',
name: 'Boolean',
ofType: null,
},
},
args: [],
},
],
interfaces: [],
},
{
kind: 'OBJECT',
name: 'TestStats',
Expand Down
Loading
Loading