mirror of
https://github.com/directus/directus.git
synced 2026-01-24 23:58:02 -05:00
code tweaks
This commit is contained in:
@@ -115,7 +115,7 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
const { uploading, progress, error, upload, onBrowseSelect, done, numberOfFiles } = useUpload();
|
||||
const { uploading, progress, upload, onBrowseSelect, done, numberOfFiles } = useUpload();
|
||||
const { onDragEnter, onDragLeave, onDrop, dragging } = useDragging();
|
||||
const { url, isValidURL, loading: urlLoading, error: urlError, importFromURL } = useURLImport();
|
||||
const { setSelection } = useSelection();
|
||||
@@ -125,7 +125,6 @@ export default defineComponent({
|
||||
return {
|
||||
uploading,
|
||||
progress,
|
||||
error,
|
||||
onDragEnter,
|
||||
onDragLeave,
|
||||
onDrop,
|
||||
@@ -146,14 +145,12 @@ export default defineComponent({
|
||||
const progress = ref(0);
|
||||
const numberOfFiles = ref(0);
|
||||
const done = ref(0);
|
||||
const error = ref(null);
|
||||
|
||||
return { uploading, progress, error, upload, onBrowseSelect, numberOfFiles, done };
|
||||
return { uploading, progress, upload, onBrowseSelect, numberOfFiles, done };
|
||||
|
||||
async function upload(files: FileList) {
|
||||
uploading.value = true;
|
||||
progress.value = 0;
|
||||
error.value = null;
|
||||
|
||||
try {
|
||||
numberOfFiles.value = files.length;
|
||||
@@ -171,7 +168,6 @@ export default defineComponent({
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
error.value = err;
|
||||
} finally {
|
||||
uploading.value = false;
|
||||
done.value = 0;
|
||||
|
||||
@@ -136,12 +136,6 @@ export default defineComponent({
|
||||
error.value = null;
|
||||
} catch (err) {
|
||||
error.value = err;
|
||||
notify.add({
|
||||
title: i18n.t('unexpected_error'),
|
||||
type: 'error',
|
||||
dialog: true,
|
||||
error: err,
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -157,12 +151,6 @@ export default defineComponent({
|
||||
disableActive.value = false;
|
||||
} catch (err) {
|
||||
error.value = err;
|
||||
notify.add({
|
||||
title: i18n.t('unexpected_error'),
|
||||
type: 'error',
|
||||
dialog: true,
|
||||
error: err,
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ export default defineComponent({
|
||||
setup(props, { emit }) {
|
||||
const notify = useNotificationsStore();
|
||||
const activeDialog = ref<'upload' | 'choose' | 'url' | null>(null);
|
||||
const { loading, error, file, fetchFile } = useFile();
|
||||
const { loading, file, fetchFile } = useFile();
|
||||
|
||||
watch(() => props.value, fetchFile, { immediate: true });
|
||||
|
||||
@@ -158,20 +158,18 @@ export default defineComponent({
|
||||
return assetURL.value + `?key=system-small-cover`;
|
||||
});
|
||||
|
||||
const { url, isValidURL, loading: urlLoading, error: urlError, importFromURL } = useURLImport();
|
||||
const { url, isValidURL, loading: urlLoading, importFromURL } = useURLImport();
|
||||
|
||||
return {
|
||||
activeDialog,
|
||||
setSelection,
|
||||
loading,
|
||||
error,
|
||||
file,
|
||||
fileExtension,
|
||||
imageThumbnail,
|
||||
onUpload,
|
||||
url,
|
||||
urlLoading,
|
||||
urlError,
|
||||
importFromURL,
|
||||
isValidURL,
|
||||
assetURL,
|
||||
@@ -179,16 +177,14 @@ export default defineComponent({
|
||||
|
||||
function useFile() {
|
||||
const loading = ref(false);
|
||||
const error = ref(null);
|
||||
const file = ref<FileInfo | null>(null);
|
||||
|
||||
return { loading, error, file, fetchFile };
|
||||
return { loading, file, fetchFile };
|
||||
|
||||
async function fetchFile() {
|
||||
if (props.value === null) {
|
||||
file.value = null;
|
||||
loading.value = false;
|
||||
error.value = null;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -203,9 +199,9 @@ export default defineComponent({
|
||||
|
||||
file.value = response.data.data;
|
||||
} catch (err) {
|
||||
error.value = err;
|
||||
console.error(err);
|
||||
notify.add({
|
||||
title: i18n.t('unexpected_error'),
|
||||
title: i18n.t('could_not_load_file'),
|
||||
type: 'error',
|
||||
dialog: true,
|
||||
error: err,
|
||||
@@ -233,7 +229,6 @@ export default defineComponent({
|
||||
function useURLImport() {
|
||||
const url = ref('');
|
||||
const loading = ref(false);
|
||||
const error = ref(null);
|
||||
|
||||
const isValidURL = computed(() => {
|
||||
try {
|
||||
@@ -244,7 +239,7 @@ export default defineComponent({
|
||||
}
|
||||
});
|
||||
|
||||
return { url, loading, error, isValidURL, importFromURL };
|
||||
return { url, loading, isValidURL, importFromURL };
|
||||
|
||||
async function importFromURL() {
|
||||
loading.value = true;
|
||||
@@ -260,7 +255,13 @@ export default defineComponent({
|
||||
url.value = '';
|
||||
emit('input', file.value?.id);
|
||||
} catch (err) {
|
||||
error.value = err;
|
||||
console.error(err);
|
||||
notify.add({
|
||||
title: i18n.t('no_file_from_url'),
|
||||
type: 'error',
|
||||
dialog: true,
|
||||
error: err,
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,6 @@ export default defineComponent({
|
||||
const notify = useNotificationsStore();
|
||||
const loading = ref(false);
|
||||
const image = ref<Image | null>(null);
|
||||
const error = ref(null);
|
||||
const lightboxActive = ref(false);
|
||||
const editorActive = ref(false);
|
||||
|
||||
@@ -137,7 +136,6 @@ export default defineComponent({
|
||||
return {
|
||||
loading,
|
||||
image,
|
||||
error,
|
||||
src,
|
||||
meta,
|
||||
lightboxActive,
|
||||
@@ -160,7 +158,7 @@ export default defineComponent({
|
||||
|
||||
image.value = response.data.data;
|
||||
} catch (err) {
|
||||
error.value = err;
|
||||
console.error(err);
|
||||
notify.add({
|
||||
title: i18n.t('unexpected_error'),
|
||||
type: 'error',
|
||||
@@ -186,7 +184,6 @@ export default defineComponent({
|
||||
|
||||
loading.value = false;
|
||||
image.value = null;
|
||||
error.value = null;
|
||||
lightboxActive.value = false;
|
||||
editorActive.value = false;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,6 @@ export default defineComponent({
|
||||
function useCurrent() {
|
||||
const currentItem = ref<Record<string, any> | null>(null);
|
||||
const loading = ref(false);
|
||||
const error = ref(null);
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
@@ -264,7 +263,7 @@ export default defineComponent({
|
||||
|
||||
currentItem.value = response.data.data;
|
||||
} catch (err) {
|
||||
error.value = err;
|
||||
console.error(err);
|
||||
notify.add({
|
||||
title: i18n.t('unexpected_error'),
|
||||
type: 'error',
|
||||
@@ -316,7 +315,7 @@ export default defineComponent({
|
||||
|
||||
items.value = response.data.data;
|
||||
} catch (err) {
|
||||
error.value = err;
|
||||
console.error(err);
|
||||
notify.add({
|
||||
title: i18n.t('unexpected_error'),
|
||||
type: 'error',
|
||||
|
||||
@@ -115,7 +115,7 @@ export default defineComponent({
|
||||
const notify = useNotificationsStore();
|
||||
|
||||
const { relation, relatedCollection, relatedPrimaryKeyField } = useRelation();
|
||||
const { tableHeaders, items, loading, error } = useTable();
|
||||
const { tableHeaders, items, loading } = useTable();
|
||||
const { currentlyEditing, editItem, editsAtStart, stageEdits, cancelEdit } = useEdits();
|
||||
const { stageSelection, selectModalActive, selectionFilters } = useSelection();
|
||||
const { sort, sortItems, sortedItems } = useSort();
|
||||
@@ -263,7 +263,6 @@ export default defineComponent({
|
||||
const tableHeaders = ref<Header[]>([]);
|
||||
const loading = ref(false);
|
||||
const items = ref<Record<string, any>[]>([]);
|
||||
const error = ref(null);
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
@@ -311,7 +310,6 @@ export default defineComponent({
|
||||
})
|
||||
.concat(...newItems);
|
||||
} catch (err) {
|
||||
error.value = err;
|
||||
notify.add({
|
||||
title: i18n.t('unexpected_error'),
|
||||
type: 'error',
|
||||
@@ -359,7 +357,7 @@ export default defineComponent({
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
return { tableHeaders, items, loading, error };
|
||||
return { tableHeaders, items, loading };
|
||||
}
|
||||
|
||||
function useEdits() {
|
||||
|
||||
@@ -50,12 +50,6 @@ Node: ${parsedInfo.value?.node.version}
|
||||
|
||||
Name: ${notify.error?.name || notify.error || 'none'}
|
||||
Message: ${notify.error?.message || 'none'}
|
||||
Action: ${notify.text || 'none'}
|
||||
<details>
|
||||
<summary>Error Stack</summary>
|
||||
|
||||
${notify.error?.stack?.replace(/^/gm, ' ').replace(' ', '')}
|
||||
</details>
|
||||
`;
|
||||
|
||||
return `https://github.com/directus/next/issues/new?body=${encodeURIComponent(debugInfo)}`;
|
||||
|
||||
Reference in New Issue
Block a user