-
Notifications
You must be signed in to change notification settings - Fork 701
[6.x] Port GraphQL screens to Inertia #19167
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
Merged
+994
−794
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e0dc6f2
Port GraphQL screens to Inertia
riasvdv 8f770b4
Fix GraphQL permission types
riasvdv 05ecae0
Fix serialized permission group types
riasvdv 1f5e1d9
Use config for GraphQL transform directive
riasvdv 374c6e5
Merge branch '6.x' into feature/inertia-graphql
riasvdv 28d7e98
UX improvements
riasvdv 59ffc0f
Move details pane into AppLayout
riasvdv 77989df
Not lowercasing broke user permissions, add a preserveCase option ins…
riasvdv d272acf
Canonicalize user permissions on the backend
riasvdv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| <script setup lang="ts"> | ||
| import {t} from '@craftcms/cp'; | ||
| import AppLayout from '@/common/layouts/AppLayout.vue'; | ||
| import Pane from '@/common/components/Pane.vue'; | ||
| import CraftInput from '@craftcms/cp/vue/CraftInput.vue'; | ||
| import CraftSwitch from '@craftcms/cp/vue/CraftSwitch.vue'; | ||
| import PermissionList from '@/modules/permissions/components/PermissionList.vue'; | ||
| import {useSettingsSave} from '@/modules/settings/composables/useSettingsSave'; | ||
| import {store, update} from '@actions/Gql/SchemasController'; | ||
| import {useForm} from '@inertiajs/vue3'; | ||
|
|
||
| type TokenData = Pick< | ||
| CraftCms.Cms.Gql.Data.GqlToken, | ||
| 'id' | 'enabled' | 'expiryDate' | ||
| >; | ||
|
|
||
| interface SchemaForm { | ||
| name: string; | ||
| permissions: Array<string>; | ||
| enabled: boolean; | ||
| expiryDate: string; | ||
| } | ||
|
|
||
| type PermissionGroup = Omit< | ||
| CraftCms.Cms.User.Data.PermissionGroup, | ||
| 'permissions' | ||
| > & { | ||
| permissions: Record<string, CraftCms.Cms.User.Data.Permission>; | ||
| }; | ||
|
|
||
| const props = defineProps<{ | ||
| schema: CraftCms.Cms.Gql.Data.GqlSchema; | ||
| token: TokenData | null; | ||
| permissions: Array<PermissionGroup>; | ||
| readOnly?: boolean; | ||
| }>(); | ||
|
|
||
| const form = useForm<SchemaForm>({ | ||
| name: props.schema.name ?? '', | ||
| permissions: props.schema.scope ?? [], | ||
| enabled: props.token?.enabled ?? true, | ||
| expiryDate: props.token?.expiryDate ?? '', | ||
| }); | ||
|
|
||
| const routeAction = () => { | ||
| if (!props.schema.id) { | ||
| return store(); | ||
| } | ||
|
|
||
| return update({ | ||
| schemaId: props.schema.isPublic ? 'public' : props.schema.id, | ||
| }); | ||
| }; | ||
|
|
||
| const {save} = useSettingsSave(form, routeAction); | ||
| </script> | ||
|
|
||
| <template> | ||
| <AppLayout :form="form" @save="save"> | ||
| <Pane appearance="raised"> | ||
| <div class="grid gap-3"> | ||
| <CraftInput | ||
| v-if="!schema.isPublic" | ||
| :label="t('Name')" | ||
| :help-text=" | ||
| t('What this schema will be called in the control panel.') | ||
| " | ||
| id="name" | ||
| name="name" | ||
| v-model="form.name" | ||
| :error="form.errors.name" | ||
| :disabled="readOnly" | ||
| required | ||
| autofocus | ||
| /> | ||
|
|
||
| <hr v-if="!schema.isPublic" /> | ||
|
|
||
| <section class="grid gap-3"> | ||
| <h2 class="text-base"> | ||
| {{ | ||
| t('Choose the available content for querying with this schema:') | ||
| }} | ||
| </h2> | ||
|
|
||
| <div | ||
| v-for="group in permissions" | ||
| :key="group.handle" | ||
| class="user-permissions" | ||
| > | ||
| <PermissionList | ||
| :heading="group.heading" | ||
| :permissions="group.permissions" | ||
| :permission-keys="group.keys" | ||
| v-model="form.permissions" | ||
| :disabled="readOnly" | ||
| /> | ||
| </div> | ||
| </section> | ||
| </div> | ||
| </Pane> | ||
|
|
||
| <template v-if="schema.isPublic" #details> | ||
| <CraftSwitch | ||
| :label="t('Enabled')" | ||
| id="enabled" | ||
| name="enabled" | ||
| v-model="form.enabled" | ||
| :disabled="readOnly" | ||
| :error="form.errors.enabled" | ||
| /> | ||
|
|
||
| <CraftInput | ||
| :label="t('Expiry Date')" | ||
| id="expiryDate" | ||
| name="expiryDate" | ||
| type="datetime-local" | ||
| v-model="form.expiryDate" | ||
| :disabled="readOnly" | ||
| :error="form.errors.expiryDate" | ||
| /> | ||
| </template> | ||
| </AppLayout> | ||
| </template> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.