Skip to content
代码片段 群组 项目
未验证 提交 a2d7d99a 编辑于 作者: Andrew Fontaine's avatar Andrew Fontaine 提交者: GitLab
浏览文件

Merge branch '413642-redirect-if-envs-page-empty' into 'master'

No related branches found
No related tags found
无相关合并请求
......@@ -154,12 +154,16 @@ export const updateApproverInheritance = ({ commit }, { rule, value }) => {
export const editRule = ({ commit }, rule) => commit(types.EDIT_RULE, rule);
export const unprotectEnvironment = ({ state, commit }, environment) => {
export const unprotectEnvironment = ({ state, commit, dispatch }, environment) => {
commit(types.REQUEST_UPDATE_PROTECTED_ENVIRONMENT);
return Api.deleteProtectedEnvironment(state.projectId, environment)
.then(() => {
commit(types.DELETE_PROTECTED_ENVIRONMENT_SUCCESS, environment);
if (!state.protectedEnvironments.length && state.pageInfo.page > 1) {
dispatch('setPage', state.pageInfo.page - 1);
}
})
.catch((error) => {
commit(types.RECEIVE_UPDATE_PROTECTED_ENVIRONMENT_ERROR, error);
......
......@@ -426,5 +426,38 @@ describe('ee/protected_environments/store/edit/actions', () => {
[],
);
});
it('redirects to previous page after deleting if current page is empty', () => {
const environment = {
name: 'staging',
};
mockedState.pageInfo = {
page: 2,
nextPage: null,
previousPage: 1,
perPage: 10,
total: 11,
totalPages: 2,
};
mock.onDelete(url, environment).replyOnce(HTTP_STATUS_OK);
return testAction({
action: unprotectEnvironment,
payload: environment,
state: mockedState,
expectedMutations: [
{ type: types.REQUEST_UPDATE_PROTECTED_ENVIRONMENT },
{ type: types.DELETE_PROTECTED_ENVIRONMENT_SUCCESS, payload: environment },
],
expectedActions: [
{
type: 'setPage',
payload: 1,
},
],
});
});
});
});
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册