Skip to content

Commit

Permalink
feat(ui): add page settings dropdown to filters (#5905)
Browse files Browse the repository at this point in the history
  • Loading branch information
MilosPaunovic authored Nov 13, 2024
1 parent dcab506 commit 7f05c72
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 5 deletions.
1 change: 1 addition & 0 deletions ui/src/components/executions/Executions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
prefix="executions"
:include="['namespace', 'state', 'scope', 'labels', 'child', 'relative_date', 'absolute_date']"
:refresh="{shown: true, callback: refresh}"
:charts="{shown: true, value: showChart, callback: onShowChartChange}"
/>
</template>

Expand Down
18 changes: 17 additions & 1 deletion ui/src/components/filter/Wrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
filterable
multiple
popper-class="global-filters-select"
:class="{charts: charts.shown}"
@change="(value) => changeCallback(value)"
@remove-tag="(item) => removeItem(item)"
@visible-change="(visible) => dropdownClosedCallback(visible)"
Expand Down Expand Up @@ -57,6 +58,7 @@
<el-button :icon="Magnify" @click="triggerSearch" />
<Save :disabled="!current.length" :prefix :current />
<Refresh v-if="refresh.shown" @refresh="refresh.callback" />
<Settings :charts />
</el-button-group>
</section>
</template>
Expand All @@ -79,6 +81,8 @@
import History from "./components/history/History.vue";
import Save from "./components/Save.vue";
import Settings from "./components/Settings.vue";
import Magnify from "vue-material-design-icons/Magnify.vue";
import State from "../../utils/state.js";
Expand All @@ -91,6 +95,10 @@
type: Object,
default: () => ({shown: false, callback: () => {}}),
},
charts: {
type: Object,
default: () => ({shown: false, value: false, callback: () => {}}),
},
});
import {formatLabel, useFilters} from "./filters.js";
Expand Down Expand Up @@ -136,7 +144,7 @@
if (current.value?.at(-1)?.value?.length === 0) current.value.pop();
}
};
const valueCallback = (filter, isDate) => {
const valueCallback = (filter, isDate = false) => {
if (!isDate) {
const values = current.value[dropdowns.value.third.index].value;
const index = values.indexOf(filter.value);
Expand Down Expand Up @@ -324,6 +332,10 @@
& .el-select {
// Combined width of buttons on the sides of select
width: calc(100% - 237px);
&.charts {
width: calc(100% - 285px);
}
}
& .el-select__wrapper {
Expand Down Expand Up @@ -367,6 +379,10 @@
border-left: none;
}
.el-button-group > .el-dropdown > .el-button {
border-left-color: transparent;
}
.global-filters-select {
& .el-date-editor.el-input__wrapper {
background-color: initial;
Expand Down
20 changes: 18 additions & 2 deletions ui/src/components/filter/components/Save.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<template>
<el-button :disabled :icon="Save" @click="toggle(true)" />
<el-tooltip v-if="disabled" :content="t('filters.save.tooltip')">
<el-button disabled :icon="Save" @click="toggle(true)" />
</el-tooltip>

<el-button v-else :icon="Save" @click="toggle(true)" />

<el-dialog
v-model="visible"
Expand All @@ -20,6 +24,11 @@
@keydown.enter.prevent="save()"
/>
</section>
<section class="current-tags">
<el-tag v-for="(item, index) in current" :key="index" class="m-1">
{{ formatLabel(item) }}
</el-tag>
</section>
<template #footer>
<div class="dialog-footer">
<el-button @click="toggle()">
Expand Down Expand Up @@ -50,7 +59,7 @@
current: {type: Object, required: true},
});
import {useFilters} from "../filters.js";
import {formatLabel, useFilters} from "../filters.js";
const {getSavedItems, setSavedItems} = useFilters(props.prefix);
const visible = ref(false);
Expand All @@ -73,3 +82,10 @@
toast.saved(t("filters.save.dialog.confirmation", {name: label.value}));
};
</script>
<style lang="scss">
.current-tags .el-tag {
background: var(--bs-border-color) !important;
color: var(--bs-gray-900);
}
</style>
45 changes: 45 additions & 0 deletions ui/src/components/filter/components/Settings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<template>
<el-dropdown trigger="click" placement="bottom-end">
<el-button :icon="TableCog" />

<template #dropdown>
<el-dropdown-menu class="py-2 settings-dropdown">
<template v-if="charts.shown">
<el-switch
:model-value="charts.value"
@update:model-value="charts.callback"
:active-text="t('filters.settings.show_chart')"
class="p-3"
/>
</template>
</el-dropdown-menu>
</template>
</el-dropdown>
</template>

<script setup lang="ts">
import TableCog from "vue-material-design-icons/TableCog.vue";
import {useI18n} from "vue-i18n";
const {t} = useI18n({useScope: "global"});
defineProps({
charts: {
type: Object,
default: () => ({shown: false, value: false, callback: () => {}}),
},
});
</script>

<style lang="scss">
.settings-dropdown {
width: 200px;
}
.title {
margin: 0;
padding: calc(1rem / 4) 0 0 1rem;
font-size: var(--el-font-size-extra-small);
color: var(--bs-grey-700);
}
</style>
4 changes: 2 additions & 2 deletions ui/src/components/filter/components/history/History.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<el-button :icon="History" class="rounded-0 rounded-start" />

<template #dropdown>
<el-dropdown-menu class="py-2 dropdown">
<el-dropdown-menu class="py-2 history-dropdown">
<p class="title">
{{ t("filters.recent.label") }}
</p>
Expand Down Expand Up @@ -98,7 +98,7 @@
</script>

<style lang="scss">
.dropdown {
.history-dropdown {
width: 400px;
}
Expand Down
4 changes: 4 additions & 0 deletions ui/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -963,13 +963,17 @@
},
"save": {
"label": "Saved searches",
"tooltip": "You can't save empty search criteria.",
"dialog": {
"heading": "Save current search",
"placeholder": "Label",
"hint": "How do you want to label this search criteria?",
"confirmation": "Search criteria <code>{name}</code>"
}
},
"settings": {
"show_chart": "Show main chart"
},
"labels": {
"placeholder": "Type label as 'key:value'"
}
Expand Down

0 comments on commit 7f05c72

Please sign in to comment.