Skip to content
Snippets Groups Projects
Verified Commit af94c30a authored by Alex Pennells's avatar Alex Pennells :three: Committed by GitLab
Browse files

Merge branch '498945_02-add-restore-list-action-and-api' into 'master'

List Actions - Add support for Restore

See merge request !173467



Merged-by: default avatarAlex Pennells <apennells@gitlab.com>
Approved-by: default avatarJames Rushford <jrushford@gitlab.com>
Approved-by: default avatarAlex Pennells <apennells@gitlab.com>
Reviewed-by: Zack Cuddy's avatarZack Cuddy <zcuddy@gitlab.com>
Co-authored-by: Zack Cuddy's avatarZachary Cuddy <zcuddy@gitlab.com>
parents e0f80816 3ac721e3
No related branches found
No related tags found
1 merge request!173467List Actions - Add support for Restore
Pipeline #1556837877 passed
import { __ } from '~/locale';
export const ACTION_EDIT = 'edit';
export const ACTION_RESTORE = 'restore';
export const ACTION_DELETE = 'delete';
export const BASE_ACTIONS = {
[ACTION_EDIT]: {
text: __('Edit'),
order: 1,
},
[ACTION_RESTORE]: {
text: __('Restore'),
order: 2,
},
[ACTION_DELETE]: {
text: __('Delete'),
extraAttrs: {
class: '!gl-text-red-500',
},
order: 3,
},
};
import axios from '~/lib/utils/axios_utils';
import { buildApiUrl } from '~/api/api_utils';
const PROJECT_RESTORE_PATH = '/api/:version/projects/:id/restore';
export function restoreProject(projectId) {
const url = buildApiUrl(PROJECT_RESTORE_PATH).replace(':id', projectId);
return axios.post(url);
}
......@@ -2,3 +2,4 @@ export * from './api/groups_api';
export * from './api/subscriptions_api';
export * from './api/dora_api';
export * from './api/status_check_api';
export * from './api/projects_api';
import MockAdapter from 'axios-mock-adapter';
import * as projectsApi from 'ee/api/projects_api';
import axios from '~/lib/utils/axios_utils';
import { HTTP_STATUS_OK } from '~/lib/utils/http_status';
describe('ee/api/projects_api.js', () => {
let mock;
const projectId = 1;
beforeEach(() => {
mock = new MockAdapter(axios);
window.gon = { api_version: 'v7' };
});
afterEach(() => {
mock.restore();
});
describe('restoreProject', () => {
beforeEach(() => {
jest.spyOn(axios, 'post');
});
it('calls POST to the correct URL', () => {
const expectedUrl = `/api/v7/projects/${projectId}/restore`;
mock.onPost(expectedUrl).replyOnce(HTTP_STATUS_OK);
return projectsApi.restoreProject(projectId).then(() => {
expect(axios.post).toHaveBeenCalledWith(expectedUrl);
});
});
});
});
......@@ -37,6 +37,7 @@ describe('ListActions', () => {
{
text: 'Edit',
href: '/-/edit',
order: 1,
},
{
text: 'Delete',
......@@ -44,6 +45,7 @@ describe('ListActions', () => {
class: '!gl-text-red-500',
},
action: expect.any(Function),
order: 3,
},
]);
});
......@@ -68,6 +70,7 @@ describe('ListActions', () => {
{
text: 'Edit',
href: '/-/edit',
order: 1,
},
{
text: 'Leave project',
......@@ -79,6 +82,7 @@ describe('ListActions', () => {
class: '!gl-text-red-500',
},
action: expect.any(Function),
order: 3,
},
]);
});
......@@ -94,6 +98,7 @@ describe('ListActions', () => {
{
text: 'Edit',
href: '/-/edit',
order: 1,
},
]);
});
......@@ -112,10 +117,12 @@ describe('ListActions', () => {
class: '!gl-text-red-500',
},
action: expect.any(Function),
order: 3,
},
{
text: 'Edit',
href: '/-/edit',
order: 1,
},
]);
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment