Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
fiskus committed Dec 20, 2024
2 parents ddd610e + fbab903 commit 77228bf
Show file tree
Hide file tree
Showing 24 changed files with 549 additions and 16 deletions.
14 changes: 14 additions & 0 deletions api/python/quilt3-admin/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,17 @@ mutation bucketTabulatorTableRename($bucketName: String!, $tableName: String!, $
}
}
}

query tabulatorGetOpenQuery {
admin {
tabulatorOpenQuery
}
}

mutation tabulatorSetOpenQuery($enabled: Boolean!) {
admin {
setTabulatorOpenQuery(enabled: $enabled) {
tabulatorOpenQuery
}
}
}
11 changes: 11 additions & 0 deletions api/python/quilt3/admin/_graphql_client/__init__.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions api/python/quilt3/admin/_graphql_client/client.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions api/python/quilt3/admin/tabulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@ def rename_table(bucket_name: str, table_name: str, new_table_name: str) -> None
"""
result = util.get_client().bucket_tabulator_table_rename(bucket_name, table_name, new_table_name)
util.handle_errors(result)


def get_open_query() -> bool:
"""
Get the **open query** status.
"""
return util.get_client().tabulator_get_open_query()


def set_open_query(enabled: bool) -> None:
"""
Set the **open query** status.
"""
util.get_client().tabulator_set_open_query(enabled)
17 changes: 17 additions & 0 deletions api/python/tests/test_admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,3 +423,20 @@ def test_tabulator_rename(data, result):
admin.tabulator.rename_table("test", "table", "new_table")
else:
assert admin.tabulator.rename_table("test", "table", "new_table") == result


def test_tabulator_get_open_query():
with mock_client(
_make_nested_dict("admin.tabulator_open_query", True),
"tabulatorGetOpenQuery",
):
assert admin.tabulator.get_open_query() is True


def test_tabulator_set_open_query():
with mock_client(
_make_nested_dict("admin.set_tabulator_open_query.tabulator_open_query", True),
"tabulatorSetOpenQuery",
variables={"enabled": True},
):
assert admin.tabulator.set_open_query(True) is None
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
2 changes: 1 addition & 1 deletion catalog/app/components/FileEditor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ export type Mode =
| '__bucketPreferences'
| '__quiltConfig'
| '__quiltSummarize'
| 'less'
| 'json'
| 'less'
| 'markdown'
| 'plain_text'
| 'yaml'
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 validators from 'utils/validators'

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

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

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

Expand Down Expand Up @@ -324,6 +329,13 @@ export default function Settings() {
</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'

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>
)
}
Loading

0 comments on commit 77228bf

Please sign in to comment.