Commit 3bc32efe authored by Tom Quirk's avatar Tom Quirk

Use feature flag mixin

As opposed to accessing window object directly
parent 564fc623
...@@ -9,6 +9,7 @@ import { ACTIVE_DISCUSSION_SOURCE_TYPES } from '../constants'; ...@@ -9,6 +9,7 @@ import { ACTIVE_DISCUSSION_SOURCE_TYPES } from '../constants';
import DesignDiscussion from './design_notes/design_discussion.vue'; import DesignDiscussion from './design_notes/design_discussion.vue';
import Participants from '~/sidebar/components/participants/participants.vue'; import Participants from '~/sidebar/components/participants/participants.vue';
import TodoButton from '~/vue_shared/components/todo_button.vue'; import TodoButton from '~/vue_shared/components/todo_button.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
export default { export default {
components: { components: {
...@@ -19,6 +20,7 @@ export default { ...@@ -19,6 +20,7 @@ export default {
GlPopover, GlPopover,
TodoButton, TodoButton,
}, },
mixins: [glFeatureFlagsMixin()],
props: { props: {
design: { design: {
type: Object, type: Object,
...@@ -62,7 +64,12 @@ export default { ...@@ -62,7 +64,12 @@ export default {
return this.resolvedDiscussionsExpanded ? 'chevron-down' : 'chevron-right'; return this.resolvedDiscussionsExpanded ? 'chevron-down' : 'chevron-right';
}, },
showTodoButton() { showTodoButton() {
return gon.features?.designManagementTodoButton; return this.glFeatures.designManagementTodoButton;
},
sidebarWrapperClass() {
return {
'gl-pt-0': this.showTodoButton,
};
}, },
}, },
watch: { watch: {
...@@ -106,7 +113,7 @@ export default { ...@@ -106,7 +113,7 @@ export default {
</script> </script>
<template> <template>
<div class="image-notes" :class="{ 'gl-pt-0': showTodoButton }" @click="handleSidebarClick"> <div class="image-notes" :class="sidebarWrapperClass" @click="handleSidebarClick">
<div <div
v-if="showTodoButton" v-if="showTodoButton"
class="gl-py-4 gl-mb-4 gl-display-flex gl-justify-content-space-between gl-align-items-center gl-border-b-1 gl-border-b-solid gl-border-b-gray-100" class="gl-py-4 gl-mb-4 gl-display-flex gl-justify-content-space-between gl-align-items-center gl-border-b-1 gl-border-b-solid gl-border-b-gray-100"
......
...@@ -43,7 +43,7 @@ describe('Design management design sidebar component', () => { ...@@ -43,7 +43,7 @@ describe('Design management design sidebar component', () => {
const findNewDiscussionDisclaimer = () => const findNewDiscussionDisclaimer = () =>
wrapper.find('[data-testid="new-discussion-disclaimer"]'); wrapper.find('[data-testid="new-discussion-disclaimer"]');
function createComponent(props = {}) { function createComponent(props = {}, { enableTodoButton } = {}) {
wrapper = shallowMount(DesignSidebar, { wrapper = shallowMount(DesignSidebar, {
propsData: { propsData: {
design, design,
...@@ -58,6 +58,9 @@ describe('Design management design sidebar component', () => { ...@@ -58,6 +58,9 @@ describe('Design management design sidebar component', () => {
}, },
}, },
stubs: { GlPopover }, stubs: { GlPopover },
provide: {
glFeatures: { designManagementTodoButton: enableTodoButton },
},
}); });
} }
...@@ -250,12 +253,7 @@ describe('Design management design sidebar component', () => { ...@@ -250,12 +253,7 @@ describe('Design management design sidebar component', () => {
describe('when `design_management_todo_button` feature flag is enabled', () => { describe('when `design_management_todo_button` feature flag is enabled', () => {
beforeEach(() => { beforeEach(() => {
window.gon = { createComponent({}, { enableTodoButton: true });
features: {
designManagementTodoButton: true,
},
};
createComponent();
}); });
it('renders sidebar root element with no top padding', () => { it('renders sidebar root element with no top padding', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment