Skip to content

Commit 84320bc

Browse files
nl0claude
andauthored
Catalog: migrate bucket queries to role-scoped Bucket type (#4839)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 752dd4a commit 84320bc

30 files changed

Lines changed: 361 additions & 166 deletions

File tree

catalog/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ where verb is one of
1818

1919
## Changes
2020

21+
- [Changed] Migrate user-facing bucket queries to the new role-scoped `buckets` / `bucket` GraphQL type; admins in a scoped managed role now see only role-permitted buckets in navbar / listings / deep-links (admin panel unchanged) ([#4839](https://github.com/quiltdata/quilt/pull/4839))
22+
- [Fixed] Refresh navbar bucket selector after bucket removal and after policy / role / user-role edits that change the caller's managed-role bucket set ([#4839](https://github.com/quiltdata/quilt/pull/4839))
2123
- [Added] HubSpot tracking ([#4807](https://github.com/quiltdata/quilt/pull/4807))
2224
- [Changed] Migrate `package-lock.json` from lockfileVersion 2 to 3 ([#4812](https://github.com/quiltdata/quilt/pull/4812))
2325
- [Changed] Replace `jsonpath` with `jsonpath-plus` for JSONPath evaluation ([#4811](https://github.com/quiltdata/quilt/pull/4811))

catalog/app/components/Assistant/Model/GlobalContext/stack.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import * as React from 'react'
22

3-
import * as BucketConfig from 'utils/BucketConfig'
3+
import * as Buckets from 'utils/Buckets'
44
import * as XML from 'utils/XML'
55

66
export function useStackInfo() {
7-
const bucketConfigs = BucketConfig.useRelevantBucketConfigs()
7+
const buckets = Buckets.useRelevantBuckets()
88

99
return React.useMemo(() => {
10-
const buckets = XML.tag(
10+
const bucketsXml = XML.tag(
1111
'buckets',
1212
{},
1313
'Buckets attached to this stack:',
14-
...bucketConfigs.map((b) =>
14+
...buckets.map((b) =>
1515
XML.tag(
1616
'bucket',
1717
{},
@@ -28,6 +28,6 @@ export function useStackInfo() {
2828
),
2929
),
3030
)
31-
return XML.tag('quilt-stack-info', {}, buckets).toString()
32-
}, [bucketConfigs])
31+
return XML.tag('quilt-stack-info', {}, bucketsXml).toString()
32+
}, [buckets])
3333
}

catalog/app/components/FileEditor/QuiltConfigEditor/BucketPreferences/BucketPreferences.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const theme = createMuiTheme()
1111

1212
vi.mock('constants/config', () => ({ default: {} }))
1313

14-
vi.mock('utils/BucketConfig', () => ({
15-
useRelevantBucketConfigs: () => [],
14+
vi.mock('utils/Buckets', () => ({
15+
useRelevantBuckets: () => [],
1616
}))
1717

1818
vi.mock('@material-ui/core', async () => ({

catalog/app/components/FileEditor/QuiltConfigEditor/BucketPreferences/BucketPreferences.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as Lab from '@material-ui/lab'
66
import JsonValidationErrors from 'components/JsonValidationErrors'
77
import { docs } from 'constants/urls'
88
import type * as Model from 'model'
9-
import * as BucketConfig from 'utils/BucketConfig'
9+
import * as Buckets from 'utils/Buckets'
1010
import StyledLink from 'utils/StyledLink'
1111
import { JsonInvalidAgainstSchema } from 'utils/error'
1212

@@ -121,13 +121,10 @@ function InputSourceBuckets({
121121
onChange,
122122
...props
123123
}: FieldProps<TypedValue<string[]>>) {
124-
const bucketConfigs = BucketConfig.useRelevantBucketConfigs()
125-
const options = React.useMemo(
126-
() => bucketConfigs.map((b) => `s3://${b.name}`),
127-
[bucketConfigs],
128-
)
124+
const buckets = Buckets.useRelevantBuckets()
125+
const options = React.useMemo(() => buckets.map((b) => `s3://${b.name}`), [buckets])
129126
const handleChange = React.useCallback(
130-
(_e, buckets: string[]) => onChange({ isDefault: false, key, value: buckets }),
127+
(_e, selected: string[]) => onChange({ isDefault: false, key, value: selected }),
131128
[key, onChange],
132129
)
133130
return (

catalog/app/components/Preview/loaders/Html/Html.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import cfg from 'constants/config'
66
import type * as Model from 'model'
77
import * as AWS from 'utils/AWS'
88
import AsyncResult from 'utils/AsyncResult'
9-
import { useIsInStack } from 'utils/BucketConfig'
9+
import { useIsInStack } from 'utils/Buckets'
1010
import * as GQL from 'utils/GraphQL'
1111
import log from 'utils/Logging'
1212
import type * as LogicalKeyResolver from 'utils/LogicalKeyResolver'
@@ -22,7 +22,7 @@ import * as Text from '../Text'
2222
import FileType from '../fileType'
2323
import * as utils from '../utils'
2424

25-
import BUCKET_CONFIG_QUERY from './gql/BrowsableBucketConfig.generated'
25+
import BROWSABLE_BUCKET_QUERY from './gql/BrowsableBucket.generated'
2626
import CREATE_BROWSING_SESSION from './gql/CreateBrowsingSession.generated'
2727
import DISPOSE_BROWSING_SESSION from './gql/DisposeBrowsingSession.generated'
2828
import REFRESH_BROWSING_SESSION from './gql/RefreshBrowsingSession.generated'
@@ -257,19 +257,16 @@ interface IFrameLoaderProps {
257257
}
258258

259259
function IFrameLoader({ handle, children }: IFrameLoaderProps) {
260-
const bucketData = GQL.useQuery(BUCKET_CONFIG_QUERY, { bucket: handle.bucket })
260+
const bucketData = GQL.useQuery(BROWSABLE_BUCKET_QUERY, { bucket: handle.bucket })
261261
const inPackage = !!handle.packageHandle
262262
return GQL.fold(bucketData, {
263263
fetching: () => children(AsyncResult.Pending()),
264264
error: (e) => children(AsyncResult.Err(e)),
265-
data: ({ bucketConfig }) =>
266-
bucketConfig?.browsable && inPackage ? (
265+
data: ({ bucket }) =>
266+
bucket?.browsable && inPackage ? (
267267
<IFrameLoaderBrowsable {...{ handle, children }} />
268268
) : (
269-
<IFrameLoaderSigned
270-
{...{ handle, children }}
271-
browsable={!!bucketConfig?.browsable}
272-
/>
269+
<IFrameLoaderSigned {...{ handle, children }} browsable={!!bucket?.browsable} />
273270
),
274271
})
275272
}

catalog/app/components/Preview/loaders/Html/gql/BrowsableBucketConfig.generated.ts renamed to catalog/app/components/Preview/loaders/Html/gql/BrowsableBucket.generated.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,28 @@
22
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'
33
import * as Types from '../../../../../model/graphql/types.generated'
44

5-
export type components_Preview_loaders_Html_gql_BrowsableBucketConfigQueryVariables =
5+
export type components_Preview_loaders_Html_gql_BrowsableBucketQueryVariables =
66
Types.Exact<{
77
bucket: Types.Scalars['String']
88
}>
99

10-
export type components_Preview_loaders_Html_gql_BrowsableBucketConfigQuery = {
10+
export type components_Preview_loaders_Html_gql_BrowsableBucketQuery = {
1111
readonly __typename: 'Query'
1212
} & {
13-
readonly bucketConfig: Types.Maybe<
14-
{ readonly __typename: 'BucketConfig' } & Pick<
15-
Types.BucketConfig,
16-
'name' | 'browsable'
17-
>
13+
readonly bucket: Types.Maybe<
14+
{ readonly __typename: 'Bucket' } & Pick<Types.Bucket, 'name' | 'browsable'>
1815
>
1916
}
2017

21-
export const components_Preview_loaders_Html_gql_BrowsableBucketConfigDocument = {
18+
export const components_Preview_loaders_Html_gql_BrowsableBucketDocument = {
2219
kind: 'Document',
2320
definitions: [
2421
{
2522
kind: 'OperationDefinition',
2623
operation: 'query',
2724
name: {
2825
kind: 'Name',
29-
value: 'components_Preview_loaders_Html_gql_BrowsableBucketConfig',
26+
value: 'components_Preview_loaders_Html_gql_BrowsableBucket',
3027
},
3128
variableDefinitions: [
3229
{
@@ -43,7 +40,7 @@ export const components_Preview_loaders_Html_gql_BrowsableBucketConfigDocument =
4340
selections: [
4441
{
4542
kind: 'Field',
46-
name: { kind: 'Name', value: 'bucketConfig' },
43+
name: { kind: 'Name', value: 'bucket' },
4744
arguments: [
4845
{
4946
kind: 'Argument',
@@ -64,8 +61,8 @@ export const components_Preview_loaders_Html_gql_BrowsableBucketConfigDocument =
6461
},
6562
],
6663
} as unknown as DocumentNode<
67-
components_Preview_loaders_Html_gql_BrowsableBucketConfigQuery,
68-
components_Preview_loaders_Html_gql_BrowsableBucketConfigQueryVariables
64+
components_Preview_loaders_Html_gql_BrowsableBucketQuery,
65+
components_Preview_loaders_Html_gql_BrowsableBucketQueryVariables
6966
>
7067

71-
export { components_Preview_loaders_Html_gql_BrowsableBucketConfigDocument as default }
68+
export { components_Preview_loaders_Html_gql_BrowsableBucketDocument as default }

catalog/app/components/Preview/loaders/Html/gql/BrowsableBucketConfig.graphql renamed to catalog/app/components/Preview/loaders/Html/gql/BrowsableBucket.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
query ($bucket: String!) {
2-
bucketConfig(name: $bucket) {
2+
bucket(name: $bucket) {
33
name
44
browsable
55
}

catalog/app/containers/Bucket/Overview/Overview.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import * as Summarize from '../Summarize'
1818
import * as requests from '../requests'
1919

2020
import Header from './Header'
21-
import BUCKET_CONFIG_QUERY from './gql/BucketConfig.generated'
21+
import BUCKET_QUERY from './gql/Bucket.generated'
2222

2323
interface BucketReadmes {
2424
forced?: Model.S3.S3ObjectLocation
@@ -116,10 +116,12 @@ export default function Overview() {
116116
const { bucket } = useParams<{ bucket: string }>()
117117

118118
const s3 = AWS.S3.use()
119-
const { bucketConfig } = GQL.useQueryS(BUCKET_CONFIG_QUERY, { bucket })
120-
const inStack = !!bucketConfig
121-
const overviewUrl = bucketConfig?.overviewUrl
122-
const description = bucketConfig?.description
119+
const { bucket: bucketData } = GQL.useQueryS(BUCKET_QUERY, { bucket })
120+
const inStack = !!bucketData
121+
// overviewUrl is dead; stubbed until the field + its Readmes/Imgs/
122+
// Summarize code paths are removed.
123+
const overviewUrl = undefined
124+
const description = bucketData?.description
123125
const { prefs } = BucketPreferences.use()
124126
return (
125127
<M.Box pb={{ xs: 0, sm: 4 }} mx={{ xs: -2, sm: 0 }} position="relative" zIndex={1}>
@@ -128,7 +130,7 @@ export default function Overview() {
128130
<LinkedData.BucketData bucket={bucket} />
129131
</React.Suspense>
130132
)}
131-
{bucketConfig ? (
133+
{bucketData ? (
132134
<Header {...{ s3, bucket, overviewUrl, description }} />
133135
) : (
134136
<M.Box

catalog/app/containers/Bucket/Overview/gql/BucketConfig.generated.ts renamed to catalog/app/containers/Bucket/Overview/gql/Bucket.generated.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,25 @@
22
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'
33
import * as Types from '../../../../model/graphql/types.generated'
44

5-
export type containers_Bucket_Overview_gql_BucketConfigQueryVariables = Types.Exact<{
5+
export type containers_Bucket_Overview_gql_BucketQueryVariables = Types.Exact<{
66
bucket: Types.Scalars['String']
77
}>
88

9-
export type containers_Bucket_Overview_gql_BucketConfigQuery = {
9+
export type containers_Bucket_Overview_gql_BucketQuery = {
1010
readonly __typename: 'Query'
1111
} & {
12-
readonly bucketConfig: Types.Maybe<
13-
{ readonly __typename: 'BucketConfig' } & Pick<
14-
Types.BucketConfig,
15-
'name' | 'description' | 'overviewUrl'
16-
>
12+
readonly bucket: Types.Maybe<
13+
{ readonly __typename: 'Bucket' } & Pick<Types.Bucket, 'name' | 'description'>
1714
>
1815
}
1916

20-
export const containers_Bucket_Overview_gql_BucketConfigDocument = {
17+
export const containers_Bucket_Overview_gql_BucketDocument = {
2118
kind: 'Document',
2219
definitions: [
2320
{
2421
kind: 'OperationDefinition',
2522
operation: 'query',
26-
name: { kind: 'Name', value: 'containers_Bucket_Overview_gql_BucketConfig' },
23+
name: { kind: 'Name', value: 'containers_Bucket_Overview_gql_Bucket' },
2724
variableDefinitions: [
2825
{
2926
kind: 'VariableDefinition',
@@ -39,7 +36,7 @@ export const containers_Bucket_Overview_gql_BucketConfigDocument = {
3936
selections: [
4037
{
4138
kind: 'Field',
42-
name: { kind: 'Name', value: 'bucketConfig' },
39+
name: { kind: 'Name', value: 'bucket' },
4340
arguments: [
4441
{
4542
kind: 'Argument',
@@ -52,7 +49,6 @@ export const containers_Bucket_Overview_gql_BucketConfigDocument = {
5249
selections: [
5350
{ kind: 'Field', name: { kind: 'Name', value: 'name' } },
5451
{ kind: 'Field', name: { kind: 'Name', value: 'description' } },
55-
{ kind: 'Field', name: { kind: 'Name', value: 'overviewUrl' } },
5652
],
5753
},
5854
},
@@ -61,8 +57,8 @@ export const containers_Bucket_Overview_gql_BucketConfigDocument = {
6157
},
6258
],
6359
} as unknown as DocumentNode<
64-
containers_Bucket_Overview_gql_BucketConfigQuery,
65-
containers_Bucket_Overview_gql_BucketConfigQueryVariables
60+
containers_Bucket_Overview_gql_BucketQuery,
61+
containers_Bucket_Overview_gql_BucketQueryVariables
6662
>
6763

68-
export { containers_Bucket_Overview_gql_BucketConfigDocument as default }
64+
export { containers_Bucket_Overview_gql_BucketDocument as default }

catalog/app/containers/Bucket/Overview/gql/BucketConfig.graphql renamed to catalog/app/containers/Bucket/Overview/gql/Bucket.graphql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
query ($bucket: String!) {
2-
bucketConfig(name: $bucket) {
2+
bucket(name: $bucket) {
33
name
44
description
5-
overviewUrl
65
}
76
}

0 commit comments

Comments
 (0)