summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorClement Ho <408677-ClemMakesApps@users.noreply.gitlab.com>2019-09-09 17:02:16 +0000
committerClement Ho <408677-ClemMakesApps@users.noreply.gitlab.com>2019-09-09 17:02:16 +0000
commitc15be006c046c6861ef5793fd85d3c6bee06e4ff (patch)
tree2b3f06763311244cd23e1cee4eec8365d17bda02 /app
parent55f05e6edcff2f71ae4785e72feb43eddce45e9d (diff)
parent929eb0568874cfe224ec59dbc4dda939f050dff4 (diff)
downloadgitlab-ce-c15be006c046c6861ef5793fd85d3c6bee06e4ff.tar.gz
Merge branch '9102-hide-dismissed-vulnerabilities-in-the-group-security-dashboard-backport' into 'master'
Add toggle to show/hide dismissed vulnerabilities (ports ee!15333) See merge request gitlab-org/gitlab-ce!32413
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/vue_shared/components/gl_toggle_vuex.vue49
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>