diff --git a/src/mixins/routerMixin.js b/src/mixins/routerMixin.js new file mode 100644 index 000000000..0363c227b --- /dev/null +++ b/src/mixins/routerMixin.js @@ -0,0 +1,13 @@ +export default { + methods: { + setSearchTextQuery (searchText) { + let queries = JSON.parse(JSON.stringify(this.$route.query)); + if (searchText === '') { + delete queries.searchText; + } else { + queries.searchText = searchText; + } + this.$router.replace({query: queries}); + } + } +} diff --git a/src/views/policy/PolicyList.vue b/src/views/policy/PolicyList.vue index fe5ef25dc..2710b31c2 100644 --- a/src/views/policy/PolicyList.vue +++ b/src/views/policy/PolicyList.vue @@ -20,6 +20,7 @@ import xssFilters from "xss-filters"; import CreatePolicyModal from "./CreatePolicyModal"; import permissionsMixin from "../../mixins/permissionsMixin"; + import routerMixin from "../../mixins/routerMixin"; import i18n from "../../i18n"; import ActionableListGroupItem from "../components/ActionableListGroupItem"; import BInputGroupFormInput from "../../forms/BInputGroupFormInput"; @@ -33,7 +34,7 @@ import { Switch as cSwitch } from '@coreui/vue'; export default { - mixins: [permissionsMixin, bootstrapTableMixin], + mixins: [permissionsMixin, bootstrapTableMixin, routerMixin], components: { CreatePolicyModal }, @@ -355,6 +356,9 @@ localStorage.setItem("PolicyListPageSize", size.toString()) } }), + onSearch: ((text) => { + this.setSearchTextQuery(text); + }) } }; } diff --git a/src/views/portfolio/licenses/LicenseList.vue b/src/views/portfolio/licenses/LicenseList.vue index 7565e6bc9..50cc949a6 100644 --- a/src/views/portfolio/licenses/LicenseList.vue +++ b/src/views/portfolio/licenses/LicenseList.vue @@ -22,11 +22,12 @@ import PortfolioWidgetRow from "../../dashboard/PortfolioWidgetRow"; import xssFilters from "xss-filters"; import permissionsMixin from "../../../mixins/permissionsMixin"; + import routerMixin from "../../../mixins/routerMixin"; import LicenseAddLicenseModal from "@/views/portfolio/licenses/LicenseAddLicenseModal"; import {loadUserPreferencesForBootstrapTable} from "@/shared/utils"; export default { - mixins: [permissionsMixin], + mixins: [permissionsMixin, routerMixin], components: { LicenseAddLicenseModal, PortfolioWidgetRow @@ -132,6 +133,9 @@ localStorage.setItem("LicenseListSortName", name); localStorage.setItem("LicenseListSortOrder", order); } + }), + onSearch: ((text) => { + this.setSearchTextQuery(text); }) } }; diff --git a/src/views/portfolio/projects/ProjectList.vue b/src/views/portfolio/projects/ProjectList.vue index 33855bca8..da1eccd2d 100644 --- a/src/views/portfolio/projects/ProjectList.vue +++ b/src/views/portfolio/projects/ProjectList.vue @@ -28,6 +28,7 @@ import MurmurHash2 from "imurmurhash"; import Vue from 'vue'; import xssFilters from "xss-filters"; import permissionsMixin from "../../../mixins/permissionsMixin"; +import routerMixin from "../../../mixins/routerMixin"; import common from "../../../shared/common"; import PolicyViolationProgressBar from "../../components/PolicyViolationProgressBar"; import SeverityProgressBar from "../../components/SeverityProgressBar"; @@ -35,7 +36,7 @@ import PortfolioWidgetRow from "../../dashboard/PortfolioWidgetRow"; import ProjectCreateProjectModal from "./ProjectCreateProjectModal"; export default { - mixins: [permissionsMixin], + mixins: [permissionsMixin, routerMixin], components: { cSwitch, ProjectCreateProjectModal, @@ -343,6 +344,7 @@ import ProjectCreateProjectModal from "./ProjectCreateProjectModal"; this.showFlatView = false; } } + this.setSearchTextQuery(text); }), onPageChange: ((number, size) => { if (localStorage) { diff --git a/src/views/portfolio/vulnerabilities/VulnerabilityList.vue b/src/views/portfolio/vulnerabilities/VulnerabilityList.vue index 981336031..debf1e8b2 100644 --- a/src/views/portfolio/vulnerabilities/VulnerabilityList.vue +++ b/src/views/portfolio/vulnerabilities/VulnerabilityList.vue @@ -22,12 +22,13 @@ import $ from "jquery"; import xssFilters from "xss-filters"; import permissionsMixin from "../../../mixins/permissionsMixin"; +import routerMixin from "../../../mixins/routerMixin"; import common from "../../../shared/common"; import PortfolioWidgetRow from "../../dashboard/PortfolioWidgetRow"; import VulnerabilityCreateVulnerabilityModal from "./VulnerabilityCreateVulnerabilityModal"; export default { - mixins: [permissionsMixin], + mixins: [permissionsMixin, routerMixin], components: { VulnerabilityCreateVulnerabilityModal, PortfolioWidgetRow @@ -164,7 +165,10 @@ import VulnerabilityCreateVulnerabilityModal from "./VulnerabilityCreateVulnerab localStorage.setItem("VulnerabilityListSortName", name); localStorage.setItem("VulnerabilityListSortOrder", order); } - }) + }), + onSearch: ((text) => { + this.setSearchTextQuery(text); + }), } }; }