Add 404 for non-existing files, prevent /+

This commit is contained in:
rijkvanzanten
2020-07-30 10:10:54 -04:00
parent ccc81b4bac
commit d1f3f02743
3 changed files with 39 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
<template>
<private-view :title="loading || !item ? $t('loading') : item.title">
<files-not-found v-if="!loading && !item" />
<private-view v-else :title="loading || !item ? $t('loading') : item.title">
<template #title-outer:prepend>
<v-button class="header-icon" rounded icon secondary exact :to="breadcrumb[0].to">
<v-icon name="arrow_back" />
@@ -68,7 +69,6 @@
<save-options
:disabled="hasEdits === false"
@save-and-stay="saveAndStay"
@save-and-add-new="saveAndAddNew"
@save-as-copy="saveAsCopyAndNavigate"
/>
</template>
@@ -163,6 +163,7 @@ import useFormFields from '@/composables/use-form-fields';
import FolderPicker from '../../components/folder-picker';
import api from '@/api';
import getRootPath from '@/utils/get-root-path';
import FilesNotFound from '../not-found/';
type Values = {
[field: string]: any;
@@ -192,6 +193,7 @@ export default defineComponent({
FileLightbox,
FileInfoDrawerDetail,
FolderPicker,
FilesNotFound,
},
props: {
primaryKey: {
@@ -271,7 +273,6 @@ export default defineComponent({
confirmDelete,
deleting,
saveAndStay,
saveAndAddNew,
saveAsCopyAndNavigate,
isBatch,
changeCacheBuster,
@@ -313,19 +314,7 @@ export default defineComponent({
async function saveAndStay() {
const savedItem: Record<string, any> = await save();
revisionsDrawerDetail.value?.$data?.refresh?.();
if (props.primaryKey === '+') {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const newPrimaryKey = savedItem.id;
router.replace(`/collections/files/${newPrimaryKey}`);
}
}
async function saveAndAddNew() {
await save();
router.push(`/files/+`);
}
async function saveAsCopyAndNavigate() {

View File

@@ -0,0 +1,4 @@
import NotFound from './not-found.vue';
export { NotFound };
export default NotFound;

View File

@@ -0,0 +1,31 @@
<template>
<private-view :title="$t('page_not_found')">
<template #navigation>
<files-navigation />
</template>
<div class="not-found">
<v-info :title="$t('page_not_found')" icon="not_interested">
{{ $t('page_not_found_body') }}
</v-info>
</div>
</private-view>
</template>
<script lang="ts">
import { defineComponent } from '@vue/composition-api';
import FilesNavigation from '../../components/navigation/';
export default defineComponent({
components: { FilesNavigation },
});
</script>
<style lang="scss" scoped>
.not-found {
display: flex;
align-items: center;
justify-content: center;
padding: 20vh 0;
}
</style>