Commit 5b76787c authored by Mark Florian's avatar Mark Florian Committed by Illya Klymov

Remove feature flag from dependencies table

Part of [Clean up dependency_list_ui feature flag and old code
paths][1].

[1]: https://gitlab.com/gitlab-org/gitlab/-/issues/212867
parent 821efd72
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
import { cloneDeep } from 'lodash'; import { cloneDeep } from 'lodash';
import { GlBadge, GlIcon, GlLink, GlButton, GlSkeletonLoading, GlTable } from '@gitlab/ui'; import { GlBadge, GlIcon, GlLink, GlButton, GlSkeletonLoading, GlTable } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import DependenciesTableRow from './dependencies_table_row.vue';
import DependencyLicenseLinks from './dependency_license_links.vue'; import DependencyLicenseLinks from './dependency_license_links.vue';
import DependencyVulnerabilities from './dependency_vulnerabilities.vue'; import DependencyVulnerabilities from './dependency_vulnerabilities.vue';
...@@ -26,7 +24,6 @@ const tdClass = (value, key, item) => { ...@@ -26,7 +24,6 @@ const tdClass = (value, key, item) => {
export default { export default {
name: 'DependenciesTable', name: 'DependenciesTable',
components: { components: {
DependenciesTableRow,
DependencyLicenseLinks, DependencyLicenseLinks,
DependencyVulnerabilities, DependencyVulnerabilities,
GlBadge, GlBadge,
...@@ -36,7 +33,6 @@ export default { ...@@ -36,7 +33,6 @@ export default {
GlSkeletonLoading, GlSkeletonLoading,
GlTable, GlTable,
}, },
mixins: [glFeatureFlagsMixin()],
props: { props: {
dependencies: { dependencies: {
type: Array, type: Array,
...@@ -48,18 +44,8 @@ export default { ...@@ -48,18 +44,8 @@ export default {
}, },
}, },
data() { data() {
const tableSections = [
{ className: 'section-20', label: s__('Dependencies|Status') },
{ className: 'section-20', label: s__('Dependencies|Component') },
{ className: 'section-10', label: s__('Dependencies|Version') },
{ className: 'section-20', label: s__('Dependencies|Packager') },
{ className: 'section-15', label: s__('Dependencies|Location') },
{ className: 'section-15', label: s__('Dependencies|License') },
];
return { return {
localDependencies: this.transformDependenciesForUI(this.dependencies), localDependencies: this.transformDependenciesForUI(this.dependencies),
tableSections,
}; };
}, },
computed: { computed: {
...@@ -96,7 +82,6 @@ export default { ...@@ -96,7 +82,6 @@ export default {
<!-- tbody- and thead-class props can be removed when <!-- tbody- and thead-class props can be removed when
https://gitlab.com/gitlab-org/gitlab/-/issues/213324 is fixed --> https://gitlab.com/gitlab-org/gitlab/-/issues/213324 is fixed -->
<gl-table <gl-table
v-if="glFeatures.dependencyListUi"
:fields="$options.fields" :fields="$options.fields"
:items="localDependencies" :items="localDependencies"
:busy="isLoading" :busy="isLoading"
...@@ -168,25 +153,4 @@ export default { ...@@ -168,25 +153,4 @@ export default {
</div> </div>
</template> </template>
</gl-table> </gl-table>
<div v-else>
<div class="gl-responsive-table-row table-row-header text-2 bg-secondary-50 px-2" role="row">
<div
v-for="(section, index) in tableSections"
:key="index"
class="table-section"
:class="section.className"
role="rowheader"
>
{{ section.label }}
</div>
</div>
<dependencies-table-row
v-for="(dependency, index) in dependencies"
:key="index"
:dependency="dependency"
:is-loading="isLoading"
/>
</div>
</template> </template>
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`DependenciesTable component given a list of dependencies (loaded) matches the snapshot 1`] = `
<div>
<div
class="gl-responsive-table-row table-row-header text-2 bg-secondary-50 px-2"
role="row"
>
<div
class="table-section section-20"
role="rowheader"
>
Status
</div>
<div
class="table-section section-20"
role="rowheader"
>
Component
</div>
<div
class="table-section section-10"
role="rowheader"
>
Version
</div>
<div
class="table-section section-20"
role="rowheader"
>
Packager
</div>
<div
class="table-section section-15"
role="rowheader"
>
Location
</div>
<div
class="table-section section-15"
role="rowheader"
>
License
</div>
</div>
<dependencies-table-row-stub
dependency="[object Object]"
/>
<dependencies-table-row-stub
dependency="[object Object]"
/>
</div>
`;
exports[`DependenciesTable component given a list of dependencies (loading) matches the snapshot 1`] = `
<div>
<div
class="gl-responsive-table-row table-row-header text-2 bg-secondary-50 px-2"
role="row"
>
<div
class="table-section section-20"
role="rowheader"
>
Status
</div>
<div
class="table-section section-20"
role="rowheader"
>
Component
</div>
<div
class="table-section section-10"
role="rowheader"
>
Version
</div>
<div
class="table-section section-20"
role="rowheader"
>
Packager
</div>
<div
class="table-section section-15"
role="rowheader"
>
Location
</div>
<div
class="table-section section-15"
role="rowheader"
>
License
</div>
</div>
<dependencies-table-row-stub
dependency="[object Object]"
isloading="true"
/>
<dependencies-table-row-stub
dependency="[object Object]"
isloading="true"
/>
</div>
`;
exports[`DependenciesTable component given an empty list of dependencies matches the snapshot 1`] = `
<div>
<div
class="gl-responsive-table-row table-row-header text-2 bg-secondary-50 px-2"
role="row"
>
<div
class="table-section section-20"
role="rowheader"
>
Status
</div>
<div
class="table-section section-20"
role="rowheader"
>
Component
</div>
<div
class="table-section section-10"
role="rowheader"
>
Version
</div>
<div
class="table-section section-20"
role="rowheader"
>
Packager
</div>
<div
class="table-section section-15"
role="rowheader"
>
Location
</div>
<div
class="table-section section-15"
role="rowheader"
>
License
</div>
</div>
</div>
`;
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import { mount, shallowMount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { GlBadge, GlButton, GlLink, GlSkeletonLoading } from '@gitlab/ui'; import { GlBadge, GlButton, GlLink, GlSkeletonLoading } from '@gitlab/ui';
import stubChildren from 'helpers/stub_children';
import DependenciesTable from 'ee/dependencies/components/dependencies_table.vue'; import DependenciesTable from 'ee/dependencies/components/dependencies_table.vue';
import DependenciesTableRow from 'ee/dependencies/components/dependencies_table_row.vue';
import DependencyLicenseLinks from 'ee/dependencies/components/dependency_license_links.vue'; import DependencyLicenseLinks from 'ee/dependencies/components/dependency_license_links.vue';
import DependencyVulnerabilities from 'ee/dependencies/components/dependency_vulnerabilities.vue'; import DependencyVulnerabilities from 'ee/dependencies/components/dependency_vulnerabilities.vue';
import { makeDependency } from './utils'; import { makeDependency } from './utils';
...@@ -10,10 +10,11 @@ import { makeDependency } from './utils'; ...@@ -10,10 +10,11 @@ import { makeDependency } from './utils';
describe('DependenciesTable component', () => { describe('DependenciesTable component', () => {
let wrapper; let wrapper;
const factory = ({ propsData, ...options } = {}) => { const createComponent = ({ propsData, ...options } = {}) => {
wrapper = shallowMount(DependenciesTable, { wrapper = mount(DependenciesTable, {
...options, ...options,
propsData: { ...propsData }, propsData: { ...propsData },
stubs: { ...stubChildren(DependenciesTable), GlTable: false },
}); });
}; };
...@@ -21,66 +22,6 @@ describe('DependenciesTable component', () => { ...@@ -21,66 +22,6 @@ describe('DependenciesTable component', () => {
wrapper.destroy(); wrapper.destroy();
}); });
describe('given an empty list of dependencies', () => {
beforeEach(() => {
factory({
propsData: {
dependencies: [],
isLoading: false,
},
});
});
it('matches the snapshot', () => {
expect(wrapper.element).toMatchSnapshot();
});
});
[true, false].forEach(isLoading => {
describe(`given a list of dependencies (${isLoading ? 'loading' : 'loaded'})`, () => {
let dependencies;
beforeEach(() => {
dependencies = [makeDependency(), makeDependency({ name: 'foo' })];
factory({
propsData: {
dependencies,
isLoading,
},
});
});
it('matches the snapshot', () => {
expect(wrapper.element).toMatchSnapshot();
});
it('passes the correct props to the table rows', () => {
const rows = wrapper.findAll(DependenciesTableRow).wrappers;
rows.forEach((row, index) => {
expect(row.props()).toEqual(
expect.objectContaining({
dependency: dependencies[index],
isLoading,
}),
);
});
});
});
});
describe('given the dependencyListUi feature flag is enabled', () => {
const createComponent = ({ propsData, ...options } = {}) => {
const stubs = Object.keys(DependenciesTable.components).filter(
component => component !== 'GlTable',
);
wrapper = mount(DependenciesTable, {
...options,
propsData: { ...propsData },
provide: { glFeatures: { dependencyListUi: true } },
stubs,
});
};
const findTableRows = () => wrapper.findAll('tbody > tr'); const findTableRows = () => wrapper.findAll('tbody > tr');
const findRowToggleButtons = () => wrapper.findAll(GlButton); const findRowToggleButtons = () => wrapper.findAll(GlButton);
const findDependencyVulnerabilities = () => wrapper.find(DependencyVulnerabilities); const findDependencyVulnerabilities = () => wrapper.find(DependencyVulnerabilities);
...@@ -244,9 +185,7 @@ describe('DependenciesTable component', () => { ...@@ -244,9 +185,7 @@ describe('DependenciesTable component', () => {
let rowIndexWithVulnerabilities; let rowIndexWithVulnerabilities;
beforeEach(() => { beforeEach(() => {
rowIndexWithVulnerabilities = dependencies.findIndex( rowIndexWithVulnerabilities = dependencies.findIndex(dep => dep.vulnerabilities.length > 0);
dep => dep.vulnerabilities.length > 0,
);
}); });
it('can be displayed by clicking on the toggle button', () => { it('can be displayed by clicking on the toggle button', () => {
...@@ -274,5 +213,4 @@ describe('DependenciesTable component', () => { ...@@ -274,5 +213,4 @@ describe('DependenciesTable component', () => {
}); });
}); });
}); });
});
}); });
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