Skip to content
代码片段 群组 项目
提交 5991c92b 编辑于 作者: Alex Pennells's avatar Alex Pennells
浏览文件

Remove Vuex label logic from VSA tasks by type charts

Removes `defaultGroupLabels` from the VSA Tasks by Type
chart.
上级 aa40a568
No related branches found
No related tags found
2 合并请求!3031Merge per-main-jh to main-jh by luzhiyuan,!3030Merge per-main-jh to main-jh
import { withVuexStore } from 'storybook_addons/vuex_store';
import { TASKS_BY_TYPE_MAX_LABELS } from '../../constants';
import { defaultGroupLabels, subjectFilter } from './stories_constants';
import { subjectFilter } from './stories_constants';
import TasksByTypeFilters from './filters.vue';
export default {
......@@ -14,9 +14,6 @@ const Template = (args, { argTypes, createVuexStore }) => ({
props: Object.keys(argTypes),
template: '<tasks-by-type-filters v-bind="$props" />',
store: createVuexStore({
state: {
defaultGroupLabels,
},
getters: {
namespaceRestApiRequestPath: () => 'fake/namespace/path',
},
......@@ -29,10 +26,3 @@ Default.args = {
selectedLabelNames: [],
subjectFilter,
};
export const SelectedLabels = Template.bind({});
SelectedLabels.args = {
maxLabels: TASKS_BY_TYPE_MAX_LABELS,
selectedLabelNames: ['ready', 'done'],
subjectFilter,
};
<script>
import { GlCollapsibleListbox, GlSegmentedControl } from '@gitlab/ui';
// eslint-disable-next-line no-restricted-imports
import { mapState, mapGetters } from 'vuex';
import { mapGetters } from 'vuex';
import { difference, debounce } from 'lodash';
import { createAlert, VARIANT_INFO } from '~/alert';
import { __, s__, n__, sprintf } from '~/locale';
......@@ -41,7 +41,6 @@ export default {
};
},
computed: {
...mapState(['defaultGroupLabels']),
...mapGetters(['namespaceRestApiRequestPath']),
subjectFilterOptions() {
return Object.entries(TASKS_BY_TYPE_SUBJECT_FILTER_OPTIONS).map(([value, text]) => ({
......@@ -88,13 +87,9 @@ export default {
async mounted() {
this.debouncedSearch = debounce(this.search, DATA_REFETCH_DELAY);
if (!this.defaultGroupLabels?.length) {
this.loading = true;
await this.fetchLabels();
this.loading = false;
} else {
this.labels = this.defaultGroupLabels;
}
this.loading = true;
await this.fetchLabels();
this.loading = false;
},
methods: {
async fetchLabels() {
......
......@@ -2,30 +2,6 @@ import { TASKS_BY_TYPE_FILTERS } from '../../constants';
export const subjectFilter = TASKS_BY_TYPE_FILTERS.SUBJECT;
export const defaultGroupLabels = [
{
id: 1,
title: 'in-review',
color: '#4018cc',
project_id: null,
text_color: '#FFFFFF',
},
{
id: 2,
title: 'ready',
color: '#48b29d',
project_id: null,
text_color: '#FFFFFF',
},
{
id: 3,
title: 'done',
color: '#4c20e8',
project_id: null,
text_color: '#FFFFFF',
},
];
export const tasksByTypeData = [
{
label: { title: 'in-review' },
......
import { withVuexStore } from 'storybook_addons/vuex_store';
import TypeOfWorkCharts from './type_of_work_charts.vue';
import { tasksByTypeChartData, defaultGroupLabels } from './stories_constants';
import { tasksByTypeChartData } from './stories_constants';
export default {
component: TypeOfWorkCharts,
......@@ -15,7 +15,6 @@ const createStoryWithState = () => {
template: '<type-of-work-charts v-bind="$props" />',
store: createVuexStore({
state: {
defaultGroupLabels,
namespace: { name: 'Some namespace' },
createdAfter: new Date('2023-01-01'),
createdBefore: new Date('2023-12-31'),
......@@ -30,12 +29,6 @@ const createStoryWithState = () => {
export const Default = createStoryWithState().bind({});
Default.args = { chartData: tasksByTypeChartData };
export const SelectedLabels = createStoryWithState().bind({});
SelectedLabels.args = {
chartData: tasksByTypeChartData,
selectedLabelNames: [defaultGroupLabels[0].title],
};
export const NoData = createStoryWithState().bind({});
NoData.args = { chartData: { data: [] } };
......
......@@ -137,10 +137,10 @@ describe('TasksByTypeFilters', () => {
});
});
describe('with no default labels', () => {
describe('labels', () => {
beforeEach(() => {
mockGroupLabelsRequest();
createWrapper({ state: { defaultGroupLabels: [] } });
createWrapper();
});
it('will show loading state while request is pending', () => {
......@@ -165,7 +165,7 @@ describe('TasksByTypeFilters', () => {
describe('default labels fail to load', () => {
beforeEach(() => {
mockGroupLabelsRequest({ status: HTTP_STATUS_NOT_FOUND });
return createWrapper({ state: { defaultGroupLabels: [] } });
return createWrapper();
});
it('stops the loading state', () => {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册