diff options
author | Paul Gascou-Vaillancourt <paul.gascvail@gmail.com> | 2019-08-29 13:52:25 -0400 |
---|---|---|
committer | Paul Gascou-Vaillancourt <paul.gascvail@gmail.com> | 2019-09-04 12:17:56 -0400 |
commit | 929eb0568874cfe224ec59dbc4dda939f050dff4 (patch) | |
tree | af794d1db9962b3d9abf935edc8b2fb775976815 /app | |
parent | ea4e9ada64091e186969d9656c74c7923652fcad (diff) | |
download | gitlab-ce-929eb0568874cfe224ec59dbc4dda939f050dff4.tar.gz |
Backport "Add toggle to hide dismissed vulnerabilities"9102-hide-dismissed-vulnerabilities-in-the-group-security-dashboard-backport
Backport of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/15333
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/vue_shared/components/gl_toggle_vuex.vue | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/app/assets/javascripts/vue_shared/components/gl_toggle_vuex.vue b/app/assets/javascripts/vue_shared/components/gl_toggle_vuex.vue new file mode 100644 index 00000000000..b649dac029a --- /dev/null +++ b/app/assets/javascripts/vue_shared/components/gl_toggle_vuex.vue @@ -0,0 +1,49 @@ +<script> +import { GlToggle } from '@gitlab/ui'; +import { capitalizeFirstCharacter } from '~/lib/utils/text_utility'; + +export default { + name: 'GlToggleVuex', + components: { + GlToggle, + }, + props: { + stateProperty: { + type: String, + required: true, + }, + storeModule: { + type: String, + required: false, + default: null, + }, + setAction: { + type: String, + required: false, + default() { + return `set${capitalizeFirstCharacter(this.stateProperty)}`; + }, + }, + }, + computed: { + value: { + get() { + const { state } = this.$store; + const { stateProperty, storeModule } = this; + return storeModule ? state[storeModule][stateProperty] : state[stateProperty]; + }, + set(value) { + const { stateProperty, storeModule, setAction } = this; + const action = storeModule ? `${storeModule}/${setAction}` : setAction; + this.$store.dispatch(action, { key: stateProperty, value }); + }, + }, + }, +}; +</script> + +<template> + <gl-toggle v-model="value"> + <slot v-bind="{ value }"></slot> + </gl-toggle> +</template> |