Commit d815f168 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera Committed by Andrew Fontaine

Move package components to infra registry

parent f72f9462
import Vue from 'vue';
import Translate from '~/vue_shared/translate';
import PackagesListApp from './components/packages_list_app.vue';
import { createStore } from './stores';
Vue.use(Translate);
export default () => {
const el = document.getElementById('js-vue-packages-list');
const store = createStore();
store.dispatch('setInitialState', el.dataset);
return new Vue({
el,
store,
components: {
PackagesListApp,
},
render(createElement) {
return createElement('packages-list-app');
},
});
};
...@@ -16,7 +16,7 @@ import { s__, __ } from '~/locale'; ...@@ -16,7 +16,7 @@ import { s__, __ } from '~/locale';
import TerraformTitle from '~/packages_and_registries/infrastructure_registry/details/components/details_title.vue'; import TerraformTitle from '~/packages_and_registries/infrastructure_registry/details/components/details_title.vue';
import TerraformInstallation from '~/packages_and_registries/infrastructure_registry/details/components/terraform_installation.vue'; import TerraformInstallation from '~/packages_and_registries/infrastructure_registry/details/components/terraform_installation.vue';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import PackageListRow from '~/packages/shared/components/package_list_row.vue'; import PackageListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue';
import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue'; import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue';
import { TrackingActions, SHOW_DELETE_SUCCESS_ALERT } from '~/packages/shared/constants'; import { TrackingActions, SHOW_DELETE_SUCCESS_ALERT } from '~/packages/shared/constants';
import { packageTypeToTrackCategory } from '~/packages/shared/utils'; import { packageTypeToTrackCategory } from '~/packages/shared/utils';
......
...@@ -3,10 +3,10 @@ import { GlPagination, GlModal, GlSprintf } from '@gitlab/ui'; ...@@ -3,10 +3,10 @@ import { GlPagination, GlModal, GlSprintf } from '@gitlab/ui';
import { mapState, mapGetters } from 'vuex'; import { mapState, mapGetters } from 'vuex';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import PackagesListRow from '../../shared/components/package_list_row.vue'; import PackagesListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue';
import PackagesListLoader from '../../shared/components/packages_list_loader.vue'; import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue';
import { TrackingActions } from '../../shared/constants'; import { TrackingActions } from '~/packages/shared/constants';
import { packageTypeToTrackCategory } from '../../shared/utils'; import { packageTypeToTrackCategory } from '~/packages/shared/utils';
export default { export default {
components: { components: {
......
...@@ -7,10 +7,10 @@ import { s__ } from '~/locale'; ...@@ -7,10 +7,10 @@ import { s__ } from '~/locale';
import { SHOW_DELETE_SUCCESS_ALERT } from '~/packages/shared/constants'; import { SHOW_DELETE_SUCCESS_ALERT } from '~/packages/shared/constants';
import { FILTERED_SEARCH_TERM } from '~/packages_and_registries/shared/constants'; import { FILTERED_SEARCH_TERM } from '~/packages_and_registries/shared/constants';
import { getQueryParams, extractFilterAndSorting } from '~/packages_and_registries/shared/utils'; import { getQueryParams, extractFilterAndSorting } from '~/packages_and_registries/shared/utils';
import InfrastructureTitle from '~/packages_and_registries/infrastructure_registry/components/infrastructure_title.vue'; import InfrastructureTitle from '~/packages_and_registries/infrastructure_registry/list/components/infrastructure_title.vue';
import InfrastructureSearch from '~/packages_and_registries/infrastructure_registry/components/infrastructure_search.vue'; import InfrastructureSearch from '~/packages_and_registries/infrastructure_registry/list/components/infrastructure_search.vue';
import { DELETE_PACKAGE_SUCCESS_MESSAGE } from '../constants'; import PackageList from '~/packages_and_registries/infrastructure_registry/list/components/packages_list.vue';
import PackageList from './packages_list.vue'; import { DELETE_PACKAGE_SUCCESS_MESSAGE } from '~/packages/list/constants';
export default { export default {
components: { components: {
......
import Vue from 'vue'; import Vue from 'vue';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import PackagesListApp from '~/packages/list/components/packages_list_app.vue'; import PackagesListApp from '~/packages_and_registries/infrastructure_registry/list/components/packages_list_app.vue';
import { createStore } from '~/packages/list/stores'; import { createStore } from '~/packages/list/stores';
import Translate from '~/vue_shared/translate'; import Translate from '~/vue_shared/translate';
...@@ -18,9 +18,6 @@ export default () => { ...@@ -18,9 +18,6 @@ export default () => {
PackagesListApp, PackagesListApp,
}, },
provide: { provide: {
titleComponent: 'InfrastructureTitle',
searchComponent: 'InfrastructureSearch',
iconComponent: 'InfrastructureIconAndName',
emptyPageTitle: s__('InfrastructureRegistry|You have no Terraform modules in your project'), emptyPageTitle: s__('InfrastructureRegistry|You have no Terraform modules in your project'),
noResultsText: s__( noResultsText: s__(
'InfrastructureRegistry|Terraform modules are the main way to package and reuse resource configurations with Terraform. Learn more about how to %{noPackagesLinkStart}create Terraform modules%{noPackagesLinkEnd} in GitLab.', 'InfrastructureRegistry|Terraform modules are the main way to package and reuse resource configurations with Terraform. Learn more about how to %{noPackagesLinkStart}create Terraform modules%{noPackagesLinkEnd} in GitLab.',
......
...@@ -3,11 +3,12 @@ import { GlButton, GlLink, GlSprintf, GlTooltipDirective, GlTruncate } from '@gi ...@@ -3,11 +3,12 @@ import { GlButton, GlLink, GlSprintf, GlTooltipDirective, GlTruncate } from '@gi
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import ListItem from '~/vue_shared/components/registry/list_item.vue'; import ListItem from '~/vue_shared/components/registry/list_item.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago'; import timeagoMixin from '~/vue_shared/mixins/timeago';
import { PACKAGE_ERROR_STATUS, PACKAGE_DEFAULT_STATUS } from '../constants'; import { PACKAGE_ERROR_STATUS, PACKAGE_DEFAULT_STATUS } from '~/packages/shared/constants';
import { getPackageTypeLabel } from '../utils'; import { getPackageTypeLabel } from '~/packages/shared/utils';
import PackagePath from './package_path.vue'; import PackagePath from '~/packages/shared/components/package_path.vue';
import PackageTags from './package_tags.vue'; import PackageTags from '~/packages/shared/components/package_tags.vue';
import PublishMethod from './publish_method.vue'; import PublishMethod from '~/packages/shared/components/publish_method.vue';
import InfrastructureIconAndName from '~/packages_and_registries/infrastructure_registry/shared/infrastructure_icon_and_name.vue';
export default { export default {
name: 'PackageListRow', name: 'PackageListRow',
...@@ -20,23 +21,12 @@ export default { ...@@ -20,23 +21,12 @@ export default {
PackagePath, PackagePath,
PublishMethod, PublishMethod,
ListItem, ListItem,
PackageIconAndName: () => InfrastructureIconAndName,
import(/* webpackChunkName: 'package_registry_components' */ './package_icon_and_name.vue'),
InfrastructureIconAndName: () =>
import(
/* webpackChunkName: 'infrastructure_registry_components' */ '~/packages_and_registries/infrastructure_registry/components/infrastructure_icon_and_name.vue'
),
}, },
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
}, },
mixins: [timeagoMixin], mixins: [timeagoMixin],
inject: {
iconComponent: {
from: 'iconComponent',
default: 'PackageIconAndName',
},
},
props: { props: {
packageEntity: { packageEntity: {
type: Object, type: Object,
...@@ -130,9 +120,9 @@ export default { ...@@ -130,9 +120,9 @@ export default {
</gl-sprintf> </gl-sprintf>
</div> </div>
<component :is="iconComponent" v-if="showPackageType"> <infrastructure-icon-and-name v-if="showPackageType">
{{ packageType }} {{ packageType }}
</component> </infrastructure-icon-and-name>
<package-path <package-path
v-if="hasProjectLink" v-if="hasProjectLink"
......
...@@ -5,7 +5,7 @@ module QA ...@@ -5,7 +5,7 @@ module QA
module Project module Project
module Packages module Packages
class Index < QA::Page::Base class Index < QA::Page::Base
view 'app/assets/javascripts/packages/shared/components/package_list_row.vue' do view 'app/assets/javascripts/packages_and_registries/package_registry/components/list/package_list_row.vue' do
element :package_row element :package_row
element :package_link element :package_link
end end
......
...@@ -9,7 +9,7 @@ import PackagesApp from '~/packages_and_registries/infrastructure_registry/detai ...@@ -9,7 +9,7 @@ import PackagesApp from '~/packages_and_registries/infrastructure_registry/detai
import PackageFiles from '~/packages_and_registries/infrastructure_registry/details/components/package_files.vue'; import PackageFiles from '~/packages_and_registries/infrastructure_registry/details/components/package_files.vue';
import PackageHistory from '~/packages_and_registries/infrastructure_registry/details/components/package_history.vue'; import PackageHistory from '~/packages_and_registries/infrastructure_registry/details/components/package_history.vue';
import * as getters from '~/packages_and_registries/infrastructure_registry/details/store/getters'; import * as getters from '~/packages_and_registries/infrastructure_registry/details/store/getters';
import PackageListRow from '~/packages/shared/components/package_list_row.vue'; import PackageListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue';
import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue'; import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue';
import { TrackingActions } from '~/packages/shared/constants'; import { TrackingActions } from '~/packages/shared/constants';
import * as SharedUtils from '~/packages/shared/utils'; import * as SharedUtils from '~/packages/shared/utils';
......
import { shallowMount, createLocalVue } from '@vue/test-utils'; import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import component from '~/packages_and_registries/infrastructure_registry/components/infrastructure_search.vue'; import component from '~/packages_and_registries/infrastructure_registry/list/components/infrastructure_search.vue';
import RegistrySearch from '~/vue_shared/components/registry/registry_search.vue'; import RegistrySearch from '~/vue_shared/components/registry/registry_search.vue';
import UrlSync from '~/vue_shared/components/url_sync.vue'; import UrlSync from '~/vue_shared/components/url_sync.vue';
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import component from '~/packages_and_registries/infrastructure_registry/components/infrastructure_title.vue'; import component from '~/packages_and_registries/infrastructure_registry/list/components/infrastructure_title.vue';
import MetadataItem from '~/vue_shared/components/registry/metadata_item.vue'; import MetadataItem from '~/vue_shared/components/registry/metadata_item.vue';
import TitleArea from '~/vue_shared/components/registry/title_area.vue'; import TitleArea from '~/vue_shared/components/registry/title_area.vue';
......
...@@ -4,12 +4,12 @@ import Vuex from 'vuex'; ...@@ -4,12 +4,12 @@ import Vuex from 'vuex';
import setWindowLocation from 'helpers/set_window_location_helper'; import setWindowLocation from 'helpers/set_window_location_helper';
import createFlash from '~/flash'; import createFlash from '~/flash';
import * as commonUtils from '~/lib/utils/common_utils'; import * as commonUtils from '~/lib/utils/common_utils';
import PackageListApp from '~/packages/list/components/packages_list_app.vue'; import PackageListApp from '~/packages_and_registries/infrastructure_registry/list/components/packages_list_app.vue';
import { DELETE_PACKAGE_SUCCESS_MESSAGE } from '~/packages/list/constants'; import { DELETE_PACKAGE_SUCCESS_MESSAGE } from '~/packages/list/constants';
import { SHOW_DELETE_SUCCESS_ALERT } from '~/packages/shared/constants'; import { SHOW_DELETE_SUCCESS_ALERT } from '~/packages/shared/constants';
import { FILTERED_SEARCH_TERM } from '~/packages_and_registries/shared/constants'; import { FILTERED_SEARCH_TERM } from '~/packages_and_registries/shared/constants';
import * as packageUtils from '~/packages_and_registries/shared/utils'; import * as packageUtils from '~/packages_and_registries/shared/utils';
import InfrastructureSearch from '~/packages_and_registries/infrastructure_registry/components/infrastructure_search.vue'; import InfrastructureSearch from '~/packages_and_registries/infrastructure_registry/list/components/infrastructure_search.vue';
jest.mock('~/lib/utils/common_utils'); jest.mock('~/lib/utils/common_utils');
jest.mock('~/flash'); jest.mock('~/flash');
......
...@@ -3,13 +3,13 @@ import { mount, createLocalVue } from '@vue/test-utils'; ...@@ -3,13 +3,13 @@ import { mount, createLocalVue } from '@vue/test-utils';
import { last } from 'lodash'; import { last } from 'lodash';
import Vuex from 'vuex'; import Vuex from 'vuex';
import stubChildren from 'helpers/stub_children'; import stubChildren from 'helpers/stub_children';
import PackagesList from '~/packages/list/components/packages_list.vue'; import PackagesList from '~/packages_and_registries/infrastructure_registry/list/components/packages_list.vue';
import PackagesListRow from '~/packages/shared/components/package_list_row.vue'; import PackagesListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue';
import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue'; import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue';
import { TrackingActions } from '~/packages/shared/constants'; import { TrackingActions } from '~/packages/shared/constants';
import * as SharedUtils from '~/packages/shared/utils'; import * as SharedUtils from '~/packages/shared/utils';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import { packageList } from '../../mock_data'; import { packageList } from '../../../../../packages/mock_data';
const localVue = createLocalVue(); const localVue = createLocalVue();
localVue.use(Vuex); localVue.use(Vuex);
......
import { GlIcon } from '@gitlab/ui'; import { GlIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import InfrastructureIconAndName from '~/packages_and_registries/infrastructure_registry/components/infrastructure_icon_and_name.vue'; import InfrastructureIconAndName from '~/packages_and_registries/infrastructure_registry/shared/infrastructure_icon_and_name.vue';
describe('InfrastructureIconAndName', () => { describe('InfrastructureIconAndName', () => {
let wrapper; let wrapper;
......
...@@ -2,13 +2,13 @@ import { GlLink } from '@gitlab/ui'; ...@@ -2,13 +2,13 @@ import { GlLink } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import PackagesListRow from '~/packages/shared/components/package_list_row.vue'; import PackagesListRow from '~/packages_and_registries/infrastructure_registry/shared/package_list_row.vue';
import PackagePath from '~/packages/shared/components/package_path.vue'; import PackagePath from '~/packages/shared/components/package_path.vue';
import PackageTags from '~/packages/shared/components/package_tags.vue'; import PackageTags from '~/packages/shared/components/package_tags.vue';
import { PACKAGE_ERROR_STATUS } from '~/packages/shared/constants'; import { PACKAGE_ERROR_STATUS } from '~/packages/shared/constants';
import ListItem from '~/vue_shared/components/registry/list_item.vue'; import ListItem from '~/vue_shared/components/registry/list_item.vue';
import { packageList } from '../../mock_data'; import { packageList } from '../../../../packages/mock_data';
describe('packages_list_row', () => { describe('packages_list_row', () => {
let wrapper; let wrapper;
...@@ -17,12 +17,10 @@ describe('packages_list_row', () => { ...@@ -17,12 +17,10 @@ describe('packages_list_row', () => {
const [packageWithoutTags, packageWithTags] = packageList; const [packageWithoutTags, packageWithTags] = packageList;
const InfrastructureIconAndName = { name: 'InfrastructureIconAndName', template: '<div></div>' }; const InfrastructureIconAndName = { name: 'InfrastructureIconAndName', template: '<div></div>' };
const PackageIconAndName = { name: 'PackageIconAndName', template: '<div></div>' };
const findPackageTags = () => wrapper.findComponent(PackageTags); const findPackageTags = () => wrapper.findComponent(PackageTags);
const findPackagePath = () => wrapper.findComponent(PackagePath); const findPackagePath = () => wrapper.findComponent(PackagePath);
const findDeleteButton = () => wrapper.findByTestId('action-delete'); const findDeleteButton = () => wrapper.findByTestId('action-delete');
const findPackageIconAndName = () => wrapper.findComponent(PackageIconAndName);
const findInfrastructureIconAndName = () => wrapper.findComponent(InfrastructureIconAndName); const findInfrastructureIconAndName = () => wrapper.findComponent(InfrastructureIconAndName);
const findListItem = () => wrapper.findComponent(ListItem); const findListItem = () => wrapper.findComponent(ListItem);
const findPackageLink = () => wrapper.findComponent(GlLink); const findPackageLink = () => wrapper.findComponent(GlLink);
...@@ -41,7 +39,6 @@ describe('packages_list_row', () => { ...@@ -41,7 +39,6 @@ describe('packages_list_row', () => {
stubs: { stubs: {
ListItem, ListItem,
InfrastructureIconAndName, InfrastructureIconAndName,
PackageIconAndName,
}, },
propsData: { propsData: {
packageLink: 'foo', packageLink: 'foo',
...@@ -93,13 +90,13 @@ describe('packages_list_row', () => { ...@@ -93,13 +90,13 @@ describe('packages_list_row', () => {
it('shows the type when set', () => { it('shows the type when set', () => {
mountComponent(); mountComponent();
expect(findPackageIconAndName().exists()).toBe(true); expect(findInfrastructureIconAndName().exists()).toBe(true);
}); });
it('does not show the type when not set', () => { it('does not show the type when not set', () => {
mountComponent({ showPackageType: false }); mountComponent({ showPackageType: false });
expect(findPackageIconAndName().exists()).toBe(false); expect(findInfrastructureIconAndName().exists()).toBe(false);
}); });
}); });
...@@ -135,27 +132,6 @@ describe('packages_list_row', () => { ...@@ -135,27 +132,6 @@ describe('packages_list_row', () => {
}); });
}); });
describe('Infrastructure config', () => {
it('defaults to package registry components', () => {
mountComponent();
expect(findPackageIconAndName().exists()).toBe(true);
expect(findInfrastructureIconAndName().exists()).toBe(false);
});
it('mounts different component based on the provided values', () => {
mountComponent({
provide: {
iconComponent: 'InfrastructureIconAndName',
},
});
expect(findPackageIconAndName().exists()).toBe(false);
expect(findInfrastructureIconAndName().exists()).toBe(true);
});
});
describe(`when the package is in ${PACKAGE_ERROR_STATUS} status`, () => { describe(`when the package is in ${PACKAGE_ERROR_STATUS} status`, () => {
beforeEach(() => { beforeEach(() => {
mountComponent({ packageEntity: { ...packageWithoutTags, status: PACKAGE_ERROR_STATUS } }); mountComponent({ packageEntity: { ...packageWithoutTags, status: PACKAGE_ERROR_STATUS } });
......
import { GlKeysetPagination, GlModal, GlSprintf } from '@gitlab/ui'; import { GlKeysetPagination, GlModal, GlSprintf } from '@gitlab/ui';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import PackagesListRow from '~/packages/shared/components/package_list_row.vue'; import PackagesListRow from '~/packages_and_registries/package_registry/components/list/package_list_row.vue';
import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue'; import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue';
import { import {
DELETE_PACKAGE_TRACKING_ACTION, DELETE_PACKAGE_TRACKING_ACTION,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment