Skip to content
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

fix(search): Always show search bars #3089

Open
wants to merge 1 commit into
base: release-2.9
Choose a base branch
from
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
31 changes: 6 additions & 25 deletions src/app/application/components/app-collection/AppCollection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,12 @@
:key="key"
#[key]="{ row, rowValue }"
>
<template
v-if="key === 'toolbar'"
>
<div class="app-collection-toolbar">
<slot name="toolbar" />
</div>
</template>

<template v-else>
<slot
v-if="(props.items ?? []).length > 0"
:name="key"
:row="row as Row"
:row-value="rowValue"
/>
</template>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We no longer need the toolbar slot within AppCollection

<slot
v-if="(props.items ?? []).length > 0"
:name="key"
:row="row as Row"
:row-value="rowValue"
/>
</template>
</KTable>
</template>
Expand Down Expand Up @@ -149,15 +139,6 @@ const click = (e: MouseEvent) => {
.app-collection :deep(td:first-child li a:hover) {
text-decoration: underline;
}
.app-collection-toolbar {
display: flex;
justify-content: flex-end;
align-items: stretch;
flex-wrap: wrap;
gap: $kui-space-60;
font-size: $kui-font-size-40;
width: 100%;
}
</style>

<style lang="scss">
Expand Down
194 changes: 96 additions & 98 deletions src/app/common/filter-bar/FilterBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,111 +4,109 @@
class="filter-bar"
data-testid="filter-bar"
>
<search>
<form
ref="$form"
@submit.prevent="change"
<form
ref="$form"
@submit.prevent="change"
>
<button
class="focus-filter-input-button"
title="Focus filter"
type="button"
data-testid="filter-bar-focus-filter-input-button"
@click="focusFilterInput"
>
<button
class="focus-filter-input-button"
title="Focus filter"
type="button"
data-testid="filter-bar-focus-filter-input-button"
@click="focusFilterInput"
>
<span class="visually-hidden">Focus filter</span>

<span class="filter-bar-icon">
<FilterIcon
decorative
data-testid="filter-bar-filter-icon"
hide-title
:size="KUI_ICON_SIZE_30"
/>
</span>
</button>

<label
:for="`${props.id}-filter-bar-input`"
class="visually-hidden"
>
<slot>
{{ placeholderAndLabelFallback }}
</slot>
</label>
<input
:id="`${props.id}-filter-bar-input`"
ref="filterInput"
v-model="currentQuery"
class="filter-bar-input"
type="search"
:placeholder="currentPlaceholder"
data-testid="filter-bar-filter-input"
name="s"
@focus="isShowingSuggestionBox = true"
@input="isShowingSuggestionBox = true"
@blur="closeSuggestionBoxIfCondition"
@search="(e: InputEvent) => {
const $el = e.target as HTMLInputElement
if($el.value.length === 0) {
clear(e)
isShowingSuggestionBox = true
}
}"
>

<div
v-if="isShowingSuggestionBox"
class="suggestion-box"
data-testid="filter-bar-suggestion-box"
>
<div class="suggestion-list">
<p
v-if="tokenizerError !== null"
class="filter-bar-error"
>
{{ tokenizerError.message }}
</p>
<span class="visually-hidden">Focus filter</span>

<span class="filter-bar-icon">
<FilterIcon
decorative
data-testid="filter-bar-filter-icon"
hide-title
:size="KUI_ICON_SIZE_30"
/>
</span>
</button>

<label
:for="`${props.id}-filter-bar-input`"
class="visually-hidden"
>
<slot>
{{ placeholderAndLabelFallback }}
</slot>
</label>
<input
:id="`${props.id}-filter-bar-input`"
ref="filterInput"
v-model="currentQuery"
class="filter-bar-input"
type="search"
:placeholder="currentPlaceholder"
data-testid="filter-bar-filter-input"
name="s"
@focus="isShowingSuggestionBox = true"
@input="isShowingSuggestionBox = true"
@blur="closeSuggestionBoxIfCondition"
@search="(e: InputEvent) => {
const $el = e.target as HTMLInputElement
if($el.value.length === 0) {
clear(e)
isShowingSuggestionBox = true
}
}"
>

<div
v-if="isShowingSuggestionBox"
class="suggestion-box"
data-testid="filter-bar-suggestion-box"
>
<div class="suggestion-list">
<p
v-if="tokenizerError !== null"
class="filter-bar-error"
>
{{ tokenizerError.message }}
</p>

<button
v-else
type="submit"
class="submit-query-button"
:class="{ 'submit-query-button-is-selected': selectedSuggestionItemIndex === 0 }"
data-testid="filter-bar-submit-query-button"
>
Submit {{ currentQuery }}
</button>

<div
v-for="(fieldEntry, index) in fieldEntries"
:key="`${props.id}-${index}`"
class="suggestion-list-item"
:class="{ 'suggestion-list-item-is-selected': selectedSuggestionItemIndex === index + 1 }"
>
<b>{{ fieldEntry.fieldName }}</b><span v-if="fieldEntry.description !== ''">: {{ fieldEntry.description }}</span>

