2020-04-22 19:07:51 +05:30
|
|
|
import { GlToast } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import Vue from 'vue';
|
2021-02-22 17:27:13 +05:30
|
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
2021-03-08 18:12:59 +05:30
|
|
|
import PerformancePlugin from '~/performance/vue_performance_plugin';
|
2021-03-11 19:13:27 +05:30
|
|
|
import Translate from '~/vue_shared/translate';
|
2020-03-13 15:44:24 +05:30
|
|
|
import RegistryBreadcrumb from './components/registry_breadcrumb.vue';
|
2021-02-22 17:27:13 +05:30
|
|
|
import { apolloProvider } from './graphql/index';
|
2021-03-11 19:13:27 +05:30
|
|
|
import RegistryExplorer from './pages/index.vue';
|
|
|
|
import createRouter from './router';
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
Vue.use(Translate);
|
2020-04-22 19:07:51 +05:30
|
|
|
Vue.use(GlToast);
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
Vue.use(PerformancePlugin, {
|
|
|
|
components: [
|
|
|
|
'RegistryListPage',
|
|
|
|
'ListHeader',
|
|
|
|
'ImageListRow',
|
|
|
|
'RegistryDetailsPage',
|
|
|
|
'DetailsHeader',
|
|
|
|
'TagsList',
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
export default () => {
|
|
|
|
const el = document.getElementById('js-container-registry');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
const {
|
|
|
|
endpoint,
|
|
|
|
expirationPolicy,
|
|
|
|
isGroupPage,
|
|
|
|
isAdmin,
|
|
|
|
showUnfinishedTagCleanupCallout,
|
|
|
|
...config
|
|
|
|
} = el.dataset;
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
// This is a mini state to help the breadcrumb have the correct name in the details page
|
|
|
|
const breadCrumbState = Vue.observable({
|
|
|
|
name: '',
|
|
|
|
updateName(value) {
|
|
|
|
this.name = value;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const router = createRouter(endpoint, breadCrumbState);
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
const attachMainComponent = () =>
|
|
|
|
new Vue({
|
|
|
|
el,
|
|
|
|
router,
|
2021-02-22 17:27:13 +05:30
|
|
|
apolloProvider,
|
2020-03-13 15:44:24 +05:30
|
|
|
components: {
|
|
|
|
RegistryExplorer,
|
|
|
|
},
|
2021-02-22 17:27:13 +05:30
|
|
|
provide() {
|
|
|
|
return {
|
|
|
|
breadCrumbState,
|
|
|
|
config: {
|
|
|
|
...config,
|
|
|
|
expirationPolicy: expirationPolicy ? JSON.parse(expirationPolicy) : undefined,
|
|
|
|
isGroupPage: parseBoolean(isGroupPage),
|
|
|
|
isAdmin: parseBoolean(isAdmin),
|
2021-03-11 19:13:27 +05:30
|
|
|
showUnfinishedTagCleanupCallout: parseBoolean(showUnfinishedTagCleanupCallout),
|
2021-02-22 17:27:13 +05:30
|
|
|
},
|
|
|
|
/* eslint-disable @gitlab/require-i18n-strings */
|
|
|
|
dockerBuildCommand: `docker build -t ${config.repositoryUrl} .`,
|
|
|
|
dockerPushCommand: `docker push ${config.repositoryUrl}`,
|
|
|
|
dockerLoginCommand: `docker login ${config.registryHostUrlWithPort}`,
|
|
|
|
/* eslint-enable @gitlab/require-i18n-strings */
|
|
|
|
};
|
|
|
|
},
|
2020-03-13 15:44:24 +05:30
|
|
|
render(createElement) {
|
|
|
|
return createElement('registry-explorer');
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const attachBreadcrumb = () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
const breadCrumbEls = document.querySelectorAll('nav .js-breadcrumbs-list li');
|
|
|
|
const breadCrumbEl = breadCrumbEls[breadCrumbEls.length - 1];
|
|
|
|
const crumbs = [breadCrumbEl.querySelector('h2')];
|
|
|
|
const nestedBreadcrumbEl = document.createElement('div');
|
|
|
|
breadCrumbEl.replaceChild(nestedBreadcrumbEl, breadCrumbEl.querySelector('h2'));
|
2020-03-13 15:44:24 +05:30
|
|
|
return new Vue({
|
2021-03-08 18:12:59 +05:30
|
|
|
el: nestedBreadcrumbEl,
|
2020-03-13 15:44:24 +05:30
|
|
|
router,
|
2021-02-22 17:27:13 +05:30
|
|
|
apolloProvider,
|
2020-03-13 15:44:24 +05:30
|
|
|
components: {
|
|
|
|
RegistryBreadcrumb,
|
|
|
|
},
|
|
|
|
render(createElement) {
|
2021-03-08 18:12:59 +05:30
|
|
|
// FIXME(@tnir): this is a workaround until the MR gets merged:
|
|
|
|
// https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48115
|
|
|
|
const parentEl = breadCrumbEl.parentElement.parentElement;
|
|
|
|
if (parentEl) {
|
|
|
|
parentEl.classList.remove('breadcrumbs-container');
|
|
|
|
parentEl.classList.add('gl-display-flex');
|
|
|
|
parentEl.classList.add('w-100');
|
|
|
|
}
|
|
|
|
// End of FIXME(@tnir)
|
2020-03-13 15:44:24 +05:30
|
|
|
return createElement('registry-breadcrumb', {
|
|
|
|
class: breadCrumbEl.className,
|
|
|
|
props: {
|
|
|
|
crumbs,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
return { attachBreadcrumb, attachMainComponent };
|
|
|
|
};
|