diff --git a/ui/public/config.json b/ui/public/config.json index 64d102841862..e3d1d30b95fb 100644 --- a/ui/public/config.json +++ b/ui/public/config.json @@ -98,5 +98,6 @@ "multipleServer": false, "allowSettingTheme": true, "docHelpMappings": {}, - "notifyLatestCSVersion": true + "notifyLatestCSVersion": true, + "showSearchFilters": true } diff --git a/ui/src/components/view/SearchFilter.vue b/ui/src/components/view/SearchFilter.vue new file mode 100644 index 000000000000..ed950c094a3b --- /dev/null +++ b/ui/src/components/view/SearchFilter.vue @@ -0,0 +1,559 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + + + + diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index a01e300c1c9a..6acc81d6a029 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -106,6 +106,16 @@ @change-filter="changeFilter"/> + + + @@ -469,6 +479,7 @@ import ListView from '@/components/view/ListView' import ResourceView from '@/components/view/ResourceView' import ActionButton from '@/components/view/ActionButton' import SearchView from '@/components/view/SearchView' +import SearchFilter from '@/components/view/SearchFilter' import OsLogo from '@/components/widgets/OsLogo' import ResourceIcon from '@/components/view/ResourceIcon' import BulkActionProgress from '@/components/view/BulkActionProgress' @@ -482,6 +493,7 @@ export default { ListView, ActionButton, SearchView, + SearchFilter, BulkActionProgress, TooltipLabel, OsLogo, @@ -1126,6 +1138,42 @@ export default { eventBus.emit('action-closing', { action: this.currentAction }) this.closeAction() }, + getActiveFilters () { + const queryParams = Object.assign({}, this.$route.query) + const activeFilters = [] + for (const filter in queryParams) { + if (!filter.startsWith('tags[')) { + activeFilters.push({ + key: filter, + value: queryParams[filter], + isTag: false + }) + } else if (filter.endsWith('].key')) { + const tagIdx = filter.split('[')[1].split(']')[0] + const tagKey = queryParams[`tags[${tagIdx}].key`] + const tagValue = queryParams[`tags[${tagIdx}].value`] + activeFilters.push({ + key: tagKey, + value: tagValue, + isTag: true, + tagIdx: tagIdx + }) + } + } + return activeFilters + }, + removeFilter (filter) { + const queryParams = Object.assign({}, this.$route.query) + if (filter.isTag) { + delete queryParams[`tags[${filter.tagIdx}].key`] + delete queryParams[`tags[${filter.tagIdx}].value`] + } else { + delete queryParams[filter.key] + } + queryParams.page = '1' + queryParams.pagesize = String(this.pageSize) + this.$router.push({ query: queryParams }) + }, onRowSelectionChange (selection) { this.selectedRowKeys = selection if (selection?.length > 0) { diff --git a/ui/tests/unit/views/AutogenView.spec.js b/ui/tests/unit/views/AutogenView.spec.js index eb0352f99d1e..05b565ab9c9c 100644 --- a/ui/tests/unit/views/AutogenView.spec.js +++ b/ui/tests/unit/views/AutogenView.spec.js @@ -113,6 +113,10 @@ store = common.createMockStore(state, actions, mutations) i18n = common.createMockI18n('en', mockData.messages) mocks = { + $config: { + showSearchFilters: true, + docBase: 'http://docs.cloudstack.apache.org/en/latest' + }, $notifyError: jest.fn((error) => { return error }),