diff options
Diffstat (limited to 'app/assets/javascripts/sidebar/components/todo_toggle/todo_button.vue')
-rw-r--r-- | app/assets/javascripts/sidebar/components/todo_toggle/todo_button.vue | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/app/assets/javascripts/sidebar/components/todo_toggle/todo_button.vue b/app/assets/javascripts/sidebar/components/todo_toggle/todo_button.vue new file mode 100644 index 00000000000..b49b8fc389b --- /dev/null +++ b/app/assets/javascripts/sidebar/components/todo_toggle/todo_button.vue @@ -0,0 +1,44 @@ +<script> +import { GlButton } from '@gitlab/ui'; +import { todoLabel, updateGlobalTodoCount } from '../../utils'; + +export default { + components: { + GlButton, + }, + props: { + isTodo: { + type: Boolean, + required: false, + default: true, + }, + }, + computed: { + buttonLabel() { + return todoLabel(this.isTodo); + }, + }, + methods: { + incrementGlobalTodoCount() { + updateGlobalTodoCount(1); + }, + decrementGlobalTodoCount() { + updateGlobalTodoCount(-1); + }, + onToggle(event) { + if (this.isTodo) { + this.decrementGlobalTodoCount(); + } else { + this.incrementGlobalTodoCount(); + } + this.$emit('click', event); + }, + }, +}; +</script> + +<template> + <gl-button v-bind="$attrs" :aria-label="buttonLabel" @click="onToggle($event)"> + {{ buttonLabel }} + </gl-button> +</template> |