2017-09-15 09:10:08 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import VueResource from 'vue-resource';
|
|
|
|
import * as types from './mutation_types';
|
|
|
|
|
|
|
|
Vue.use(VueResource);
|
|
|
|
|
|
|
|
export const fetchRepos = ({ commit, state }) => {
|
|
|
|
commit(types.TOGGLE_MAIN_LOADING);
|
|
|
|
|
2018-05-28 05:47:59 -04:00
|
|
|
return Vue.http
|
|
|
|
.get(state.endpoint)
|
2017-09-15 09:10:08 -04:00
|
|
|
.then(res => res.json())
|
2018-05-28 05:47:59 -04:00
|
|
|
.then(response => {
|
2017-09-15 09:10:08 -04:00
|
|
|
commit(types.TOGGLE_MAIN_LOADING);
|
|
|
|
commit(types.SET_REPOS_LIST, response);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-09-22 06:46:55 -04:00
|
|
|
export const fetchList = ({ commit }, { repo, page }) => {
|
|
|
|
commit(types.TOGGLE_REGISTRY_LIST_LOADING, repo);
|
2017-09-15 09:10:08 -04:00
|
|
|
|
2018-05-28 05:47:59 -04:00
|
|
|
return Vue.http.get(repo.tagsPath, { params: { page } }).then(response => {
|
2018-06-16 17:50:13 -04:00
|
|
|
const { headers } = response;
|
2017-09-22 06:46:55 -04:00
|
|
|
|
2018-05-28 05:47:59 -04:00
|
|
|
return response.json().then(resp => {
|
|
|
|
commit(types.TOGGLE_REGISTRY_LIST_LOADING, repo);
|
|
|
|
commit(types.SET_REGISTRY_LIST, { repo, resp, headers });
|
2017-09-15 09:10:08 -04:00
|
|
|
});
|
2018-05-28 05:47:59 -04:00
|
|
|
});
|
2017-09-15 09:10:08 -04:00
|
|
|
};
|
|
|
|
|
2018-05-28 05:53:00 -04:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
export const deleteRepo = ({ commit }, repo) => Vue.http.delete(repo.destroyPath);
|
2017-09-15 09:10:08 -04:00
|
|
|
|
2018-05-28 05:53:00 -04:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
export const deleteRegistry = ({ commit }, image) => Vue.http.delete(image.destroyPath);
|
2017-09-19 11:38:55 -04:00
|
|
|
|
|
|
|
export const setMainEndpoint = ({ commit }, data) => commit(types.SET_MAIN_ENDPOINT, data);
|
2017-09-20 14:03:53 -04:00
|
|
|
export const toggleLoading = ({ commit }) => commit(types.TOGGLE_MAIN_LOADING);
|
2018-04-13 19:27:16 -04:00
|
|
|
|
|
|
|
// prevent babel-plugin-rewire from generating an invalid default during karma tests
|
|
|
|
export default () => {};
|