Commit 07a36d1e authored by Nathan Friend's avatar Nathan Friend Committed by Olena Horal-Koretska

Rename release Vuex store modules

Updates the name of the Vuex store modules used on the releases pages.

"list" is now "index", "detail" is now "editNew".
parent 401c77ab
......@@ -22,7 +22,7 @@ export default {
TagField,
},
computed: {
...mapState('detail', [
...mapState('editNew', [
'isFetchingRelease',
'isUpdatingRelease',
'fetchError',
......@@ -36,13 +36,13 @@ export default {
'groupId',
'groupMilestonesAvailable',
]),
...mapGetters('detail', ['isValid', 'isExistingRelease']),
...mapGetters('editNew', ['isValid', 'isExistingRelease']),
showForm() {
return Boolean(!this.isFetchingRelease && !this.fetchError && this.release);
},
releaseTitle: {
get() {
return this.$store.state.detail.release.name;
return this.$store.state.editNew.release.name;
},
set(title) {
this.updateReleaseTitle(title);
......@@ -50,7 +50,7 @@ export default {
},
releaseNotes: {
get() {
return this.$store.state.detail.release.description;
return this.$store.state.editNew.release.description;
},
set(notes) {
this.updateReleaseNotes(notes);
......@@ -58,7 +58,7 @@ export default {
},
releaseMilestones: {
get() {
return this.$store.state.detail.release.milestones;
return this.$store.state.editNew.release.milestones;
},
set(milestones) {
this.updateReleaseMilestones(milestones);
......@@ -93,7 +93,7 @@ export default {
this.$el.querySelector('input:enabled, button:enabled').focus();
},
methods: {
...mapActions('detail', [
...mapActions('editNew', [
'initializeRelease',
'saveRelease',
'updateReleaseTitle',
......
......@@ -20,7 +20,7 @@ export default {
ReleasesSort,
},
computed: {
...mapState('list', [
...mapState('index', [
'documentationPath',
'illustrationPath',
'newReleasePath',
......@@ -46,7 +46,7 @@ export default {
window.addEventListener('popstate', this.fetchReleases);
},
methods: {
...mapActions('list', {
...mapActions('index', {
fetchReleasesStoreAction: 'fetchReleases',
}),
fetchReleases() {
......
......@@ -26,14 +26,14 @@ export default {
},
directives: { GlTooltip: GlTooltipDirective },
computed: {
...mapState('detail', ['release', 'releaseAssetsDocsPath']),
...mapGetters('detail', ['validationErrors']),
...mapState('editNew', ['release', 'releaseAssetsDocsPath']),
...mapGetters('editNew', ['validationErrors']),
},
created() {
this.ensureAtLeastOneLink();
},
methods: {
...mapActions('detail', [
...mapActions('editNew', [
'addEmptyAssetLink',
'updateAssetLinkUrl',
'updateAssetLinkName',
......
......@@ -7,13 +7,13 @@ export default {
name: 'ReleasesPaginationGraphql',
components: { GlKeysetPagination },
computed: {
...mapState('list', ['graphQlPageInfo']),
...mapState('index', ['graphQlPageInfo']),
showPagination() {
return this.graphQlPageInfo.hasPreviousPage || this.graphQlPageInfo.hasNextPage;
},
},
methods: {
...mapActions('list', ['fetchReleases']),
...mapActions('index', ['fetchReleases']),
onPrev(before) {
historyPushState(buildUrlWithCurrentLocation(`?before=${before}`));
this.fetchReleases({ before });
......
......@@ -7,10 +7,10 @@ export default {
name: 'ReleasesPaginationRest',
components: { TablePagination },
computed: {
...mapState('list', ['restPageInfo']),
...mapState('index', ['restPageInfo']),
},
methods: {
...mapActions('list', ['fetchReleases']),
...mapActions('index', ['fetchReleases']),
onChangePage(page) {
historyPushState(buildUrlWithCurrentLocation(`?page=${page}`));
this.fetchReleases({ page });
......
......@@ -10,7 +10,7 @@ export default {
GlSortingItem,
},
computed: {
...mapState('list', {
...mapState('index', {
orderBy: (state) => state.sorting.orderBy,
sort: (state) => state.sorting.sort,
}),
......@@ -26,7 +26,7 @@ export default {
},
},
methods: {
...mapActions('list', ['setSorting']),
...mapActions('index', ['setSorting']),
onDirectionChange() {
const sort = this.isSortAscending ? DESCENDING_ORDER : ASCENDING_ODER;
this.setSorting({ sort });
......
......@@ -9,7 +9,7 @@ export default {
TagFieldNew,
},
computed: {
...mapGetters('detail', ['isExistingRelease']),
...mapGetters('editNew', ['isExistingRelease']),
},
};
</script>
......
......@@ -8,7 +8,7 @@ export default {
name: 'TagFieldExisting',
components: { GlFormGroup, GlFormInput, FormFieldContainer },
computed: {
...mapState('detail', ['release']),
...mapState('editNew', ['release']),
inputId() {
return uniqueId('tag-name-input-');
},
......
......@@ -27,8 +27,8 @@ export default {
};
},
computed: {
...mapState('detail', ['projectId', 'release', 'createFrom']),
...mapGetters('detail', ['validationErrors']),
...mapState('editNew', ['projectId', 'release', 'createFrom']),
...mapGetters('editNew', ['validationErrors']),
tagName: {
get() {
return this.release.tagName;
......@@ -62,7 +62,7 @@ export default {
},
},
methods: {
...mapActions('detail', ['updateReleaseTagName', 'updateCreateFrom']),
...mapActions('editNew', ['updateReleaseTagName', 'updateCreateFrom']),
markInputAsDirty() {
this.isInputDirty = true;
},
......
......@@ -2,7 +2,7 @@ import Vue from 'vue';
import Vuex from 'vuex';
import ReleaseEditNewApp from './components/app_edit_new.vue';
import createStore from './stores';
import createDetailModule from './stores/modules/detail';
import createEditNewModule from './stores/modules/edit_new';
Vue.use(Vuex);
......@@ -11,7 +11,7 @@ export default () => {
const store = createStore({
modules: {
detail: createDetailModule(el.dataset),
editNew: createEditNewModule(el.dataset),
},
});
......
import Vue from 'vue';
import Vuex from 'vuex';
import ReleaseListApp from './components/app_index.vue';
import ReleaseIndexApp from './components/app_index.vue';
import createStore from './stores';
import createListModule from './stores/modules/list';
import createIndexModule from './stores/modules/index';
Vue.use(Vuex);
......@@ -13,7 +13,7 @@ export default () => {
el,
store: createStore({
modules: {
list: createListModule(el.dataset),
index: createIndexModule(el.dataset),
},
featureFlags: {
graphqlReleaseData: Boolean(gon.features?.graphqlReleaseData),
......@@ -21,6 +21,6 @@ export default () => {
graphqlMilestoneStats: Boolean(gon.features?.graphqlMilestoneStats),
},
}),
render: (h) => h(ReleaseListApp),
render: (h) => h(ReleaseIndexApp),
});
};
......@@ -2,7 +2,7 @@ import Vue from 'vue';
import Vuex from 'vuex';
import ReleaseEditNewApp from './components/app_edit_new.vue';
import createStore from './stores';
import createDetailModule from './stores/modules/detail';
import createEditNewModule from './stores/modules/edit_new';
Vue.use(Vuex);
......@@ -11,7 +11,7 @@ export default () => {
const store = createStore({
modules: {
detail: createDetailModule(el.dataset),
editNew: createEditNewModule(el.dataset),
},
});
......
......@@ -50,7 +50,7 @@ describe('Release edit/new component', () => {
merge(
{
modules: {
detail: {
editNew: {
namespaced: true,
actions,
state,
......@@ -168,7 +168,7 @@ describe('Release edit/new component', () => {
await factory({
store: {
modules: {
detail: {
editNew: {
getters: {
isExistingRelease: () => false,
},
......@@ -207,7 +207,7 @@ describe('Release edit/new component', () => {
await factory({
store: {
modules: {
detail: {
editNew: {
getters: {
isValid: () => true,
},
......@@ -227,7 +227,7 @@ describe('Release edit/new component', () => {
await factory({
store: {
modules: {
detail: {
editNew: {
getters: {
isValid: () => false,
},
......
......@@ -8,7 +8,7 @@ import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import ReleasesApp from '~/releases/components/app_index.vue';
import ReleasesPagination from '~/releases/components/releases_pagination.vue';
import createStore from '~/releases/stores';
import createListModule from '~/releases/stores/modules/list';
import createIndexModule from '~/releases/stores/modules/index';
import { pageInfoHeadersWithoutPagination, pageInfoHeadersWithPagination } from '../mock_data';
jest.mock('~/lib/utils/common_utils', () => ({
......@@ -41,15 +41,15 @@ describe('Releases App ', () => {
};
const createComponent = (stateUpdates = {}) => {
const listModule = createListModule({
const indexModule = createIndexModule({
...defaultInitialState,
...stateUpdates,
});
fetchReleaseSpy = jest.spyOn(listModule.actions, 'fetchReleases');
fetchReleaseSpy = jest.spyOn(indexModule.actions, 'fetchReleases');
const store = createStore({
modules: { list: listModule },
modules: { index: indexModule },
featureFlags: {
graphqlReleaseData: true,
graphqlReleasesPage: false,
......
......@@ -44,7 +44,7 @@ describe('Release edit component', () => {
const store = new Vuex.Store({
modules: {
detail: {
editNew: {
namespaced: true,
actions,
state,
......
......@@ -3,7 +3,7 @@ import Vuex from 'vuex';
import { historyPushState } from '~/lib/utils/common_utils';
import ReleasesPaginationGraphql from '~/releases/components/releases_pagination_graphql.vue';
import createStore from '~/releases/stores';
import createListModule from '~/releases/stores/modules/list';
import createIndexModule from '~/releases/stores/modules/index';
jest.mock('~/lib/utils/common_utils', () => ({
...jest.requireActual('~/lib/utils/common_utils'),
......@@ -15,7 +15,7 @@ localVue.use(Vuex);
describe('~/releases/components/releases_pagination_graphql.vue', () => {
let wrapper;
let listModule;
let indexModule;
const cursors = {
startCursor: 'startCursor',
......@@ -25,16 +25,16 @@ describe('~/releases/components/releases_pagination_graphql.vue', () => {
const projectPath = 'my/project';
const createComponent = (pageInfo) => {
listModule = createListModule({ projectPath });
indexModule = createIndexModule({ projectPath });
listModule.state.graphQlPageInfo = pageInfo;
indexModule.state.graphQlPageInfo = pageInfo;
listModule.actions.fetchReleases = jest.fn();
indexModule.actions.fetchReleases = jest.fn();
wrapper = mount(ReleasesPaginationGraphql, {
store: createStore({
modules: {
list: listModule,
index: indexModule,
},
featureFlags: {},
}),
......@@ -142,7 +142,7 @@ describe('~/releases/components/releases_pagination_graphql.vue', () => {
});
it('calls fetchReleases with the correct after cursor', () => {
expect(listModule.actions.fetchReleases.mock.calls).toEqual([
expect(indexModule.actions.fetchReleases.mock.calls).toEqual([
[expect.anything(), { after: cursors.endCursor }],
]);
});
......@@ -160,7 +160,7 @@ describe('~/releases/components/releases_pagination_graphql.vue', () => {
});
it('calls fetchReleases with the correct before cursor', () => {
expect(listModule.actions.fetchReleases.mock.calls).toEqual([
expect(indexModule.actions.fetchReleases.mock.calls).toEqual([
[expect.anything(), { before: cursors.startCursor }],
]);
});
......
......@@ -4,7 +4,7 @@ import Vuex from 'vuex';
import * as commonUtils from '~/lib/utils/common_utils';
import ReleasesPaginationRest from '~/releases/components/releases_pagination_rest.vue';
import createStore from '~/releases/stores';
import createListModule from '~/releases/stores/modules/list';
import createIndexModule from '~/releases/stores/modules/index';
commonUtils.historyPushState = jest.fn();
......@@ -13,21 +13,21 @@ localVue.use(Vuex);
describe('~/releases/components/releases_pagination_rest.vue', () => {
let wrapper;
let listModule;
let indexModule;
const projectId = 19;
const createComponent = (pageInfo) => {
listModule = createListModule({ projectId });
indexModule = createIndexModule({ projectId });
listModule.state.restPageInfo = pageInfo;
indexModule.state.restPageInfo = pageInfo;
listModule.actions.fetchReleases = jest.fn();
indexModule.actions.fetchReleases = jest.fn();
wrapper = mount(ReleasesPaginationRest, {
store: createStore({
modules: {
list: listModule,
index: indexModule,
},
featureFlags: {},
}),
......@@ -58,7 +58,7 @@ describe('~/releases/components/releases_pagination_rest.vue', () => {
});
it('calls fetchReleases with the correct page', () => {
expect(listModule.actions.fetchReleases.mock.calls).toEqual([
expect(indexModule.actions.fetchReleases.mock.calls).toEqual([
[expect.anything(), { page: newPage }],
]);
});
......
......@@ -3,7 +3,7 @@ import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex';
import ReleasesSort from '~/releases/components/releases_sort.vue';
import createStore from '~/releases/stores';
import createListModule from '~/releases/stores/modules/list';
import createIndexModule from '~/releases/stores/modules/index';
const localVue = createLocalVue();
localVue.use(Vuex);
......@@ -11,15 +11,15 @@ localVue.use(Vuex);
describe('~/releases/components/releases_sort.vue', () => {
let wrapper;
let store;
let listModule;
let indexModule;
const projectId = 8;
const createComponent = () => {
listModule = createListModule({ projectId });
indexModule = createIndexModule({ projectId });
store = createStore({
modules: {
list: listModule,
index: indexModule,
},
});
......@@ -52,7 +52,7 @@ describe('~/releases/components/releases_sort.vue', () => {
it('on sort change set sorting in vuex and emit event', () => {
findReleasesSorting().vm.$emit('sortDirectionChange');
expect(store.dispatch).toHaveBeenCalledWith('list/setSorting', { sort: 'asc' });
expect(store.dispatch).toHaveBeenCalledWith('index/setSorting', { sort: 'asc' });
expect(wrapper.emitted('sort:changed')).toBeTruthy();
});
......@@ -60,7 +60,7 @@ describe('~/releases/components/releases_sort.vue', () => {
const item = findSortingItems().at(0);
const { orderBy } = wrapper.vm.sortOptions[0];
item.vm.$emit('click');
expect(store.dispatch).toHaveBeenCalledWith('list/setSorting', { orderBy });
expect(store.dispatch).toHaveBeenCalledWith('index/setSorting', { orderBy });
expect(wrapper.emitted('sort:changed')).toBeTruthy();
});
});
......@@ -3,7 +3,7 @@ import { shallowMount, mount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex';
import TagFieldExisting from '~/releases/components/tag_field_existing.vue';
import createStore from '~/releases/stores';
import createDetailModule from '~/releases/stores/modules/detail';
import createEditNewModule from '~/releases/stores/modules/edit_new';
const TEST_TAG_NAME = 'test-tag-name';
......@@ -27,13 +27,13 @@ describe('releases/components/tag_field_existing', () => {
beforeEach(() => {
store = createStore({
modules: {
detail: createDetailModule({
editNew: createEditNewModule({
tagName: TEST_TAG_NAME,
}),
},
});
store.state.detail.release = {
store.state.editNew.release = {
tagName: TEST_TAG_NAME,
};
});
......
......@@ -3,7 +3,7 @@ import { mount, shallowMount } from '@vue/test-utils';
import Vue from 'vue';
import TagFieldNew from '~/releases/components/tag_field_new.vue';
import createStore from '~/releases/stores';
import createDetailModule from '~/releases/stores/modules/detail';
import createEditNewModule from '~/releases/stores/modules/edit_new';
const TEST_TAG_NAME = 'test-tag-name';
const TEST_PROJECT_ID = '1234';
......@@ -44,15 +44,15 @@ describe('releases/components/tag_field_new', () => {
beforeEach(() => {
store = createStore({
modules: {
detail: createDetailModule({
editNew: createEditNewModule({
projectId: TEST_PROJECT_ID,
}),
},
});
store.state.detail.createFrom = TEST_CREATE_FROM;
store.state.editNew.createFrom = TEST_CREATE_FROM;
store.state.detail.release = {
store.state.editNew.release = {
tagName: TEST_TAG_NAME,
assets: {
links: [],
......@@ -89,7 +89,7 @@ describe('releases/components/tag_field_new', () => {
});
it("updates the store's release.tagName property", () => {
expect(store.state.detail.release.tagName).toBe(NONEXISTENT_TAG_NAME);
expect(store.state.editNew.release.tagName).toBe(NONEXISTENT_TAG_NAME);
});
it('hides the "Create from" field', () => {
......@@ -107,7 +107,7 @@ describe('releases/components/tag_field_new', () => {
});
it("updates the store's release.tagName property", () => {
expect(store.state.detail.release.tagName).toBe(updatedTagName);
expect(store.state.editNew.release.tagName).toBe(updatedTagName);
});
it('shows the "Create from" field', () => {
......@@ -178,7 +178,7 @@ describe('releases/components/tag_field_new', () => {
await wrapper.vm.$nextTick();
expect(store.state.detail.createFrom).toBe(updatedCreateFrom);
expect(store.state.editNew.createFrom).toBe(updatedCreateFrom);
});
});
});
......
......@@ -3,7 +3,7 @@ import TagField from '~/releases/components/tag_field.vue';
import TagFieldExisting from '~/releases/components/tag_field_existing.vue';
import TagFieldNew from '~/releases/components/tag_field_new.vue';
import createStore from '~/releases/stores';
import createDetailModule from '~/releases/stores/modules/detail';
import createEditNewModule from '~/releases/stores/modules/edit_new';
describe('releases/components/tag_field', () => {
let store;
......@@ -12,11 +12,11 @@ describe('releases/components/tag_field', () => {
const createComponent = ({ tagName }) => {
store = createStore({
modules: {
detail: createDetailModule({}),
editNew: createEditNewModule({}),
},
});
store.state.detail.tagName = tagName;
store.state.editNew.tagName = tagName;
wrapper = shallowMount(TagField, { store });
};
......
......@@ -9,9 +9,9 @@ import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import httpStatus from '~/lib/utils/http_status';
import { redirectTo } from '~/lib/utils/url_utility';
import { ASSET_LINK_TYPE } from '~/releases/constants';
import * as actions from '~/releases/stores/modules/detail/actions';
import * as types from '~/releases/stores/modules/detail/mutation_types';
import createState from '~/releases/stores/modules/detail/state';
import * as actions from '~/releases/stores/modules/edit_new/actions';
import * as types from '~/releases/stores/modules/edit_new/mutation_types';
import createState from '~/releases/stores/modules/edit_new/state';
import { releaseToApiJson, apiJsonToRelease } from '~/releases/util';
jest.mock('~/flash');
......@@ -23,7 +23,7 @@ jest.mock('~/lib/utils/url_utility', () => ({
const originalRelease = getJSONFixture('api/releases/release.json');
describe('Release detail actions', () => {
describe('Release edit/new actions', () => {
let state;
let release;
let mock;
......
import * as getters from '~/releases/stores/modules/detail/getters';
import * as getters from '~/releases/stores/modules/edit_new/getters';
describe('Release detail getters', () => {
describe('Release edit/new getters', () => {
describe('isExistingRelease', () => {
it('returns true if the release is an existing release that already exists in the database', () => {
const state = { tagName: 'test-tag-name' };
......
import { getJSONFixture } from 'helpers/fixtures';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import { ASSET_LINK_TYPE, DEFAULT_ASSET_LINK_TYPE } from '~/releases/constants';
import * as types from '~/releases/stores/modules/detail/mutation_types';
import mutations from '~/releases/stores/modules/detail/mutations';
import createState from '~/releases/stores/modules/detail/state';
import * as types from '~/releases/stores/modules/edit_new/mutation_types';
import mutations from '~/releases/stores/modules/edit_new/mutations';
import createState from '~/releases/stores/modules/edit_new/state';
const originalRelease = getJSONFixture('api/releases/release.json');
describe('Release detail mutations', () => {
describe('Release edit/new mutations', () => {
let state;
let release;
......
......@@ -15,9 +15,9 @@ import {
fetchReleasesRest,
receiveReleasesError,
setSorting,
} from '~/releases/stores/modules/list/actions';
import * as types from '~/releases/stores/modules/list/mutation_types';
import createState from '~/releases/stores/modules/list/state';
} from '~/releases/stores/modules/index/actions';
import * as types from '~/releases/stores/modules/index/mutation_types';
import createState from '~/releases/stores/modules/index/state';
import { gqClient, convertAllReleasesGraphQLResponse } from '~/releases/util';
import { pageInfoHeadersWithoutPagination } from '../../../mock_data';
......
import state from '~/releases/stores/modules/list/state';
import state from '~/releases/stores/modules/index/state';
export const resetStore = (store) => {
store.replaceState(state());
......
import { getJSONFixture } from 'helpers/fixtures';
import { parseIntPagination, convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import * as types from '~/releases/stores/modules/list/mutation_types';
import mutations from '~/releases/stores/modules/list/mutations';
import createState from '~/releases/stores/modules/list/state';
import * as types from '~/releases/stores/modules/index/mutation_types';
import mutations from '~/releases/stores/modules/index/mutations';
import createState from '~/releases/stores/modules/index/state';
import { convertAllReleasesGraphQLResponse } from '~/releases/util';
import { pageInfoHeadersWithoutPagination } from '../../../mock_data';
......
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