-
Notifications
You must be signed in to change notification settings - Fork 10
[WIP] MINOR: Naming templates #691
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |||||||||||||||
| :initialSearchText="searchText" | ||||||||||||||||
| @update:searchText="searchText = $event" | ||||||||||||||||
| @upload-files="uploadFiles" | ||||||||||||||||
| @manage-naming-conflicts="openNamingConflictsModal" | ||||||||||||||||
| /> | ||||||||||||||||
| <div class="files-manager__content"> | ||||||||||||||||
| <transition name="slide-fade-left"> | ||||||||||||||||
|
|
@@ -88,6 +89,7 @@ | |||||||||||||||
| @file-clicked="onFileSelected" | ||||||||||||||||
| @file-uploaded="$emit('file-uploaded')" | ||||||||||||||||
| @manage-access="openAccessManager" | ||||||||||||||||
| @manage-naming-rule="openFolderNamingConstraintManager" | ||||||||||||||||
| @open-tag-manager="openTagManager" | ||||||||||||||||
| @open-versioning-manager="openVersioningManager" | ||||||||||||||||
| @open-visa-manager="openVisaManager" | ||||||||||||||||
|
|
@@ -111,6 +113,7 @@ | |||||||||||||||
| @file-clicked="onFileSelected" | ||||||||||||||||
| @go-folders-view="goFoldersView" | ||||||||||||||||
| @manage-access="openAccessManager" | ||||||||||||||||
| @manage-naming-rule="openFolderNamingConstraintManager" | ||||||||||||||||
| @open-tag-manager="openTagManager" | ||||||||||||||||
| @open-versioning-manager="openVersioningManager" | ||||||||||||||||
| @open-visa-manager="openVisaManager" | ||||||||||||||||
|
|
@@ -205,12 +208,14 @@ import FileService from "../../../../services/FileService.js"; | |||||||||||||||
| import TagService from "../../../../services/TagService"; | ||||||||||||||||
| import { useFiles } from "../../../../state/files.js"; | ||||||||||||||||
| import { useModels } from "../../../../state/models.js"; | ||||||||||||||||
| import { useNamingConstraints } from "../../../../state/naming-constraints.js"; | ||||||||||||||||
| import { useProjects } from "../../../../state/projects.js"; | ||||||||||||||||
| import { useSpaces } from "../../../../state/spaces.js"; | ||||||||||||||||
| import { useVisa } from "../../../../state/visa.js"; | ||||||||||||||||
| import { collectDescendants } from "../../../../utils/file-tree.js"; | ||||||||||||||||
| import { isFolder } from "../../../../utils/file-structure.js"; | ||||||||||||||||
| import { getFilesFromEvent } from "../../../../utils/files.js"; | ||||||||||||||||
| import { matchName } from "../../../../utils/naming-constraint.js"; | ||||||||||||||||
| import { isFullTotal } from "../../../../utils/spaces.js"; | ||||||||||||||||
| import { fileUploadInput } from "../../../../utils/upload.js"; | ||||||||||||||||
|
|
||||||||||||||||
|
|
@@ -225,6 +230,8 @@ import FilesManagerOnboarding from "./files-manager-onboarding/FilesManagerOnboa | |||||||||||||||
| import FileTree from "../file-tree/FileTree.vue"; | ||||||||||||||||
| import FileTreePreviewModal from "../file-tree-preview-modal/FileTreePreviewModal.vue"; | ||||||||||||||||
| import FolderAccessManager from "../folder-access-manager/FolderAccessManager.vue"; | ||||||||||||||||
| import FolderNamingConstraintManager from "../naming-constraint/FolderNamingConstraintManager.vue"; | ||||||||||||||||
| import NamingConflictModal from "../naming-constraint/NamingConflictModal.vue"; | ||||||||||||||||
| import FoldersTable from "../folder-table/FoldersTable.vue"; | ||||||||||||||||
| import SubscriptionModal from "../../subscriptions/subscription-modal/SubscriptionModal.vue"; | ||||||||||||||||
| import TagsMain from "../../tags/tags-main/TagsMain.vue"; | ||||||||||||||||
|
|
@@ -280,7 +287,8 @@ export default { | |||||||||||||||
| const { createModel, createPhotosphere, deleteModels } = useModels(); | ||||||||||||||||
|
|
||||||||||||||||
| const { fetchToValidateVisas, fetchCreatedVisas } = useVisa(); | ||||||||||||||||
|
|
||||||||||||||||
| const { getEffectiveFolderRule } = | ||||||||||||||||
| useNamingConstraints(); | ||||||||||||||||
| const currentFolder = ref(null); | ||||||||||||||||
| const currentFiles = ref([]); | ||||||||||||||||
| const toValidateVisas = ref([]); | ||||||||||||||||
|
|
@@ -337,20 +345,57 @@ export default { | |||||||||||||||
|
|
||||||||||||||||
| const filesToUpload = ref([]); | ||||||||||||||||
| const foldersToUpload = ref([]); | ||||||||||||||||
| const uploadFiles = async (event, folder = currentFolder.value) => { | ||||||||||||||||
| const { files, folders } = await getFilesFromEvent(event); | ||||||||||||||||
| const proceedUpload = async (files, folder) => { | ||||||||||||||||
| files.forEach((file) => (file.folder = folder)); | ||||||||||||||||
|
|
||||||||||||||||
| filesToUpload.value = files; | ||||||||||||||||
| foldersToUpload.value = await Promise.all( | ||||||||||||||||
| folders.map((f) => FileService.createFolderStructure(props.project, folder, f)), | ||||||||||||||||
| ); | ||||||||||||||||
|
|
||||||||||||||||
| setTimeout(() => { | ||||||||||||||||
| filesToUpload.value = []; | ||||||||||||||||
| foldersToUpload.value = []; | ||||||||||||||||
| }, 10); | ||||||||||||||||
| }; | ||||||||||||||||
| let folders = []; | ||||||||||||||||
| const uploadFiles = async (event, folder = currentFolder.value) => { | ||||||||||||||||
| const fromEvent = await getFilesFromEvent(event); | ||||||||||||||||
| const files = fromEvent.files; | ||||||||||||||||
| folders = fromEvent.folders; | ||||||||||||||||
|
Comment on lines
+359
to
+363
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
|
|
||||||||||||||||
| const rule = await getEffectiveFolderRule(props.project, folder); | ||||||||||||||||
| const invalidFiles = rule?.rule | ||||||||||||||||
| ? files.filter((file) => !matchName(file.name, rule.rule)) | ||||||||||||||||
| : []; | ||||||||||||||||
|
|
||||||||||||||||
| if (invalidFiles.length > 0) { | ||||||||||||||||
| openModal({ | ||||||||||||||||
| component: NamingConflictModal, | ||||||||||||||||
| props: { | ||||||||||||||||
| project: props.project, | ||||||||||||||||
| documents: invalidFiles.map((file, i) => ({ id: `upload-${i}`, name: file.name })), | ||||||||||||||||
| rule, | ||||||||||||||||
| persistChanges: false, | ||||||||||||||||
| onClose: closeModal, | ||||||||||||||||
| onConfirm: ({ renamed, deleted }) => { | ||||||||||||||||
| const deletedIds = new Set(deleted.map((d) => d.id)); | ||||||||||||||||
| const renamedById = new Map(renamed.map((r) => [r.id, r.name])); | ||||||||||||||||
| const finalFiles = invalidFiles | ||||||||||||||||
| .map((file, i) => ({ file, id: `upload-${i}` })) | ||||||||||||||||
| .filter(({ id }) => !deletedIds.has(id)) | ||||||||||||||||
| .map(({ file, id }) => { | ||||||||||||||||
| const name = renamedById.get(id); | ||||||||||||||||
| return name ? new File([file], name, { type: file.type }) : file; | ||||||||||||||||
| }); | ||||||||||||||||
| const validFiles = files.filter((file) => matchName(file.name, rule.rule)); | ||||||||||||||||
| proceedUpload([...validFiles, ...finalFiles], folder); | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
| }, | ||||||||||||||||
| }, | ||||||||||||||||
| }); | ||||||||||||||||
| return; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| proceedUpload(files, folder); | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| const loadingFileIds = ref([]); | ||||||||||||||||
| const isCreatingModels = ref(false); | ||||||||||||||||
|
|
@@ -544,6 +589,50 @@ export default { | |||||||||||||||
| }, 100); | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| const openFolderNamingConstraintManager = (folder) => { | ||||||||||||||||
| openSidePanel("right", { | ||||||||||||||||
| component: FolderNamingConstraintManager, | ||||||||||||||||
| props: { | ||||||||||||||||
| project: props.project, | ||||||||||||||||
| folder, | ||||||||||||||||
| }, | ||||||||||||||||
| }); | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| const openNamingConflictsModal = async () => { | ||||||||||||||||
| const conflicting = allFiles.value.filter( | ||||||||||||||||
| (file) => file.naming_constraint_conflict, | ||||||||||||||||
| ); | ||||||||||||||||
| if (conflicting.length === 0) { | ||||||||||||||||
| pushNotification({ | ||||||||||||||||
| type: "success", | ||||||||||||||||
| title: t("NamingConstraint.noConflictsTitle"), | ||||||||||||||||
| message: t("NamingConstraint.noConflictsMessage"), | ||||||||||||||||
| }); | ||||||||||||||||
| return; | ||||||||||||||||
| } | ||||||||||||||||
| const documents = await Promise.all( | ||||||||||||||||
| conflicting.map(async (file) => { | ||||||||||||||||
| const folder = allFolders.value.find((f) => f.id === file.parent_id); | ||||||||||||||||
| const effective = folder | ||||||||||||||||
| ? await getEffectiveFolderRule(props.project, folder) | ||||||||||||||||
| : null; | ||||||||||||||||
| return { ...file, namingRule: effective?.rule ?? null }; | ||||||||||||||||
| }), | ||||||||||||||||
| ); | ||||||||||||||||
| openModal({ | ||||||||||||||||
| component: NamingConflictModal, | ||||||||||||||||
| props: { | ||||||||||||||||
| project: props.project, | ||||||||||||||||
| documents, | ||||||||||||||||
| allFolders: allFolders.value, | ||||||||||||||||
| rule: null, | ||||||||||||||||
| onClose: closeModal, | ||||||||||||||||
| onConfirm: () => emit("file-updated"), | ||||||||||||||||
| }, | ||||||||||||||||
| }); | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| const visasLoading = ref(false); | ||||||||||||||||
| const openVisaManager = (file) => { | ||||||||||||||||
| onTabChange(filesTabs[2]); | ||||||||||||||||
|
|
@@ -833,6 +922,8 @@ export default { | |||||||||||||||
| moveFiles, | ||||||||||||||||
| onFileSelected, | ||||||||||||||||
| openAccessManager, | ||||||||||||||||
| openFolderNamingConstraintManager, | ||||||||||||||||
| openNamingConflictsModal, | ||||||||||||||||
| openFileDeleteModal, | ||||||||||||||||
| openVisaDeleteModal, | ||||||||||||||||
| openSidePanel, | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.