Skip to content

Commit

Permalink
allow search queries with colons if no other filter applied
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Mar 15, 2024
1 parent aa18de7 commit 7597efb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
11 changes: 7 additions & 4 deletions client/src/components/Grid/GridList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -291,8 +294,8 @@ watch(operationMessage, () => {
<hr v-if="showAdvanced" />
</div>
<LoadingSpan v-if="initDataLoading" />
<span v-else-if="!isAvailable || Object.keys(invalidFilters).length > 0" variant="info" show>
<BAlert v-if="Object.keys(invalidFilters).length === 0" variant="info" show>
<span v-else-if="!isAvailable || hasInvalidFilters" variant="info" show>
<BAlert v-if="!hasInvalidFilters" variant="info" show>
<span v-if="filterText">
<span v-localize>Nothing found with:</span>
<b>{{ filterText }}</b>
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/Workflow/WorkflowCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ async function onTagClick(tag: string) {
'workflow-shared': workflow.published,
}">
<div class="workflow-card-header">
<WorkflowIndicators :workflow="workflow" :published-view="publishedView" @update-filter="(k, v) => emit('update-filter', k, v)" />
<WorkflowIndicators
:workflow="workflow"
:published-view="publishedView"
@update-filter="(k, v) => emit('update-filter', k, v)" />

<div class="workflow-count-actions">
<WorkflowInvocationsCount v-if="!isAnonymous && !shared" class="mx-1" :workflow="workflow" />
Expand Down
4 changes: 4 additions & 0 deletions client/src/components/Workflow/WorkflowFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
11 changes: 7 additions & 4 deletions client/src/components/Workflow/WorkflowList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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`
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -260,8 +263,8 @@ onMounted(() => {
</BAlert>

<!-- There are either `noResults` or `invalidFilters` -->
<span v-else-if="!loading && !overlay && (noResults || Object.keys(invalidFilters).length > 0)">
<BAlert v-if="Object.keys(invalidFilters).length === 0" id="no-workflow-found" variant="info" show>
<span v-else-if="!loading && !overlay && (noResults || hasInvalidFilters)">
<BAlert v-if="!hasInvalidFilters" id="no-workflow-found" variant="info" show>
No workflows found matching: <span class="font-weight-bold">{{ filterText }}</span>
</BAlert>

Expand Down

0 comments on commit 7597efb

Please sign in to comment.