<button
v-else
type="submit"
class="submit-query-button"
:class="{ 'submit-query-button-is-selected': selectedSuggestionItemIndex === 0 }"
data-testid="filter-bar-submit-query-button"
class="apply-suggestion-button"
:title="`Add ${fieldEntry.fieldName}:`"
type="button"
:data-filter-field="fieldEntry.fieldName"
data-testid="filter-bar-apply-suggestion-button"
@click="applySuggestion"
>
Submit {{ currentQuery }}
</button>
<span class="visually-hidden">Add {{ fieldEntry.fieldName }}:</span>

<div
v-for="(fieldEntry, index) in fieldEntries"
:key="`${props.id}-${index}`"
class="suggestion-list-item"
:class="{ 'suggestion-list-item-is-selected': selectedSuggestionItemIndex === index + 1 }"
>
<b>{{ fieldEntry.fieldName }}</b><span v-if="fieldEntry.description !== ''">: {{ fieldEntry.description }}</span>

<button
class="apply-suggestion-button"
:title="`Add ${fieldEntry.fieldName}:`"
type="button"
:data-filter-field="fieldEntry.fieldName"
data-testid="filter-bar-apply-suggestion-button"
@click="applySuggestion"
>
<span class="visually-hidden">Add {{ fieldEntry.fieldName }}:</span>

<ChevronRightIcon
decorative
hide-title
:size="KUI_ICON_SIZE_30"
/>
</button>
</div>
<ChevronRightIcon
decorative
hide-title
:size="KUI_ICON_SIZE_30"
/>
</button>
</div>
</div>
</form>
</search>
</div>
</form>
</div>
</template>

Expand Down
96 changes: 52 additions & 44 deletions src/app/data-planes/views/DataPlaneListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,49 @@
>
<div v-html="t('data-planes.routes.items.intro', {}, { defaultMessage: '' })" />
<KCard>
<search>
<FilterBar
class="data-plane-proxy-filter"
:placeholder="`service:backend`"
:query="route.params.s"
:fields="{
name: { description: 'filter by name or parts of a name' },
protocol: { description: 'filter by “kuma.io/protocol” value' },
service: { description: 'filter by “kuma.io/service” value' },
tag: { description: 'filter by tags (e.g. “tag: version:2”)' },
...(can('use zones') && { zone: { description: 'filter by “kuma.io/zone” value' } }),
}"
@change="(e) => route.update({
...Object.fromEntries(e.entries()) as Record<string, string | undefined>,
})"
/>

<XSelect
label="Type"
:selected="route.params.dataplaneType"
@change="(value: string) => route.update({ dataplaneType: value })"
>
<template #selected="{ item }: { item: 'all' | 'standard' | 'builtin' | 'delegated'}">
<XIcon
v-if="item !== 'all'"
:size="KUI_ICON_SIZE_40"
:name="item"
/>
{{ t(`data-planes.type.${item}`) }}
</template>
<template
v-for="item in (['all', 'standard', 'builtin', 'delegated'] as const)"
:key="item"
#[`${item}-option`]
>
<XIcon
v-if="item !== 'all'"
:name="item"
/>
{{ t(`data-planes.type.${item}`) }}
</template>
</XSelect>
</search>
<DataLoader
:src="uri(sources, `/meshes/:mesh/dataplanes/of/:type`, {
mesh: route.params.mesh,
Expand Down Expand Up @@ -59,50 +102,6 @@
:is-selected-row="(row) => row.name === route.params.dataPlane"
@resize="me.set"
>
<template #toolbar>
<FilterBar
class="data-plane-proxy-filter"
:placeholder="`service:backend`"
:query="route.params.s"
:fields="{
name: { description: 'filter by name or parts of a name' },
protocol: { description: 'filter by “kuma.io/protocol” value' },
service: { description: 'filter by “kuma.io/service” value' },
tag: { description: 'filter by tags (e.g. “tag: version:2”)' },
...(can('use zones') && { zone: { description: 'filter by “kuma.io/zone” value' } }),
}"
@change="(e) => route.update({
...Object.fromEntries(e.entries()) as Record<string, string | undefined>,
})"
/>

<XSelect
label="Type"
:selected="route.params.dataplaneType"
@change="(value: string) => route.update({ dataplaneType: value })"
>
<template #selected="{ item }: { item: 'all' | 'standard' | 'builtin' | 'delegated'}">
<XIcon
v-if="item !== 'all'"
:size="KUI_ICON_SIZE_40"
:name="item"
/>
{{ t(`data-planes.type.${item}`) }}
</template>
<template
v-for="item in (['all', 'standard', 'builtin', 'delegated'] as const)"
:key="item"
#[`${item}-option`]
>
<XIcon
v-if="item !== 'all'"
:name="item"
/>
{{ t(`data-planes.type.${item}`) }}
</template>
</XSelect>
</template>

<template #type="{ row: item }">
<XIcon :name="item.dataplaneType">
{{ t(`data-planes.type.${item.dataplaneType}`) }}
Expand Down Expand Up @@ -311,6 +310,15 @@ const props = defineProps<{
text-decoration: none;
}

search {
width: 100%;
display: flex;
justify-content: flex-end;
align-items: stretch;
flex-wrap: wrap;
gap: $kui-space-60;
margin-bottom: $kui-space-60;
}
.data-plane-proxy-filter {
flex-basis: 310px;
flex-grow: 1;
Expand Down
Loading