From 7597efb097a6025f7466c6accc52b4bafffac734 Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Fri, 15 Mar 2024 15:23:05 -0500 Subject: [PATCH] allow search queries with colons if no other filter applied --- client/src/components/Grid/GridList.vue | 11 +++++++---- client/src/components/Workflow/WorkflowCard.vue | 5 ++++- client/src/components/Workflow/WorkflowFilters.js | 4 ++++ client/src/components/Workflow/WorkflowList.vue | 11 +++++++---- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/client/src/components/Grid/GridList.vue b/client/src/components/Grid/GridList.vue index d0b3bae9f051..7a9e57784bb5 100644 --- a/client/src/components/Grid/GridList.vue +++ b/client/src/components/Grid/GridList.vue @@ -82,6 +82,9 @@ const filterClass = props.gridConfig.filtering; const rawFilters = computed(() => Object.fromEntries(filterClass.getFiltersForText(filterText.value, true, false))); const validFilters = computed(() => filterClass.getValidFilters(rawFilters.value, true).validFilters); const invalidFilters = computed(() => filterClass.getValidFilters(rawFilters.value, true).invalidFilters); +const hasInvalidFilters = computed( + () => Object.keys(invalidFilters.value).length > 0 && Object.keys(validFilters.value).length > 0 +); // hide message helper const hideMessage = useDebounceFn(() => { @@ -116,7 +119,7 @@ async function getGridData() { resultsLoading.value = true; selected.value = new Set(); if (props.gridConfig) { - if (Object.keys(invalidFilters.value).length > 0) { + if (hasInvalidFilters.value) { // there are invalid filters, so we don't want to search initDataLoading.value = false; resultsLoading.value = false; @@ -221,7 +224,7 @@ function onSelectAll(current: boolean): void { */ function validatedFilterText() { // there are no filters derived from the `filterText`; return the `filterText` as is - if (Object.keys(rawFilters.value).length === 0) { + if (Object.keys(rawFilters.value).length === 0 || Object.keys(validFilters.value).length === 0) { return filterText.value; } // there are valid filters derived from the `filterText` @@ -291,8 +294,8 @@ watch(operationMessage, () => {
- - + + Nothing found with: {{ filterText }} diff --git a/client/src/components/Workflow/WorkflowCard.vue b/client/src/components/Workflow/WorkflowCard.vue index b7fda777e075..818fb1844516 100644 --- a/client/src/components/Workflow/WorkflowCard.vue +++ b/client/src/components/Workflow/WorkflowCard.vue @@ -125,7 +125,10 @@ async function onTagClick(tag: string) { 'workflow-shared': workflow.published, }">
- +
diff --git a/client/src/components/Workflow/WorkflowFilters.js b/client/src/components/Workflow/WorkflowFilters.js index 509e9f4cfc96..1c184ff0d4c8 100644 --- a/client/src/components/Workflow/WorkflowFilters.js +++ b/client/src/components/Workflow/WorkflowFilters.js @@ -74,12 +74,14 @@ export function helpHtml(activeList = "my") { export function WorkflowFilters(activeList = "my") { const commonFilters = { name: { placeholder: "name", type: String, handler: contains("name"), menuItem: true }, + n: { handler: contains("n"), menuItem: false }, tag: { placeholder: "tag(s)", type: "MultiTags", handler: contains("tag", "tag", expandNameTag), menuItem: true, }, + t: { type: "MultiTags", handler: contains("t", "t", expandNameTag), menuItem: false }, }; if (activeList === "my") { @@ -129,6 +131,7 @@ export function WorkflowFilters(activeList = "my") { handler: contains("user"), menuItem: true, }, + u: { handler: contains("u"), menuItem: false }, published: { placeholder: "Filter on published workflows", type: Boolean, @@ -151,6 +154,7 @@ export function WorkflowFilters(activeList = "my") { handler: contains("user"), menuItem: true, }, + u: { handler: contains("u"), menuItem: false }, shared_with_me: { placeholder: "Filter on workflows shared with me", type: Boolean, diff --git a/client/src/components/Workflow/WorkflowList.vue b/client/src/components/Workflow/WorkflowList.vue index 9d8abcc2f7e1..37c857daf1d7 100644 --- a/client/src/components/Workflow/WorkflowList.vue +++ b/client/src/components/Workflow/WorkflowList.vue @@ -78,6 +78,9 @@ const rawFilters = computed(() => ); const validFilters = computed(() => workflowFilters.value.getValidFilters(rawFilters.value, true).validFilters); const invalidFilters = computed(() => workflowFilters.value.getValidFilters(rawFilters.value, true).invalidFilters); +const hasInvalidFilters = computed( + () => Object.keys(invalidFilters.value).length > 0 && Object.keys(validFilters.value).length > 0 +); function updateFilterValue(filterKey: string, newValue: any) { const currentFilterText = filterText.value; @@ -97,7 +100,7 @@ async function load(overlayLoading = false, silent = false) { } } let search; - if (Object.keys(invalidFilters.value).length === 0) { + if (!hasInvalidFilters.value) { search = validatedFilterText(); // append default backend query filters for provided `props.activeList` @@ -155,7 +158,7 @@ async function onPageChange(page: number) { function validatedFilterText() { // there are no filters derived from the `filterText` - if (Object.keys(rawFilters.value).length === 0) { + if (Object.keys(rawFilters.value).length === 0 || Object.keys(validFilters.value).length === 0) { return filterText.value; } // there are valid filters derived from the `filterText` @@ -260,8 +263,8 @@ onMounted(() => { - - + + No workflows found matching: {{ filterText }}