From cd16b044565d4bcda7bba07501e2465230916c51 Mon Sep 17 00:00:00 2001 From: Kristaps Fabians Geikins Date: Fri, 26 Apr 2024 10:44:49 +0300 Subject: [PATCH] fix: model list view query bug w/ names w/ parentheses (#2230) --- .../project/page/models/StructureItem.vue | 48 ++++++++++++------- .../components/user/profile/EditDialog.vue | 24 +++++++++- .../modules/core/repositories/branches.ts | 18 ++++--- 3 files changed, 64 insertions(+), 26 deletions(-) diff --git a/packages/frontend-2/components/project/page/models/StructureItem.vue b/packages/frontend-2/components/project/page/models/StructureItem.vue index 80bf075a2e..1ff94356ce 100644 --- a/packages/frontend-2/components/project/page/models/StructureItem.vue +++ b/packages/frontend-2/components/project/page/models/StructureItem.vue @@ -17,6 +17,9 @@ +
@@ -200,25 +203,32 @@ v-if="hasChildren && expanded && !isPendingFileUpload(item)" class="pl-8 mt-4 space-y-4" > -
-
- -
+
+ +
- +
+
+ +
+ + +
+ +
+
-
@@ -396,7 +406,11 @@ const viewAllUrl = computed(() => { return modelRoute(props.project.id, `$${props.item.fullName}`) }) -const { result: childrenResult, refetch: refetchChildren } = useQuery( +const { + result: childrenResult, + refetch: refetchChildren, + loading: childrenLoading +} = useQuery( projectModelChildrenTreeQuery, () => ({ projectId: props.project.id, diff --git a/packages/frontend-2/components/user/profile/EditDialog.vue b/packages/frontend-2/components/user/profile/EditDialog.vue index 7532781308..a1cb055c39 100644 --- a/packages/frontend-2/components/user/profile/EditDialog.vue +++ b/packages/frontend-2/components/user/profile/EditDialog.vue @@ -15,8 +15,17 @@ -
- User #{{ user.id }} {{ distinctId ? ` | ${distinctId}` : '' }} +
+ User ID: + + #{{ user.id }} + +
@@ -44,6 +53,7 @@ const props = defineProps<{ }>() const { activeUser: user, distinctId } = useActiveUser() +const { copy } = useClipboard() const isOpen = computed({ get: () => !!(props.open && user.value), @@ -59,4 +69,14 @@ const developerSettingsButton = computed(() => ({ isOpen.value = false } })) + +const copyUserId = () => { + if (!user.value) return + copy(user.value.id) +} + +const copyDistinctId = () => { + if (!distinctId.value) return + copy(distinctId.value) +} diff --git a/packages/server/modules/core/repositories/branches.ts b/packages/server/modules/core/repositories/branches.ts index eeb099a196..c82709b087 100644 --- a/packages/server/modules/core/repositories/branches.ts +++ b/packages/server/modules/core/repositories/branches.ts @@ -406,19 +406,23 @@ function getModelTreeItemsBaseQuery( projectId: string, options?: Partial<{ filterOutEmptyMain: boolean; parentModelName: string }> ) { - const cleanInput = (input: string | null | undefined) => { - const clean = (input || '').toLowerCase() - const trimmed = trim(trim(clean), '/') - return trimmed + const cleanInput = ( + input: string | null | undefined, + options?: Partial<{ escapeRegexp: boolean }> + ) => { + let clean = (input || '').toLowerCase() + clean = trim(trim(clean), '/') + clean = options?.escapeRegexp ? clean.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') : clean + return clean } const { filterOutEmptyMain = true, parentModelName } = options || {} - const cleanModelName = cleanInput(parentModelName) + const cleanModelName = cleanInput(parentModelName, { escapeRegexp: true }) const branchPartPattern = `[^/]+` // regexp for each branch part between slashes const regExp = cleanModelName.length ? // only direct children of parentModelName - `^${cleanModelName.replace('/', '\\/')}\\/(${branchPartPattern})` + `^${cleanModelName}\\/(${branchPartPattern})` : // only first branch part (top level item) `^${branchPartPattern}` @@ -470,7 +474,7 @@ function getModelTreeItemsBaseQuery( return { query: finalQuery, - parentModelName: cleanModelName + parentModelName: cleanInput(parentModelName) } }