Commit fcf5cfc2 authored by Zack Cuddy's avatar Zack Cuddy

Geo Replication - Paramaterized API

This MR is an effort at MVC.

This MR splits off from:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/26410

The overall focus of this and following related
changes is to replace Geo_dDesigns with
Geo_Replicable.

This MR adds the prop "replicable_type".
This prop is used in the geo_replication api
to denote which type of replicable we are using.

It also removes an un-used prop:
"design_management_link" that had no
usage in the components.

Following MRs:
Public Store Functions and State
Vue Components and Filenames
parent 1438907f
...@@ -4,7 +4,7 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -4,7 +4,7 @@ import axios from '~/lib/utils/axios_utils';
export default { export default {
...Api, ...Api,
geoNodesPath: '/api/:version/geo_nodes', geoNodesPath: '/api/:version/geo_nodes',
geoDesignsPath: '/api/:version/geo_replication/designs', geoReplicationPath: '/api/:version/geo_replication/:replicable',
ldapGroupsPath: '/api/:version/ldap/:provider/groups.json', ldapGroupsPath: '/api/:version/ldap/:provider/groups.json',
subscriptionPath: '/api/:version/namespaces/:id/gitlab_subscription', subscriptionPath: '/api/:version/namespaces/:id/gitlab_subscription',
childEpicPath: '/api/:version/groups/:id/epics/:epic_iid/epics', childEpicPath: '/api/:version/groups/:id/epics/:epic_iid/epics',
...@@ -215,18 +215,18 @@ export default { ...@@ -215,18 +215,18 @@ export default {
return axios.get(url, { params }); return axios.get(url, { params });
}, },
getGeoDesigns(params = {}) { getGeoReplicableItems(replicable, params = {}) {
const url = Api.buildUrl(this.geoDesignsPath); const url = Api.buildUrl(this.geoReplicationPath).replace(':replicable', replicable);
return axios.get(url, { params }); return axios.get(url, { params });
}, },
initiateAllGeoDesignSyncs(action) { initiateAllGeoReplicableSyncs(replicable, action) {
const url = Api.buildUrl(this.geoDesignsPath); const url = Api.buildUrl(this.geoReplicationPath).replace(':replicable', replicable);
return axios.post(`${url}/${action}`, {}); return axios.post(`${url}/${action}`, {});
}, },
initiateGeoDesignSync({ projectId, action }) { initiateGeoReplicableSync(replicable, { projectId, action }) {
const url = Api.buildUrl(this.geoDesignsPath); const url = Api.buildUrl(this.geoReplicationPath).replace(':replicable', replicable);
return axios.put(`${url}/${projectId}/${action}`, {}); return axios.put(`${url}/${projectId}/${action}`, {});
}, },
......
...@@ -26,10 +26,6 @@ export default { ...@@ -26,10 +26,6 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
designManagementLink: {
type: String,
required: true,
},
}, },
computed: { computed: {
...mapState(['isLoading', 'totalDesigns']), ...mapState(['isLoading', 'totalDesigns']),
......
<script> <script>
import { mapState } from 'vuex';
import { GlEmptyState } from '@gitlab/ui'; import { GlEmptyState } from '@gitlab/ui';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
...@@ -18,6 +19,7 @@ export default { ...@@ -18,6 +19,7 @@ export default {
}, },
}, },
computed: { computed: {
...mapState(['replicableType']),
linkText() { linkText() {
return sprintf( return sprintf(
s__( s__(
...@@ -35,7 +37,10 @@ export default { ...@@ -35,7 +37,10 @@ export default {
</script> </script>
<template> <template>
<gl-empty-state :title="__('No Design Repositories match this filter')" :svg-path="issuesSvgPath"> <gl-empty-state
:title="sprintf(__('No %{replicableType} match this filter'), { replicableType })"
:svg-path="issuesSvgPath"
>
<template #description> <template #description>
<div class="text-center"> <div class="text-center">
<p>{{ __('Adjust your filters/search criteria above.') }}</p> <p>{{ __('Adjust your filters/search criteria above.') }}</p>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import { debounce } from 'underscore'; import { debounce } from 'underscore';
import { GlTabs, GlTab, GlFormInput, GlDropdown, GlDropdownItem } from '@gitlab/ui'; import { GlTabs, GlTab, GlFormInput, GlDropdown, GlDropdownItem } from '@gitlab/ui';
import { __, sprintf } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import { DEFAULT_SEARCH_DELAY, ACTION_TYPES } from '../store/constants'; import { DEFAULT_SEARCH_DELAY, ACTION_TYPES } from '../store/constants';
...@@ -16,7 +17,7 @@ export default { ...@@ -16,7 +17,7 @@ export default {
Icon, Icon,
}, },
computed: { computed: {
...mapState(['currentFilterIndex', 'filterOptions', 'searchFilter']), ...mapState(['currentFilterIndex', 'filterOptions', 'searchFilter', 'replicableType']),
search: { search: {
get() { get() {
return this.searchFilter; return this.searchFilter;
...@@ -26,6 +27,9 @@ export default { ...@@ -26,6 +27,9 @@ export default {
this.fetchDesigns(); this.fetchDesigns();
}, DEFAULT_SEARCH_DELAY), }, DEFAULT_SEARCH_DELAY),
}, },
resyncText() {
return sprintf(__('Resync all %{replicableType}'), { replicableType: this.replicableType });
},
}, },
methods: { methods: {
...mapActions(['setFilter', 'setSearch', 'fetchDesigns', 'initiateAllDesignSyncs']), ...mapActions(['setFilter', 'setSearch', 'fetchDesigns', 'initiateAllDesignSyncs']),
...@@ -57,9 +61,9 @@ export default { ...@@ -57,9 +61,9 @@ export default {
<icon name="chevron-down" /> <icon name="chevron-down" />
</span> </span>
</template> </template>
<gl-dropdown-item @click="initiateAllDesignSyncs($options.actionTypes.RESYNC)">{{ <gl-dropdown-item @click="initiateAllDesignSyncs($options.actionTypes.RESYNC)">
__('Resync all designs') {{ resyncText }}
}}</gl-dropdown-item> </gl-dropdown-item>
</gl-dropdown> </gl-dropdown>
</div> </div>
</template> </template>
......
...@@ -7,23 +7,23 @@ Vue.use(Translate); ...@@ -7,23 +7,23 @@ Vue.use(Translate);
export default () => { export default () => {
const el = document.getElementById('js-geo-designs'); const el = document.getElementById('js-geo-designs');
const { replicableType } = el.dataset;
return new Vue({ return new Vue({
el, el,
store: createStore(), store: createStore(replicableType),
components: { components: {
GeoDesignsApp, GeoDesignsApp,
}, },
data() { data() {
const { const {
dataset: { geoSvgPath, issuesSvgPath, geoTroubleshootingLink, designManagementLink }, dataset: { geoSvgPath, issuesSvgPath, geoTroubleshootingLink },
} = this.$options.el; } = this.$options.el;
return { return {
geoSvgPath, geoSvgPath,
issuesSvgPath, issuesSvgPath,
geoTroubleshootingLink, geoTroubleshootingLink,
designManagementLink,
}; };
}, },
...@@ -33,7 +33,6 @@ export default () => { ...@@ -33,7 +33,6 @@ export default () => {
geoSvgPath: this.geoSvgPath, geoSvgPath: this.geoSvgPath,
issuesSvgPath: this.issuesSvgPath, issuesSvgPath: this.issuesSvgPath,
geoTroubleshootingLink: this.geoTroubleshootingLink, geoTroubleshootingLink: this.geoTroubleshootingLink,
designManagementLink: this.designManagementLink,
}, },
}); });
}, },
......
import Api from 'ee/api'; import Api from 'ee/api';
import createFlash from '~/flash'; import createFlash from '~/flash';
import toast from '~/vue_shared/plugins/global_toast'; import toast from '~/vue_shared/plugins/global_toast';
import { __ } from '~/locale'; import { __, sprintf } from '~/locale';
import { import {
parseIntPagination, parseIntPagination,
normalizeHeaders, normalizeHeaders,
...@@ -14,8 +14,12 @@ import { FILTER_STATES } from './constants'; ...@@ -14,8 +14,12 @@ import { FILTER_STATES } from './constants';
export const requestReplicableItems = ({ commit }) => commit(types.REQUEST_REPLICABLE_ITEMS); export const requestReplicableItems = ({ commit }) => commit(types.REQUEST_REPLICABLE_ITEMS);
export const receiveReplicableItemsSuccess = ({ commit }, data) => export const receiveReplicableItemsSuccess = ({ commit }, data) =>
commit(types.RECEIVE_REPLICABLE_ITEMS_SUCCESS, data); commit(types.RECEIVE_REPLICABLE_ITEMS_SUCCESS, data);
export const receiveReplicableItemsError = ({ commit }) => { export const receiveReplicableItemsError = ({ state, commit }) => {
createFlash(__('There was an error fetching the designs')); createFlash(
sprintf(__('There was an error fetching the %{replicableType}'), {
replicableType: state.replicableType,
}),
);
commit(types.RECEIVE_REPLICABLE_ITEMS_ERROR); commit(types.RECEIVE_REPLICABLE_ITEMS_ERROR);
}; };
...@@ -31,7 +35,7 @@ export const fetchDesigns = ({ state, dispatch }) => { ...@@ -31,7 +35,7 @@ export const fetchDesigns = ({ state, dispatch }) => {
sync_status: statusFilterName === FILTER_STATES.ALL ? null : statusFilterName, sync_status: statusFilterName === FILTER_STATES.ALL ? null : statusFilterName,
}; };
Api.getGeoDesigns(query) Api.getGeoReplicableItems(state.replicableType, query)
.then(res => { .then(res => {
const normalizedHeaders = normalizeHeaders(res.headers); const normalizedHeaders = normalizeHeaders(res.headers);
const paginationInformation = parseIntPagination(normalizedHeaders); const paginationInformation = parseIntPagination(normalizedHeaders);
...@@ -51,20 +55,32 @@ export const fetchDesigns = ({ state, dispatch }) => { ...@@ -51,20 +55,32 @@ export const fetchDesigns = ({ state, dispatch }) => {
// Initiate All Replicable Syncs // Initiate All Replicable Syncs
export const requestInitiateAllReplicableSyncs = ({ commit }) => export const requestInitiateAllReplicableSyncs = ({ commit }) =>
commit(types.REQUEST_INITIATE_ALL_REPLICABLE_SYNCS); commit(types.REQUEST_INITIATE_ALL_REPLICABLE_SYNCS);
export const receiveInitiateAllReplicableSyncsSuccess = ({ commit, dispatch }, { action }) => { export const receiveInitiateAllReplicableSyncsSuccess = (
toast(__(`All designs are being scheduled for ${action}`)); { state, commit, dispatch },
{ action },
) => {
toast(
sprintf(__('All %{replicableType} are being scheduled for %{action}'), {
replicableType: state.replicableType,
action,
}),
);
commit(types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS); commit(types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS);
dispatch('fetchReplicableItems'); dispatch('fetchDesigns');
}; };
export const receiveInitiateAllReplicableSyncsError = ({ commit }) => { export const receiveInitiateAllReplicableSyncsError = ({ state, commit }) => {
createFlash(__('There was an error syncing the designs.')); createFlash(
sprintf(__('There was an error syncing the %{replicableType}'), {
replicableType: state.replicableType,
}),
);
commit(types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_ERROR); commit(types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_ERROR);
}; };
export const initiateAllDesignSyncs = ({ dispatch }, action) => { export const initiateAllDesignSyncs = ({ state, dispatch }, action) => {
dispatch('requestInitiateAllReplicableSyncs'); dispatch('requestInitiateAllReplicableSyncs');
Api.initiateAllGeoDesignSyncs(action) Api.initiateAllGeoReplicableSyncs(state.replicableType, action)
.then(() => dispatch('receiveInitiateAllReplicableSyncsSuccess', { action })) .then(() => dispatch('receiveInitiateAllReplicableSyncsSuccess', { action }))
.catch(() => { .catch(() => {
dispatch('receiveInitiateAllReplicableSyncsError'); dispatch('receiveInitiateAllReplicableSyncsError');
...@@ -75,19 +91,19 @@ export const initiateAllDesignSyncs = ({ dispatch }, action) => { ...@@ -75,19 +91,19 @@ export const initiateAllDesignSyncs = ({ dispatch }, action) => {
export const requestInitiateReplicableSync = ({ commit }) => export const requestInitiateReplicableSync = ({ commit }) =>
commit(types.REQUEST_INITIATE_REPLICABLE_SYNC); commit(types.REQUEST_INITIATE_REPLICABLE_SYNC);
export const receiveInitiateReplicableSyncSuccess = ({ commit, dispatch }, { name, action }) => { export const receiveInitiateReplicableSyncSuccess = ({ commit, dispatch }, { name, action }) => {
toast(__(`${name} is scheduled for ${action}`)); toast(sprintf(__('%{name} is scheduled for %{action}'), { name, action }));
commit(types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS); commit(types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS);
dispatch('fetchReplicableItems'); dispatch('fetchDesigns');
}; };
export const receiveInitiateReplicableSyncError = ({ commit }, { name }) => { export const receiveInitiateReplicableSyncError = ({ commit }, { name }) => {
createFlash(__(`There was an error syncing project '${name}'`)); createFlash(sprintf(__('There was an error syncing project %{name}'), { name }));
commit(types.RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR); commit(types.RECEIVE_INITIATE_REPLICABLE_SYNC_ERROR);
}; };
export const initiateDesignSync = ({ dispatch }, { projectId, name, action }) => { export const initiateDesignSync = ({ state, dispatch }, { projectId, name, action }) => {
dispatch('requestInitiateReplicableSync'); dispatch('requestInitiateReplicableSync');
Api.initiateGeoDesignSync({ projectId, action }) Api.initiateGeoReplicableSync(state.replicableType, { projectId, action })
.then(() => dispatch('receiveInitiateReplicableSyncSuccess', { name, action })) .then(() => dispatch('receiveInitiateReplicableSyncSuccess', { name, action }))
.catch(() => { .catch(() => {
dispatch('receiveInitiateReplicableSyncError', { name }); dispatch('receiveInitiateReplicableSyncError', { name });
......
...@@ -6,10 +6,10 @@ import createState from './state'; ...@@ -6,10 +6,10 @@ import createState from './state';
Vue.use(Vuex); Vue.use(Vuex);
const createStore = () => const createStore = replicableType =>
new Vuex.Store({ new Vuex.Store({
actions, actions,
mutations, mutations,
state: createState(), state: createState(replicableType),
}); });
export default createStore; export default createStore;
import { FILTER_STATES } from './constants'; import { FILTER_STATES } from './constants';
const createState = () => ({ const createState = replicableType => ({
replicableType,
isLoading: false, isLoading: false,
designs: [], designs: [],
......
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
#js-geo-designs{ data: { "geo-svg-path" => image_path('illustrations/empty-state/geo-empty.svg'), #js-geo-designs{ data: { "geo-svg-path" => image_path('illustrations/empty-state/geo-empty.svg'),
"issues-svg-path" => image_path('illustrations/issues.svg'), "issues-svg-path" => image_path('illustrations/issues.svg'),
"geo-troubleshooting-link" => help_page_path('administration/geo/replication/troubleshooting.html'), "geo-troubleshooting-link" => help_page_path('administration/geo/replication/troubleshooting.html'),
"design-management-link" => help_page_path('user/project/issues/design_management.html') } } "replicable-type" => 'designs' } }
...@@ -550,17 +550,19 @@ describe('Api', () => { ...@@ -550,17 +550,19 @@ describe('Api', () => {
}); });
}); });
describe('GeoDesigns', () => { describe('GeoReplicable', () => {
let expectedUrl; let expectedUrl;
let apiResponse; let apiResponse;
let mockParams; let mockParams;
let mockReplicableType;
beforeEach(() => { beforeEach(() => {
expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/geo_replication/designs`; mockReplicableType = 'designs';
expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/geo_replication/${mockReplicableType}`;
}); });
describe('getGeoDesigns', () => { describe('getGeoReplicableItems', () => {
it('fetches designs', () => { it('fetches replicableItems based on replicableType', () => {
apiResponse = [{ id: 1, name: 'foo' }, { id: 2, name: 'bar' }]; apiResponse = [{ id: 1, name: 'foo' }, { id: 2, name: 'bar' }];
mockParams = { page: 1 }; mockParams = { page: 1 };
...@@ -568,14 +570,14 @@ describe('Api', () => { ...@@ -568,14 +570,14 @@ describe('Api', () => {
jest.spyOn(axios, 'get'); jest.spyOn(axios, 'get');
mock.onGet(expectedUrl).replyOnce(200, apiResponse); mock.onGet(expectedUrl).replyOnce(200, apiResponse);
return Api.getGeoDesigns(mockParams).then(({ data }) => { return Api.getGeoReplicableItems(mockReplicableType, mockParams).then(({ data }) => {
expect(data).toEqual(apiResponse); expect(data).toEqual(apiResponse);
expect(axios.get).toHaveBeenCalledWith(expectedUrl, { params: mockParams }); expect(axios.get).toHaveBeenCalledWith(expectedUrl, { params: mockParams });
}); });
}); });
}); });
describe('initiateAllGeoDesignSyncs', () => { describe('initiateAllGeoReplicableSyncs', () => {
it('POSTs with correct action', () => { it('POSTs with correct action', () => {
apiResponse = [{ status: 'ok' }]; apiResponse = [{ status: 'ok' }];
mockParams = {}; mockParams = {};
...@@ -586,14 +588,16 @@ describe('Api', () => { ...@@ -586,14 +588,16 @@ describe('Api', () => {
jest.spyOn(axios, 'post'); jest.spyOn(axios, 'post');
mock.onPost(`${expectedUrl}/${mockAction}`).replyOnce(201, apiResponse); mock.onPost(`${expectedUrl}/${mockAction}`).replyOnce(201, apiResponse);
return Api.initiateAllGeoDesignSyncs(mockAction).then(({ data }) => { return Api.initiateAllGeoReplicableSyncs(mockReplicableType, mockAction).then(
expect(data).toEqual(apiResponse); ({ data }) => {
expect(axios.post).toHaveBeenCalledWith(`${expectedUrl}/${mockAction}`, mockParams); expect(data).toEqual(apiResponse);
}); expect(axios.post).toHaveBeenCalledWith(`${expectedUrl}/${mockAction}`, mockParams);
},
);
}); });
}); });
describe('initiateGeoDesignSync', () => { describe('initiateGeoReplicableSync', () => {
it('PUTs with correct action and projectId', () => { it('PUTs with correct action and projectId', () => {
apiResponse = [{ status: 'ok' }]; apiResponse = [{ status: 'ok' }];
mockParams = {}; mockParams = {};
...@@ -605,15 +609,16 @@ describe('Api', () => { ...@@ -605,15 +609,16 @@ describe('Api', () => {
jest.spyOn(axios, 'put'); jest.spyOn(axios, 'put');
mock.onPut(`${expectedUrl}/${mockProjectId}/${mockAction}`).replyOnce(201, apiResponse); mock.onPut(`${expectedUrl}/${mockProjectId}/${mockAction}`).replyOnce(201, apiResponse);
return Api.initiateGeoDesignSync({ projectId: mockProjectId, action: mockAction }).then( return Api.initiateGeoReplicableSync(mockReplicableType, {
({ data }) => { projectId: mockProjectId,
expect(data).toEqual(apiResponse); action: mockAction,
expect(axios.put).toHaveBeenCalledWith( }).then(({ data }) => {
`${expectedUrl}/${mockProjectId}/${mockAction}`, expect(data).toEqual(apiResponse);
mockParams, expect(axios.put).toHaveBeenCalledWith(
); `${expectedUrl}/${mockProjectId}/${mockAction}`,
}, mockParams,
); );
});
}); });
}); });
}); });
......
...@@ -10,7 +10,6 @@ import { ...@@ -10,7 +10,6 @@ import {
MOCK_GEO_SVG_PATH, MOCK_GEO_SVG_PATH,
MOCK_ISSUES_SVG_PATH, MOCK_ISSUES_SVG_PATH,
MOCK_GEO_TROUBLESHOOTING_LINK, MOCK_GEO_TROUBLESHOOTING_LINK,
MOCK_DESIGN_MANAGEMENT_LINK,
MOCK_BASIC_FETCH_DATA_MAP, MOCK_BASIC_FETCH_DATA_MAP,
} from '../mock_data'; } from '../mock_data';
...@@ -24,7 +23,6 @@ describe('GeoDesignsApp', () => { ...@@ -24,7 +23,6 @@ describe('GeoDesignsApp', () => {
geoSvgPath: MOCK_GEO_SVG_PATH, geoSvgPath: MOCK_GEO_SVG_PATH,
issuesSvgPath: MOCK_ISSUES_SVG_PATH, issuesSvgPath: MOCK_ISSUES_SVG_PATH,
geoTroubleshootingLink: MOCK_GEO_TROUBLESHOOTING_LINK, geoTroubleshootingLink: MOCK_GEO_TROUBLESHOOTING_LINK,
designManagementLink: MOCK_DESIGN_MANAGEMENT_LINK,
}; };
const actionSpies = { const actionSpies = {
......
...@@ -7,8 +7,7 @@ export const MOCK_ISSUES_SVG_PATH = 'illustrations/issues.svg'; ...@@ -7,8 +7,7 @@ export const MOCK_ISSUES_SVG_PATH = 'illustrations/issues.svg';
export const MOCK_GEO_TROUBLESHOOTING_LINK = export const MOCK_GEO_TROUBLESHOOTING_LINK =
'https://docs.gitlab.com/ee/administration/geo/replication/troubleshooting.html'; 'https://docs.gitlab.com/ee/administration/geo/replication/troubleshooting.html';
export const MOCK_DESIGN_MANAGEMENT_LINK = export const MOCK_REPLICABLE_TYPE = 'designs';
'https://docs.gitlab.com/ee/user/project/issues/design_management.html';
export const MOCK_BASIC_FETCH_RESPONSE = { export const MOCK_BASIC_FETCH_RESPONSE = {
data: [ data: [
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
MOCK_BASIC_FETCH_DATA_MAP, MOCK_BASIC_FETCH_DATA_MAP,
MOCK_BASIC_FETCH_RESPONSE, MOCK_BASIC_FETCH_RESPONSE,
MOCK_BASIC_POST_RESPONSE, MOCK_BASIC_POST_RESPONSE,
MOCK_REPLICABLE_TYPE,
} from '../mock_data'; } from '../mock_data';
jest.mock('~/flash'); jest.mock('~/flash');
...@@ -21,7 +22,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -21,7 +22,7 @@ describe('GeoDesigns Store Actions', () => {
let mock; let mock;
beforeEach(() => { beforeEach(() => {
state = createState(); state = createState(MOCK_REPLICABLE_TYPE);
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
}); });
...@@ -79,7 +80,13 @@ describe('GeoDesigns Store Actions', () => { ...@@ -79,7 +80,13 @@ describe('GeoDesigns Store Actions', () => {
.replyOnce(200, MOCK_BASIC_FETCH_RESPONSE.data, MOCK_BASIC_FETCH_RESPONSE.headers); .replyOnce(200, MOCK_BASIC_FETCH_RESPONSE.data, MOCK_BASIC_FETCH_RESPONSE.headers);
}); });
it('should dispatch the request and success actions', done => { it('should dispatch the request with correct replicable param and success actions', () => {
function fetchReplicableItemsCall() {
const callHistory = mock.history.get[0];
expect(callHistory.url).toContain(`/geo_replication/${MOCK_REPLICABLE_TYPE}`);
}
testAction( testAction(
actions.fetchDesigns, actions.fetchDesigns,
{}, {},
...@@ -89,7 +96,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -89,7 +96,7 @@ describe('GeoDesigns Store Actions', () => {
{ type: 'requestReplicableItems' }, { type: 'requestReplicableItems' },
{ type: 'receiveReplicableItemsSuccess', payload: MOCK_BASIC_FETCH_DATA_MAP }, { type: 'receiveReplicableItemsSuccess', payload: MOCK_BASIC_FETCH_DATA_MAP },
], ],
done, fetchReplicableItemsCall,
); );
}); });
}); });
...@@ -120,12 +127,13 @@ describe('GeoDesigns Store Actions', () => { ...@@ -120,12 +127,13 @@ describe('GeoDesigns Store Actions', () => {
}); });
describe('no params set', () => { describe('no params set', () => {
it('should call fetchDesigns with default queryParams', () => { it('should call fetchDesigns with default queryParams and correct replicable params', () => {
state.isLoading = true; state.isLoading = true;
function fetchDesignsCall() { function fetchReplicableItemsCall() {
const callHistory = mock.history.get[0]; const callHistory = mock.history.get[0];
expect(callHistory.url).toContain(`/geo_replication/${MOCK_REPLICABLE_TYPE}`);
expect(callHistory.params.page).toEqual(1); expect(callHistory.params.page).toEqual(1);
expect(callHistory.params.search).toBeNull(); expect(callHistory.params.search).toBeNull();
expect(callHistory.params.sync_status).toBeNull(); expect(callHistory.params.sync_status).toBeNull();
...@@ -140,7 +148,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -140,7 +148,7 @@ describe('GeoDesigns Store Actions', () => {
{ type: 'requestReplicableItems' }, { type: 'requestReplicableItems' },
{ type: 'receiveReplicableItemsSuccess', payload: MOCK_BASIC_FETCH_DATA_MAP }, { type: 'receiveReplicableItemsSuccess', payload: MOCK_BASIC_FETCH_DATA_MAP },
], ],
fetchDesignsCall, fetchReplicableItemsCall,
); );
}); });
}); });
...@@ -152,9 +160,10 @@ describe('GeoDesigns Store Actions', () => { ...@@ -152,9 +160,10 @@ describe('GeoDesigns Store Actions', () => {
state.searchFilter = 'test search'; state.searchFilter = 'test search';
state.currentFilterIndex = 2; state.currentFilterIndex = 2;
function fetchDesignsCall() { function fetchReplicableItemsCall() {
const callHistory = mock.history.get[0]; const callHistory = mock.history.get[0];
expect(callHistory.url).toContain(`/geo_replication/${MOCK_REPLICABLE_TYPE}`);
expect(callHistory.params.page).toEqual(state.currentPage); expect(callHistory.params.page).toEqual(state.currentPage);
expect(callHistory.params.search).toEqual(state.searchFilter); expect(callHistory.params.search).toEqual(state.searchFilter);
expect(callHistory.params.sync_status).toEqual( expect(callHistory.params.sync_status).toEqual(
...@@ -171,7 +180,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -171,7 +180,7 @@ describe('GeoDesigns Store Actions', () => {
{ type: 'requestReplicableItems' }, { type: 'requestReplicableItems' },
{ type: 'receiveReplicableItemsSuccess', payload: MOCK_BASIC_FETCH_DATA_MAP }, { type: 'receiveReplicableItemsSuccess', payload: MOCK_BASIC_FETCH_DATA_MAP },
], ],
fetchDesignsCall, fetchReplicableItemsCall,
); );
}); });
}); });
...@@ -191,13 +200,13 @@ describe('GeoDesigns Store Actions', () => { ...@@ -191,13 +200,13 @@ describe('GeoDesigns Store Actions', () => {
}); });
describe('receiveInitiateAllReplicableSyncsSuccess', () => { describe('receiveInitiateAllReplicableSyncsSuccess', () => {
it('should commit mutation RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS and call fetchReplicableItems and toast', () => { it('should commit mutation RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS and call fetchDesigns and toast', () => {
testAction( testAction(
actions.receiveInitiateAllReplicableSyncsSuccess, actions.receiveInitiateAllReplicableSyncsSuccess,
{ action: ACTION_TYPES.RESYNC }, { action: ACTION_TYPES.RESYNC },
state, state,
[{ type: types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS }], [{ type: types.RECEIVE_INITIATE_ALL_REPLICABLE_SYNCS_SUCCESS }],
[{ type: 'fetchReplicableItems' }], [{ type: 'fetchDesigns' }],
() => { () => {
expect(toast).toHaveBeenCalledTimes(1); expect(toast).toHaveBeenCalledTimes(1);
toast.mockClear(); toast.mockClear();
...@@ -232,7 +241,13 @@ describe('GeoDesigns Store Actions', () => { ...@@ -232,7 +241,13 @@ describe('GeoDesigns Store Actions', () => {
mock.onPost().replyOnce(201, MOCK_BASIC_POST_RESPONSE); mock.onPost().replyOnce(201, MOCK_BASIC_POST_RESPONSE);
}); });
it('should dispatch the request and success actions', done => { it('should dispatch the request with correct replicable param and success actions', () => {
function fetchReplicableItemsCall() {
const callHistory = mock.history.post[0];
expect(callHistory.url).toContain(`/geo_replication/${MOCK_REPLICABLE_TYPE}`);
}
testAction( testAction(
actions.initiateAllDesignSyncs, actions.initiateAllDesignSyncs,
action, action,
...@@ -242,7 +257,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -242,7 +257,7 @@ describe('GeoDesigns Store Actions', () => {
{ type: 'requestInitiateAllReplicableSyncs' }, { type: 'requestInitiateAllReplicableSyncs' },
{ type: 'receiveInitiateAllReplicableSyncsSuccess', payload: { action } }, { type: 'receiveInitiateAllReplicableSyncsSuccess', payload: { action } },
], ],
done, fetchReplicableItemsCall,
); );
}); });
}); });
...@@ -284,13 +299,13 @@ describe('GeoDesigns Store Actions', () => { ...@@ -284,13 +299,13 @@ describe('GeoDesigns Store Actions', () => {
}); });
describe('receiveInitiateReplicableSyncSuccess', () => { describe('receiveInitiateReplicableSyncSuccess', () => {
it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS and call fetchReplicableItems and toast', () => { it('should commit mutation RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS and call fetchDesigns and toast', () => {
testAction( testAction(
actions.receiveInitiateReplicableSyncSuccess, actions.receiveInitiateReplicableSyncSuccess,
{ action: ACTION_TYPES.RESYNC, projectName: 'test' }, { action: ACTION_TYPES.RESYNC, projectName: 'test' },
state, state,
[{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS }], [{ type: types.RECEIVE_INITIATE_REPLICABLE_SYNC_SUCCESS }],
[{ type: 'fetchReplicableItems' }], [{ type: 'fetchDesigns' }],
() => { () => {
expect(toast).toHaveBeenCalledTimes(1); expect(toast).toHaveBeenCalledTimes(1);
toast.mockClear(); toast.mockClear();
...@@ -329,7 +344,13 @@ describe('GeoDesigns Store Actions', () => { ...@@ -329,7 +344,13 @@ describe('GeoDesigns Store Actions', () => {
mock.onPut().replyOnce(201, MOCK_BASIC_POST_RESPONSE); mock.onPut().replyOnce(201, MOCK_BASIC_POST_RESPONSE);
}); });
it('should dispatch the request and success actions', done => { it('should dispatch the request with correct replicable param and success actions', () => {
function fetchReplicableItemsCall() {
const callHistory = mock.history.put[0];
expect(callHistory.url).toContain(`/geo_replication/${MOCK_REPLICABLE_TYPE}`);
}
testAction( testAction(
actions.initiateDesignSync, actions.initiateDesignSync,
{ projectId, name, action }, { projectId, name, action },
...@@ -339,7 +360,7 @@ describe('GeoDesigns Store Actions', () => { ...@@ -339,7 +360,7 @@ describe('GeoDesigns Store Actions', () => {
{ type: 'requestInitiateReplicableSync' }, { type: 'requestInitiateReplicableSync' },
{ type: 'receiveInitiateReplicableSyncSuccess', payload: { name, action } }, { type: 'receiveInitiateReplicableSyncSuccess', payload: { name, action } },
], ],
done, fetchReplicableItemsCall,
); );
}); });
}); });
......
...@@ -363,6 +363,9 @@ msgstr "" ...@@ -363,6 +363,9 @@ msgstr ""
msgid "%{name} found %{resultsString}" msgid "%{name} found %{resultsString}"
msgstr "" msgstr ""
msgid "%{name} is scheduled for %{action}"
msgstr ""
msgid "%{name}'s avatar" msgid "%{name}'s avatar"
msgstr "" msgstr ""
...@@ -1585,6 +1588,9 @@ msgstr "" ...@@ -1585,6 +1588,9 @@ msgstr ""
msgid "All" msgid "All"
msgstr "" msgstr ""
msgid "All %{replicableType} are being scheduled for %{action}"
msgstr ""
msgid "All Members" msgid "All Members"
msgstr "" msgstr ""
...@@ -13127,7 +13133,7 @@ msgstr "" ...@@ -13127,7 +13133,7 @@ msgstr ""
msgid "No %{providerTitle} repositories found" msgid "No %{providerTitle} repositories found"
msgstr "" msgstr ""
msgid "No Design Repositories match this filter" msgid "No %{replicableType} match this filter"
msgstr "" msgstr ""
msgid "No Epic" msgid "No Epic"
...@@ -16866,7 +16872,7 @@ msgstr "" ...@@ -16866,7 +16872,7 @@ msgstr ""
msgid "Resync" msgid "Resync"
msgstr "" msgstr ""
msgid "Resync all designs" msgid "Resync all %{replicableType}"
msgstr "" msgstr ""
msgid "Retry" msgid "Retry"
...@@ -19986,10 +19992,10 @@ msgstr "" ...@@ -19986,10 +19992,10 @@ msgstr ""
msgid "There was an error fetching median data for stages" msgid "There was an error fetching median data for stages"
msgstr "" msgstr ""
msgid "There was an error fetching the Node's Groups" msgid "There was an error fetching the %{replicableType}"
msgstr "" msgstr ""
msgid "There was an error fetching the designs" msgid "There was an error fetching the Node's Groups"
msgstr "" msgstr ""
msgid "There was an error fetching the environments information." msgid "There was an error fetching the environments information."
...@@ -20034,7 +20040,10 @@ msgstr "" ...@@ -20034,7 +20040,10 @@ msgstr ""
msgid "There was an error subscribing to this label." msgid "There was an error subscribing to this label."
msgstr "" msgstr ""
msgid "There was an error syncing the designs." msgid "There was an error syncing project %{name}"
msgstr ""
msgid "There was an error syncing the %{replicableType}"
msgstr "" msgstr ""
msgid "There was an error trying to validate your query" msgid "There was an error trying to validate your query"
......
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