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 (unrestricted access) #4255

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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>
)
}
99 changes: 99 additions & 0 deletions catalog/app/containers/Admin/Settings/TabulatorSettings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import * as Eff from 'effect'
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 5 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-L5

Added lines #L1 - L5 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 11 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#L7-L11

Added lines #L7 - L11 were not covered by tests

import UNRESTRICTED_QUERY from './gql/TabulatorUnrestricted.generated'
import SET_UNRESTRICTED_MUTATION from './gql/SetTabulatorUnrestricted.generated'

Check warning on line 14 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#L13-L14

Added lines #L13 - L14 were not covered by tests

interface ToggleProps {
checked: boolean
}

const NONE = Eff.Option.none<{ value: boolean }>()

Check warning on line 20 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#L20

Added line #L20 was not covered by tests

function Toggle({ checked }: ToggleProps) {
const { push: notify } = Notifications.use()
const mutate = GQL.useMutation(SET_UNRESTRICTED_MUTATION)
const [mutationState, setMutationState] = React.useState(NONE)

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#L22-L25

Added lines #L22 - L25 were not covered by tests

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

Check warning on line 28 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-L28

Added lines #L27 - L28 were not covered by tests
if (Eff.Option.isSome(mutationState)) return
setMutationState(Eff.Option.some({ value }))

Check warning on line 30 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#L30

Added line #L30 was not covered by tests
try {
await mutate({ value })

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#L32

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

Check warning on line 35 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-L35

Added lines #L34 - L35 were not covered by tests
} finally {
setMutationState(NONE)

Check warning on line 37 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#L37

Added line #L37 was not covered by tests
}
},
[mutate, notify, mutationState, setMutationState],
nl0 marked this conversation as resolved.
Show resolved Hide resolved
)

const value = Eff.pipe(

Check warning on line 43 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#L43

Added line #L43 was not covered by tests
mutationState,
Eff.Option.map((x) => x.value),
Eff.Option.getOrElse(() => checked),

Check warning on line 46 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#L45-L46

Added lines #L45 - L46 were not covered by tests
)

return (

Check warning on line 49 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#L49

Added line #L49 was not covered by tests
<>
<M.FormControlLabel
control={
<M.Switch
checked={value}
onChange={handleChange}
disabled={Eff.Option.isSome(mutationState)}
/>
}
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 77 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#L76-L77

Added lines #L76 - L77 were not covered by tests

return (

Check warning on line 79 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#L79

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

Check warning on line 83 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#L82-L83

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

Check warning on line 89 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#L89

Added line #L89 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