-
Notifications
You must be signed in to change notification settings - Fork 703
[6.x] Inertia filesystems #18932
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
Merged
[6.x] Inertia filesystems #18932
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
91ccbcb
[WIP] convert filesystem to Inertia
brianjhanson b989d9d
Create and saving filesystems
brianjhanson c4a4251
Fix public URL settings
brianjhanson 8b55501
Fix data saving issue
brianjhanson a602534
Merge branch '6.x' of github.com:craftcms/cms into feature/inertia-fi…
brianjhanson d525685
Fix S3 settings rendering
brianjhanson 00c550c
Ugly but working
brianjhanson cbf1bdc
Merge branch '6.x' into feature/inertia-filesystems
brianjhanson 5b81ba6
Support phpstan-type aliases in typescript generation
brianjhanson 54aab0f
Cleanup typescript types
brianjhanson 7ded283
Remove debug
brianjhanson 0b21da3
Fix tests
brianjhanson 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
73 changes: 73 additions & 0 deletions
73
resources/js/components/Filesystems/FilesystemSettings.vue
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,73 @@ | ||
| <script setup lang="ts"> | ||
| import {t} from '@craftcms/cp'; | ||
| import {computed} from 'vue'; | ||
| import {usePage} from '@inertiajs/vue3'; | ||
| import type {Filesystem} from '@/pages/SettingsFilesystemsEditPage.vue'; | ||
| import VarDump from '@/components/VarDump.vue'; | ||
| import CraftSwitch from '@craftcms/cp/vue/CraftSwitch.vue'; | ||
| import CraftCombobox from '@/components/form/CraftCombobox.vue'; | ||
| import DynamicHtmlRenderer from '@/components/DynamicHtmlRenderer.vue'; | ||
|
|
||
| const hasUrls = defineModel<boolean>('hasUrls'); | ||
| const url = defineModel<string>('url'); | ||
| withDefaults( | ||
| defineProps<{ | ||
| filesystem?: Filesystem; | ||
| }>(), | ||
| { | ||
| filesystem: { | ||
| errors: () => [], | ||
| name: null, | ||
| handle: null, | ||
| oldHandle: null, | ||
| hasUrls: false, | ||
| url: null, | ||
| uid: null, | ||
| rootUrl: null, | ||
| id: null, | ||
| dateCreated: null, | ||
| dateUpdated: null, | ||
| settingsHtml: null, | ||
| rootPath: null, | ||
| path: null, | ||
| }, | ||
| } | ||
| ); | ||
|
|
||
| const page = usePage<{ | ||
| readOnly: boolean; | ||
| baseUrlSuggestions?: Array<any>; | ||
| }>(); | ||
| </script> | ||
|
|
||
| <template> | ||
| <div v-if="filesystem" :id="filesystem.type"> | ||
| <template v-if="filesystem.showHasUrlSetting"> | ||
| <CraftSwitch | ||
| :label="t('Files in this filesystem have public URLs')" | ||
| name="hasUrls" | ||
| id="has-urls" | ||
| v-model="hasUrls" | ||
| :disabled="page.props.readOnly" | ||
| /> | ||
|
|
||
| <template v-if="hasUrls && filesystem.showUrlSetting"> | ||
| <CraftCombobox | ||
| :label="t('Base URL')" | ||
| :help-text="t('The base URL to the files in this filesystem.')" | ||
| v-model="url" | ||
| :options="page.props.baseUrlSuggestions" | ||
| name="url" | ||
| :required="true" | ||
| placeholder="//example.com/path/to/folder" | ||
| data-error-key="url" | ||
| :disabled="page.props.readOnly" | ||
| ></CraftCombobox> | ||
| </template> | ||
| </template> | ||
| <DynamicHtmlRenderer :html="filesystem.settingsHtml"/> | ||
| <!--<div v-html="filesystem.settingsHtml" />--> | ||
| </div> | ||
| </template> | ||
|
|
||
| <style scoped lang="scss"></style> | ||
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,18 @@ | ||
| <script setup lang="ts"> | ||
| import {computed} from 'vue'; | ||
| import VarDump from '@/components/VarDump.vue'; | ||
|
|
||
| const props = defineProps<{ | ||
| filesystem?: string; | ||
| }>(); | ||
|
|
||
| const fs = computed(() => props.filesystem ? JSON.parse(props.filesystem) : null); | ||
| </script> | ||
|
|
||
| <template> | ||
| <h2>Roundabout LocalFsSettings</h2> | ||
|
|
||
| <VarDump :data="{props}" /> | ||
| </template> | ||
|
|
||
| <style scoped lang="scss"></style> |
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,130 @@ | ||
| <script setup lang="ts"> | ||
|
riasvdv marked this conversation as resolved.
Outdated
|
||
| import {t, toHandle} from '@craftcms/cp'; | ||
| import AppLayout from '@/layout/AppLayout.vue'; | ||
| import VarDump from '@/components/VarDump.vue'; | ||
| import type {SelectItem, SelectOption} from '@/types'; | ||
| import Pane from '@/components/Pane.vue'; | ||
| import CraftInput from '@craftcms/cp/vue/CraftInput.vue'; | ||
| import CraftInputHandle from '@craftcms/cp/vue/CraftInputHandle.vue'; | ||
| import Select from '@/components/form/Select.vue'; | ||
| import {useForm} from '@inertiajs/vue3'; | ||
| import {useInputGenerator} from '@/composables/useInputGenerator'; | ||
| import DynamicHtmlRenderer from '@/components/DynamicHtmlRenderer.vue'; | ||
| import FilesystemSettings from '@/components/Filesystems/FilesystemSettings.vue'; | ||
|
|
||
| export type Filesystem = { | ||
| errors: any[]; | ||
| name: string | null; | ||
| handle: string | null; | ||
| oldHandle: any; | ||
| hasUrls: boolean; | ||
| url: any; | ||
| uid: any; | ||
| rootUrl: any; | ||
| id: any; | ||
| dateCreated: any; | ||
| dateUpdated: any; | ||
| settingsHtml: string; | ||
| rootPath: string; | ||
| path: any; | ||
| type: string; | ||
| showHasUrlSetting: boolean; | ||
| showUrlSetting: boolean; | ||
| }; | ||
|
|
||
| const props = defineProps<{ | ||
| oldHandle: string | null; | ||
| filesystem: Filesystem; | ||
| fsOptions: Array<SelectOption>; | ||
| fsInstances: Record<string, Filesystem>; | ||
| fsTypes: Array<string>; | ||
| readOnly: boolean; | ||
| }>(); | ||
|
|
||
| const form = useForm({ | ||
| name: props.filesystem.name ?? '', | ||
| handle: props.filesystem.handle ?? '', | ||
| type: props.filesystem.type ?? '', | ||
| hasUrls: props.filesystem.hasUrls ?? false, | ||
| url: props.filesystem.url ?? '', | ||
| }); | ||
|
|
||
| useInputGenerator( | ||
| () => form.name, | ||
| (v) => (form.handle = toHandle(v)) | ||
| ); | ||
|
|
||
| function handleSubmit() { | ||
| const form = event.target as HTMLFormElement; | ||
|
|
||
| form.transform(() => { | ||
| return { | ||
| ...(new FormData(form)), | ||
| ...form | ||
| } | ||
| }).submit(); | ||
| } | ||
|
|
||
| function getFs(fsType: string): Filesystem | null { | ||
| if (fsType === form.type) { | ||
| return props.filesystem; | ||
| } | ||
|
|
||
| return props.fsInstances[fsType] ?? null; | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <AppLayout> | ||
| <Pane appearance="raised"> | ||
| <div class="grid gap-3"> | ||
|
riasvdv marked this conversation as resolved.
Outdated
|
||
| <CraftInput | ||
| v-model="form.name" | ||
| :label="t('Name')" | ||
| id="name" | ||
| name="name" | ||
| :autofocus="true" | ||
| :required="true" | ||
| :error="form.errors?.name" | ||
| data-error-key="name" | ||
| :disabled="readOnly" | ||
| /> | ||
|
|
||
| <CraftInputHandle | ||
| :label="t('Handle')" | ||
| id="handle" | ||
| name="handle" | ||
| v-model="form.handle" | ||
| :required="true" | ||
| :error="form.errors?.handle" | ||
| data-error-key="handle" | ||
| :disabled="readOnly" | ||
| /> | ||
|
|
||
| <hr /> | ||
|
|
||
| <template v-if="fsOptions.length"> | ||
| <Select | ||
| id="type" | ||
| name="type" | ||
| :label="t('Filesystem Type')" | ||
| :help-text="t('What type of filesystem is this?')" | ||
| :options="fsOptions" | ||
| v-model="form.type" | ||
| :disabled="readOnly" | ||
| /> | ||
| </template> | ||
|
|
||
| <template v-for="fsType in fsTypes"> | ||
| <FilesystemSettings | ||
| v-model:has-urls="form.hasUrls" | ||
| v-model:url="form.url" | ||
| :filesystem="fsInstances[fsType]" | ||
| /> | ||
| </template> | ||
| </div> | ||
| </Pane> | ||
| </AppLayout> | ||
| </template> | ||
|
|
||
| <style scoped lang="scss"></style> | ||
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 |
|---|---|---|
| @@ -1,17 +1,23 @@ | ||
| {% from "_includes/forms" import autosuggestField %} | ||
|
|
||
| <craft-input | ||
| label="{{ "Base Path"|t('app') }}" | ||
| :help-text="{{ "The base folder path that should be used as the root of the filesystem."|t('app') }}" | ||
| name="path" | ||
| ></craft-input> | ||
|
|
||
| {{ autosuggestField({ | ||
| label: "Base Path"|t('app'), | ||
| instructions: "The base folder path that should be used as the root of the filesystem."|t('app'), | ||
| id: 'path', | ||
| class: 'ltr', | ||
| name: 'path', | ||
| suggestEnvVars: true, | ||
| suggestAliases: true, | ||
| value: filesystem.path, | ||
| required: true, | ||
| placeholder: "/path/to/folder"|t('app'), | ||
| errors: filesystem.errors.get('path'), | ||
| data: {'error-key': 'path'}, | ||
| disabled: readOnly, | ||
| label: "Base Path"|t('app'), | ||
| instructions: "The base folder path that should be used as the root of the filesystem."|t('app'), | ||
| id: 'path', | ||
| class: 'ltr', | ||
| name: 'path', | ||
| suggestEnvVars: true, | ||
| suggestAliases: true, | ||
| value: filesystem.path, | ||
| required: true, | ||
| placeholder: "/path/to/folder"|t('app'), | ||
| errors: filesystem.errors.get('path'), | ||
| data: {'error-key': 'path'}, | ||
| disabled: readOnly, | ||
| }) }} |
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
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.