blob: 340f60258a074cb80b27d4e81d0f8d64fa5ff262 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import Api from '~/api';
import { deprecatedCreateFlash as createFlash } from '~/flash';
import { FETCH_PACKAGE_VERSIONS_ERROR } from '../constants';
import { DELETE_PACKAGE_ERROR_MESSAGE } from '~/packages/shared/constants';
import * as types from './mutation_types';
export const fetchPackageVersions = ({ commit, state }) => {
commit(types.SET_LOADING, true);
const { project_id, id } = state.packageEntity;
return Api.projectPackage(project_id, id)
.then(({ data }) => {
if (data.versions) {
commit(types.SET_PACKAGE_VERSIONS, data.versions.reverse());
}
})
.catch(() => {
createFlash(FETCH_PACKAGE_VERSIONS_ERROR);
})
.finally(() => {
commit(types.SET_LOADING, false);
});
};
export const deletePackage = ({
state: {
packageEntity: { project_id, id },
},
}) => {
return Api.deleteProjectPackage(project_id, id).catch(() => {
createFlash(DELETE_PACKAGE_ERROR_MESSAGE);
});
};
|