-
Notifications
You must be signed in to change notification settings - Fork 1
feat: update to statamic 6 #75
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
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
614aa09
wip
NeoIsRecursive 12705b7
wip
NeoIsRecursive e9c5168
fix formatting
NeoIsRecursive ba899d5
wip
NeoIsRecursive 800fa7c
wip
NeoIsRecursive fbb1c90
wip
NeoIsRecursive c7ee4d7
wip
NeoIsRecursive e582aac
wip
NeoIsRecursive 6f5eeb5
Merge remote-tracking branch 'origin/main' into statamic-6
NeoIsRecursive 97570bf
Update mago to beta.2
NeoIsRecursive afb6398
chore: use queueable trait instead of splitup
NeoIsRecursive d8ca40a
wip bump alpha
NeoIsRecursive 78a4c73
chore: update mago
NeoIsRecursive 0d8fe7e
fix: php actor issues
NeoIsRecursive d77e8c6
wip
NeoIsRecursive bbe233b
Fix test issues
NeoIsRecursive ff81a66
Make mago happy
NeoIsRecursive a3a0d3f
bump min php version to 8.3
NeoIsRecursive db2d554
wip
NeoIsRecursive a032436
update mago and migrate to yaml file and apply fixes
NeoIsRecursive 3b34e50
wip
NeoIsRecursive c3d2ff4
wip update mago and pest
NeoIsRecursive 0dcfdab
wip
NeoIsRecursive 098e6c3
wip beta support
NeoIsRecursive 6b9f16d
Update to statamic 6
NeoIsRecursive 1d5ccc2
Update php version to 8.5
NeoIsRecursive c62aa3f
chore: update deps and improve static analysis a bit
NeoIsRecursive 8862cc2
fix
NeoIsRecursive de2a32d
fix: icon
NeoIsRecursive b09d1a9
fix: stop polling
NeoIsRecursive f87ef2e
fix: handle chunk assembling better
NeoIsRecursive 6ea8289
fix: typings
NeoIsRecursive cdd5806
fix: build error
NeoIsRecursive 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 was deleted.
Oops, something went wrong.
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,55 +1,162 @@ | ||
| <template> | ||
| <div> | ||
| <div class="flex"> | ||
| <div class="flex flex-col mb-4"> | ||
| <h1>{{ __("statamic-backup::backup.title") }}</h1> | ||
| <p v-if="status !== 'idle'" class="text-sm text-gray-700 whitespace-nowrap"> | ||
| {{ __(`statamic-backup::backup.state.${status}`) }} | ||
| </p> | ||
| </div> | ||
| <backup-actions @openBrowser="openBrowser" /> | ||
| </div> | ||
|
|
||
| <backup-listing /> | ||
| </div> | ||
| </template> | ||
| <script setup> | ||
| import { Listing, DropdownItem, Header, Button } from "@statamic/cms/ui"; | ||
| import { Head } from "@statamic/cms/inertia"; | ||
| import { requireElevatedSession } from "@statamic/cms"; | ||
| import { useBackupStore } from "../store"; | ||
| import { onUnmounted, ref, watch } from "vue"; | ||
| import { useResumable } from "../resumable"; | ||
|
|
||
| <script> | ||
| import Listing from "./Listing.vue"; | ||
| import Actions from "./Actions.vue"; | ||
| import { store } from "../store"; | ||
| const backupStore = useBackupStore(); | ||
|
|
||
| export default { | ||
| components: { | ||
| "backup-listing": Listing, | ||
| "backup-actions": Actions, | ||
| }, | ||
| props: { | ||
| chunkSize: { | ||
| type: Number, | ||
| default: 2 * 1024 * 1024, // 2MB | ||
| }, | ||
| const listing = ref(null); | ||
|
|
||
| const dropZone = ref(null); | ||
| const browseTarget = ref(null); | ||
|
|
||
| const { files } = useResumable({ | ||
| chunkSize: Statamic.$config.get('statamic_backup.chunk_size', 2 * 1024 * 1024), | ||
| dropZone, | ||
| browseTarget, | ||
| onFileUploaded: (file) => { | ||
| listing.value.refresh(); | ||
| }, | ||
| created() { | ||
| // console.log(this.chunkSize) | ||
| }); | ||
|
|
||
| backupStore.startPolling(); | ||
|
|
||
| window.backup = { | ||
| chunkSize: this.chunkSize | ||
| }; | ||
| onUnmounted(() => { | ||
| backupStore.stopPolling(); | ||
| }) | ||
|
|
||
| if (!this.$store.hasModule('backup-provider')) { | ||
| this.$store.registerModule('backup-provider', store); | ||
| this.$store.dispatch('backup-provider/pollEndpoint'); | ||
| watch( | ||
| () => backupStore.status, | ||
| (newStatus, oldStatus) => { | ||
| if (oldStatus === "initializing") return; | ||
| if (newStatus !== oldStatus) { | ||
| listing.value.refresh(); | ||
| } | ||
| }, | ||
| computed: { | ||
| status() { | ||
| return this.$store.state['backup-provider'].status; | ||
| }, | ||
| }, | ||
| destroy() { | ||
| this.$store.dispatch('backup-provider/stopPolling'); | ||
| this.$store.unregisterModule('backup-provider'); | ||
| }, | ||
| } | ||
| ); | ||
|
|
||
| const withErrHandling = (fn) => async (params) => { | ||
| return fn(params).catch((err) => { | ||
| console.error(err); | ||
|
|
||
| if (err.response) { | ||
| Statamic.$toast.error(err.response.data.message); | ||
| } else { | ||
| Statamic.$toast.error(err.message); | ||
| } | ||
| }); | ||
| }; | ||
|
|
||
| const queueRestore = withErrHandling(async (id) => { | ||
| await requireElevatedSession(); | ||
|
|
||
| const { data } = | ||
| await window.Statamic.$app.config.globalProperties.$axios.post( | ||
| cp_url(`api/backups/restore/${id}`) | ||
| ); | ||
|
|
||
| Statamic.$toast.info(__(data.message)); | ||
| }); | ||
|
|
||
| const queueBackup = withErrHandling(async () => { | ||
| backupStore.setStatus("backup_in_progress"); | ||
|
|
||
| const { data } = | ||
| await window.Statamic.$app.config.globalProperties.$axios.post( | ||
| cp_url("api/backups") | ||
| ); | ||
|
|
||
| Statamic.$toast.info(__(data.message)); | ||
| listing.value.refresh(); | ||
| }); | ||
|
|
||
| const deleteBackup = withErrHandling(async (id) => { | ||
| await requireElevatedSession(); | ||
|
|
||
| const { data } = | ||
| await window.Statamic.$app.config.globalProperties.$axios.delete( | ||
| cp_url(`api/backups/${id}`) | ||
| ); | ||
|
|
||
| Statamic.$toast.info(__(data.message)); | ||
| listing.value.refresh(); | ||
| }); | ||
| </script> | ||
|
|
||
| <template> | ||
| <Head title="Backups" /> | ||
| <Header icon="database" :title="__('statamic-backup::backup.title')"> | ||
| <Button variant="subtle" ref="browseTarget">{{ | ||
| __("statamic-backup::backup.upload.label") | ||
| }}</Button> | ||
| <Button | ||
| variant="primary" | ||
| v-on:click="queueBackup" | ||
| :disabled="!backupStore.abilities.backup.isPossible" | ||
| :loading="backupStore.status === 'backup_in_progress'" | ||
| > | ||
| {{ __("statamic-backup::backup.create") }} | ||
| </Button> | ||
| </Header> | ||
|
|
||
| <p v-for="file in files" :key="file.file.uniqueIdentifier" class="mb-2"> | ||
| <span>{{ file.file.fileName }}</span> | ||
| <span v-if="file.status === 'uploading'"> | ||
| - {{ Math.round(file.progress * 100) }}%</span | ||
| > | ||
| <span v-if="file.status === 'retrying'"> | ||
| - {{ __("statamic-backup::backup.upload.retrying") }}</span | ||
| > | ||
| <span v-if="file.status === 'error'" class="text-red-600"> | ||
| - {{ __("statamic-backup::backup.upload.error") }}</span | ||
| > | ||
| </p> | ||
|
|
||
| <Listing | ||
| ref="listing" | ||
| :allowSearch="false" | ||
| :allowCustomizingColumns="false" | ||
| :url="cp_url('api/backups')" | ||
| :columns="[ | ||
| { | ||
| field: 'name', | ||
| label: __('statamic-backup::backup.name'), | ||
| visible: true, | ||
| }, | ||
| { | ||
| field: 'created_at', | ||
| label: __('statamic-backup::backup.created_at'), | ||
| visible: true, | ||
| }, | ||
| { | ||
| field: 'size', | ||
| label: __('statamic-backup::backup.size'), | ||
| visible: true, | ||
| }, | ||
| ]" | ||
| > | ||
| <template #prepended-row-actions="{ row }"> | ||
| <DropdownItem | ||
| v-if="backupStore.abilities.download.isPermitted" | ||
| :text="__('statamic-backup::backup.download.label')" | ||
| target="_blank" | ||
| :href="`${cp_url('api/backups/download')}/${row.id}`" | ||
| /> | ||
| <DropdownItem | ||
| v-if="backupStore.abilities.restore.isPermitted" | ||
| :disabled="!backupStore.abilities.restore.isPossible" | ||
| v-on:click="queueRestore(row.id)" | ||
| :text="__('statamic-backup::backup.restore.label')" | ||
| /> | ||
| <DropdownItem | ||
| v-if="backupStore.abilities.destroy.isPermitted" | ||
| variant="destructive" | ||
| v-on:click="deleteBackup(row.id)" | ||
| :text="__('statamic-backup::backup.destroy.label')" | ||
| /> | ||
| </template> | ||
| </Listing> | ||
| </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.