Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 19 additions & 89 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@bimdata/bcf-components": "6.7.7",
"@bimdata/components": "1.10.1",
"@bimdata/design-system": "2.4.2",
"@bimdata/typescript-fetch-api-client": "10.41.0",
"@bimdata/typescript-fetch-api-client": "10.44.1",
"@bimdata/viewer": "2.17.1-alpha.fragments.3",
"@paddle/paddle-js": "^1.6.4",
"async": "^3.2.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
@download="$emit('download', file)"
@file-clicked="$emit('file-clicked', file)"
@manage-access="$emit('manage-access', file)"
@manage-naming-rule="$emit('manage-naming-rule', file)"
@open-tag-manager="$emit('open-tag-manager', file)"
@open-versioning-manager="$emit('open-versioning-manager', file)"
@open-visa-manager="$emit('open-visa-manager', file)"
Expand Down Expand Up @@ -288,6 +289,7 @@ export default {
"file-clicked",
"go-folders-view",
"manage-access",
"manage-naming-rule",
"open-tag-manager",
"open-versioning-manager",
"open-visa-manager",
Expand Down
101 changes: 96 additions & 5 deletions src/components/specific/files/files-manager/FilesManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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";

Expand All @@ -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";
Expand Down Expand Up @@ -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([]);
Expand Down Expand Up @@ -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) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const proceedUpload = async (files, folder) => {
const proceedUpload = async ({ files, folders }, 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let folders = [];
const uploadFiles = async (event, folder = currentFolder.value) => {
const fromEvent = await getFilesFromEvent(event);
const files = fromEvent.files;
folders = fromEvent.folders;
const uploadFiles = async (event, folder = currentFolder.value) => {
const { files, folders } = await getFilesFromEvent(event);


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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
proceedUpload([...validFiles, ...finalFiles], folder);
proceedUpload({ files: [...validFiles, ...finalFiles], folders }, folder);

},
},
});
return;
}

proceedUpload(files, folder);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
proceedUpload(files, folder);
proceedUpload({ files, folders }, folder);

};

const loadingFileIds = ref([]);
const isCreatingModels = ref(false);
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -833,6 +922,8 @@ export default {
moveFiles,
onFileSelected,
openAccessManager,
openFolderNamingConstraintManager,
openNamingConflictsModal,
openFileDeleteModal,
openVisaDeleteModal,
openSidePanel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ import {
import { useFiles } from "../../../../../state/files.js";
import { useUser } from "../../../../../state/user.js";
import { isFullTotal } from "../../../../../utils/spaces.js";
import { collectDescendants } from "../../../../../utils/file-tree.js";
import { isFolder } from "../../../../../utils/file-structure.js";
import { fileUploadInput } from "../../../../../utils/upload.js";

// Components
Expand Down Expand Up @@ -157,7 +159,7 @@ export default {
required: true,
},
},
emits: ["open-subscription-modal", "update:searchText", "upload-files"],
emits: ["open-subscription-modal", "update:searchText", "upload-files", "manage-naming-conflicts"],
setup(props, { emit }) {
const { t } = useI18n();
const { isUserOrga, isProjectAdmin, isProjectGuest, hasAdminPerm } = useUser();
Expand All @@ -176,6 +178,14 @@ export default {
};

const dropdown = ref(null);
const conflictCount = computed(() => {
const root = projectFileStructure.value;
if (!root) return 0;
return collectDescendants(
root,
(child) => !isFolder(child) && child.naming_constraint_conflict,
).length;
});
const menuItems = computed(() => {
const items = [];

Expand All @@ -192,6 +202,17 @@ export default {
);
}

if (isProjectAdmin(props.project)) {
items.push({
name: t("NamingConstraint.renameConflictsMenuItem") +
(conflictCount.value > 0 ? ` (${conflictCount.value})` : ""),
action: () => {
emit("manage-naming-conflicts");
dropdown.value.displayed = false;
},
});
}

if (hasAdminPerm(props.project, props.currentFolder)) {
items.splice(1, 0, {
name: t("FilesManager.folderImport"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export default {
"download",
"file-clicked",
"manage-access",
"manage-naming-rule",
"open-tag-manager",
"open-versioning-manager",
"open-visa-manager",
Expand All @@ -96,14 +97,16 @@ export default {
const isOpen = ref(false);
const menuItems = shallowRef([]);

let current_key = 0;

const openMenu = () => {
if (!props.parent) return;

isOpen.value = true;

if (!isFolder(props.file)) {
menuItems.value.push({
key: 1,
key: current_key++,
icon: "preview",
text: "FileActionsCell.previewModelButtonText",
color: "primary",
Expand All @@ -114,7 +117,7 @@ export default {
if (isViewable(props.file)) {
const { model_id: id, model_type: type } = props.file;
menuItems.value.push({
key: 2,
key: current_key++,
icon: "show",
text: "FileActionsCell.openViewerButtonText",
color: "primary",
Expand All @@ -125,15 +128,15 @@ export default {
if (!isFolder(props.file) && isConvertible(props.file)) {
if (!isModel(props.file)) {
menuItems.value.push({
key: 3,
key: current_key++,
iconComponent: SetAsModelIcon,
text: "FileActionsCell.createModelButtonText",
disabled: !hasAdminPerm(props.project, props.file),
action: () => onClick("create-model")
});
} else {
menuItems.value.push({
key: 4,
key: current_key++,
iconComponent: RemoveModelsIcon,
text: "FileActionsCell.removeModelButtonText",
action: () => onClick("remove-model"),
Expand All @@ -143,7 +146,7 @@ export default {

if (!isFolder(props.file) && isConvertibleToPhotosphere(props.file) && !isModel(props.file)) {
menuItems.value.push({
key: 3,
key: current_key++,
iconComponent: SetAsModelIcon,
text: "FileActionsCell.createPhotosphereButtonText",
disabled: !hasAdminPerm(props.project, props.file),
Expand All @@ -152,7 +155,7 @@ export default {
}

menuItems.value.push({
key: 5,
key: current_key++,
icon: "edit",
text: "t.rename",
disabled: !hasAdminPerm(props.project, props.file),
Expand All @@ -168,31 +171,38 @@ export default {

if (isFolder(props.file) && isProjectAdmin(props.project)) {
menuItems.value.push({
key: 7,
key: current_key++,
icon: "key",
text: "FileActionsCell.manageAccessButtonText",
action: () => onClick("manage-access"),
divider: true,
});
menuItems.value.push({
key: current_key++,
iconComponent: "BIMDataIconLock",
text: "NamingConstraint.folderRuleMenuItem",
action: () => onClick("manage-naming-rule"),
dataTestId: "btn-manage-naming-rule",
});
}

if (!isFolder(props.file) && hasAdminPerm(props.project, props.file)) {
menuItems.value.push({
key: 8,
key: current_key++,
icon: "visa",
text: "FileActionsCell.visaButtonText",
action: () => onClick("open-visa-manager"),
dataTestId: "btn-open-visa-manager",
});
menuItems.value.push({
key: 9,
key: current_key++,
icon: "tag",
text: "FileActionsCell.addTagsButtonText",
action: () => onClick("open-tag-manager"),
dataTestId: "btn-open-tag-manager",
});
menuItems.value.push({
key: 10,
key: current_key++,
icon: "versioning",
text: "FileActionsCell.versioningButtonText",
action: () => onClick("open-versioning-manager"),
Expand All @@ -202,7 +212,7 @@ export default {
}

menuItems.value.push({
key: 11,
key: current_key++,
icon: "delete",
text: "t.delete",
color: "high",
Expand Down
Loading