Commit fc10af3a authored by Coung Ngo's avatar Coung Ngo

Update hide labels from issue board cards

This commit fixes comments given on a merge request
parent 20da9965
export default { export default {
getSnowplowLabelToggleState: state => (state.isShowingLabels ? 'on' : 'off'), getLabelToggleState: state => (state.isShowingLabels ? 'on' : 'off'),
}; };
...@@ -546,9 +546,12 @@ ...@@ -546,9 +546,12 @@
cursor: help; cursor: help;
} }
.boards-labels-toggle-wrapper { .board-labels-toggle-wrapper {
display: flex; /**
align-items: center; * Make the wrapper the same height as a button so it aligns properly when the
* filtered-search-box input element increases in size on Linux smaller breakpoints
*/
height: 34px;
label { label {
font-weight: $gl-font-weight-normal; font-weight: $gl-font-weight-normal;
......
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
%button.clear-search.hidden{ type: 'button' } %button.clear-search.hidden{ type: 'button' }
= icon('times') = icon('times')
#boards-labels-toggle #js-board-labels-toggle
.filter-dropdown-container.d-flex.flex-column.flex-md-row .filter-dropdown-container.d-flex.flex-column.flex-md-row
- if type == :boards - if type == :boards
.js-board-config{ data: { can_admin_list: user_can_admin_list, has_scope: board.scoped? } } .js-board-config{ data: { can_admin_list: user_can_admin_list, has_scope: board.scoped? } }
......
...@@ -10,7 +10,7 @@ export default { ...@@ -10,7 +10,7 @@ export default {
...actionsCE, ...actionsCE,
toggleShowLabels({ commit }) { toggleShowLabels({ commit }) {
commit(types.TOGGLE_SHOW_LABELS); commit(types.TOGGLE_LABELS);
}, },
fetchAllBoards: () => { fetchAllBoards: () => {
......
...@@ -11,4 +11,4 @@ export const REQUEST_REMOVE_BOARD = 'REQUEST_REMOVE_BOARD'; ...@@ -11,4 +11,4 @@ export const REQUEST_REMOVE_BOARD = 'REQUEST_REMOVE_BOARD';
export const RECEIVE_REMOVE_BOARD_SUCCESS = 'RECEIVE_REMOVE_BOARD_SUCCESS'; export const RECEIVE_REMOVE_BOARD_SUCCESS = 'RECEIVE_REMOVE_BOARD_SUCCESS';
export const RECEIVE_REMOVE_BOARD_ERROR = 'RECEIVE_REMOVE_BOARD_ERROR'; export const RECEIVE_REMOVE_BOARD_ERROR = 'RECEIVE_REMOVE_BOARD_ERROR';
export const TOGGLE_PROMOTION_STATE = 'TOGGLE_PROMOTION_STATE'; export const TOGGLE_PROMOTION_STATE = 'TOGGLE_PROMOTION_STATE';
export const TOGGLE_SHOW_LABELS = 'TOGGLE_SHOW_LABELS'; export const TOGGLE_LABELS = 'TOGGLE_LABELS';
...@@ -6,7 +6,7 @@ const notImplemented = () => { ...@@ -6,7 +6,7 @@ const notImplemented = () => {
}; };
export default { export default {
[mutationTypes.TOGGLE_SHOW_LABELS]: state => { [mutationTypes.TOGGLE_LABELS]: state => {
Object.assign(state, { Object.assign(state, {
isShowingLabels: !state.isShowingLabels, isShowingLabels: !state.isShowingLabels,
}); });
......
...@@ -7,17 +7,21 @@ import store from '~/boards/stores'; ...@@ -7,17 +7,21 @@ import store from '~/boards/stores';
export default () => export default () =>
new Vue({ new Vue({
el: document.getElementById('boards-labels-toggle'), el: document.getElementById('js-board-labels-toggle'),
components: { components: {
GlToggle, GlToggle,
}, },
store, store,
data: {
toggleLabel: __('Show labels'),
},
computed: { computed: {
...mapState(['isShowingLabels']), ...mapState(['isShowingLabels']),
...mapGetters(['getSnowplowLabelToggleState']), ...mapGetters(['getLabelToggleState']),
toggleOnLabel() {
return __('Showing all labels');
},
toggleOffLabel() {
return __('Hiding all labels');
},
}, },
methods: { methods: {
...mapActions(['toggleShowLabels']), ...mapActions(['toggleShowLabels']),
...@@ -27,21 +31,21 @@ export default () => ...@@ -27,21 +31,21 @@ export default () =>
Tracking.event(document.body.dataset.page, 'toggle', { Tracking.event(document.body.dataset.page, 'toggle', {
label: 'show_labels', label: 'show_labels',
property: this.getSnowplowLabelToggleState, property: this.getLabelToggleState,
}); });
}, },
}, },
template: ` template: `
<div class="boards-labels-toggle-wrapper prepend-left-10"> <div class="board-labels-toggle-wrapper d-flex align-items-center prepend-left-10">
<span id="boards-labels-toggle-text"> <span id="board-labels-toggle-text">
{{toggleLabel}} {{ __('Show labels') }}
</span> </span>
<gl-toggle <gl-toggle
:value="isShowingLabels" :value="isShowingLabels"
class="prepend-left-10" class="prepend-left-10"
label-on="Showing all labels" :label-on="toggleOnLabel"
label-off="Hiding all labels" :label-off="toggleOffLabel"
aria-describedby="boards-labels-toggle-text" aria-describedby="board-labels-toggle-text"
data-qa-selector="show_labels_toggle" data-qa-selector="show_labels_toggle"
@change="onToggle" @change="onToggle"
/> />
......
...@@ -9,19 +9,12 @@ const expectNotImplemented = action => { ...@@ -9,19 +9,12 @@ const expectNotImplemented = action => {
}; };
describe('toggleShowLabels', () => { describe('toggleShowLabels', () => {
it('should commit mutation TOGGLE_SHOW_LABELS', done => { it('should commit mutation TOGGLE_LABELS', done => {
const state = { const state = {
isShowingLabels: true, isShowingLabels: true,
}; };
testAction( testAction(actions.toggleShowLabels, null, state, [{ type: types.TOGGLE_LABELS }], [], done);
actions.toggleShowLabels,
null,
state,
[{ type: types.TOGGLE_SHOW_LABELS }],
[],
done,
);
}); });
}); });
......
...@@ -6,13 +6,13 @@ const expectNotImplemented = action => { ...@@ -6,13 +6,13 @@ const expectNotImplemented = action => {
}); });
}; };
describe('TOGGLE_SHOW_LABELS', () => { describe('TOGGLE_LABELS', () => {
it('toggles isShowingLabels from true to false', () => { it('toggles isShowingLabels from true to false', () => {
const state = { const state = {
isShowingLabels: true, isShowingLabels: true,
}; };
mutations.TOGGLE_SHOW_LABELS(state); mutations.TOGGLE_LABELS(state);
expect(state.isShowingLabels).toBe(false); expect(state.isShowingLabels).toBe(false);
}); });
...@@ -22,7 +22,7 @@ describe('TOGGLE_SHOW_LABELS', () => { ...@@ -22,7 +22,7 @@ describe('TOGGLE_SHOW_LABELS', () => {
isShowingLabels: false, isShowingLabels: false,
}; };
mutations.TOGGLE_SHOW_LABELS(state); mutations.TOGGLE_LABELS(state);
expect(state.isShowingLabels).toBe(true); expect(state.isShowingLabels).toBe(true);
}); });
......
...@@ -8593,6 +8593,9 @@ msgstr[1] "" ...@@ -8593,6 +8593,9 @@ msgstr[1] ""
msgid "Hide values" msgid "Hide values"
msgstr "" msgstr ""
msgid "Hiding all labels"
msgstr ""
msgid "Highest number of requests per minute for each raw path, default to 300. To disable throttling set to 0." msgid "Highest number of requests per minute for each raw path, default to 300. To disable throttling set to 0."
msgstr "" msgstr ""
...@@ -15050,9 +15053,6 @@ msgstr "" ...@@ -15050,9 +15053,6 @@ msgstr ""
msgid "Show file browser" msgid "Show file browser"
msgstr "" msgstr ""
msgid "Show labels"
msgstr ""
msgid "Show latest version" msgid "Show latest version"
msgstr "" msgstr ""
...@@ -15082,6 +15082,9 @@ msgstr "" ...@@ -15082,6 +15082,9 @@ msgstr ""
msgid "Showing all issues" msgid "Showing all issues"
msgstr "" msgstr ""
msgid "Showing all labels"
msgstr ""
msgid "Showing last %{size} of log -" msgid "Showing last %{size} of log -"
msgstr "" msgstr ""
......
import getters from '~/boards/stores/getters'; import getters from '~/boards/stores/getters';
describe('Boards - Getters', () => { describe('Boards - Getters', () => {
describe('getSnowplowLabelToggleState', () => { describe('getLabelToggleState', () => {
it('should return "on" when isShowingLabels is true', () => { it('should return "on" when isShowingLabels is true', () => {
const state = { const state = {
isShowingLabels: true, isShowingLabels: true,
}; };
expect(getters.getSnowplowLabelToggleState(state)).toBe('on'); expect(getters.getLabelToggleState(state)).toBe('on');
}); });
it('should return "off" when isShowingLabels is false', () => { it('should return "off" when isShowingLabels is false', () => {
...@@ -15,7 +15,7 @@ describe('Boards - Getters', () => { ...@@ -15,7 +15,7 @@ describe('Boards - Getters', () => {
isShowingLabels: false, isShowingLabels: false,
}; };
expect(getters.getSnowplowLabelToggleState(state)).toBe('off'); expect(getters.getLabelToggleState(state)).toBe('off');
}); });
}); });
}); });
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