Commit 1983602e authored by Phil Hughes's avatar Phil Hughes

Render folder lock icon in table rows

When a folder is locked this renders the lock icon next
to the folder name
parent 2e4f1684
<script> <script>
import { GlBadge, GlLink, GlSkeletonLoading } from '@gitlab/ui'; import { GlBadge, GlLink, GlSkeletonLoading, GlTooltipDirective } from '@gitlab/ui';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import Icon from '~/vue_shared/components/icon.vue';
import { getIconName } from '../../utils/icon'; import { getIconName } from '../../utils/icon';
import getRefMixin from '../../mixins/get_ref'; import getRefMixin from '../../mixins/get_ref';
import getCommit from '../../queries/getCommit.query.graphql'; import getCommit from '../../queries/getCommit.query.graphql';
...@@ -12,6 +13,10 @@ export default { ...@@ -12,6 +13,10 @@ export default {
GlLink, GlLink,
GlSkeletonLoading, GlSkeletonLoading,
TimeagoTooltip, TimeagoTooltip,
Icon,
},
directives: {
GlTooltip: GlTooltipDirective,
}, },
apollo: { apollo: {
commit: { commit: {
...@@ -95,6 +100,9 @@ export default { ...@@ -95,6 +100,9 @@ export default {
shortSha() { shortSha() {
return this.id.slice(0, 8); return this.id.slice(0, 8);
}, },
hasLockLabel() {
return this.commit && this.commit.lockLabel;
},
}, },
methods: { methods: {
openRow(e) { openRow(e) {
...@@ -122,6 +130,14 @@ export default { ...@@ -122,6 +130,14 @@ export default {
<template v-if="isSubmodule"> <template v-if="isSubmodule">
@ <gl-link :href="submoduleTreeUrl" class="commit-sha">{{ shortSha }}</gl-link> @ <gl-link :href="submoduleTreeUrl" class="commit-sha">{{ shortSha }}</gl-link>
</template> </template>
<icon
v-if="hasLockLabel"
v-gl-tooltip
:title="commit.lockLabel"
name="lock"
:size="12"
class="ml-2 vertical-align-middle"
/>
</td> </td>
<td class="d-none d-sm-table-cell tree-commit"> <td class="d-none d-sm-table-cell tree-commit">
<gl-link <gl-link
......
...@@ -14,6 +14,7 @@ export function normalizeData(data) { ...@@ -14,6 +14,7 @@ export function normalizeData(data) {
commitPath: d.commit_path, commitPath: d.commit_path,
fileName: d.file_name, fileName: d.file_name,
type: d.type, type: d.type,
lockLabel: d.lock_label,
__typename: 'LogTreeCommit', __typename: 'LogTreeCommit',
})); }));
} }
......
...@@ -6,5 +6,6 @@ query getCommit($fileName: String!, $type: String!, $path: String!) { ...@@ -6,5 +6,6 @@ query getCommit($fileName: String!, $type: String!, $path: String!) {
commitPath commitPath
fileName fileName
type type
lockLabel
} }
} }
...@@ -6,5 +6,6 @@ query getCommits { ...@@ -6,5 +6,6 @@ query getCommits {
commitPath commitPath
fileName fileName
type type
lockLabel
} }
} }
...@@ -25,6 +25,8 @@ exports[`Repository table row component renders table row 1`] = ` ...@@ -25,6 +25,8 @@ exports[`Repository table row component renders table row 1`] = `
<!----> <!---->
<!----> <!---->
<!---->
</td> </td>
<td <td
......
...@@ -2,6 +2,7 @@ import { shallowMount, RouterLinkStub } from '@vue/test-utils'; ...@@ -2,6 +2,7 @@ import { shallowMount, RouterLinkStub } from '@vue/test-utils';
import { GlBadge, GlLink } from '@gitlab/ui'; import { GlBadge, GlLink } from '@gitlab/ui';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
import TableRow from '~/repository/components/table/row.vue'; import TableRow from '~/repository/components/table/row.vue';
import Icon from '~/vue_shared/components/icon.vue';
jest.mock('~/lib/utils/url_utility'); jest.mock('~/lib/utils/url_utility');
...@@ -156,4 +157,17 @@ describe('Repository table row component', () => { ...@@ -156,4 +157,17 @@ describe('Repository table row component', () => {
expect(vm.find('a').attributes('href')).toEqual('https://test.com'); expect(vm.find('a').attributes('href')).toEqual('https://test.com');
expect(vm.find(GlLink).attributes('href')).toEqual('https://test.com/commit'); expect(vm.find(GlLink).attributes('href')).toEqual('https://test.com/commit');
}); });
it('renders lock icon', () => {
factory({
id: '1',
path: 'test',
type: 'tree',
currentPath: '/',
});
vm.setData({ commit: { lockLabel: 'Locked by Root', committedDate: '2019-01-01' } });
expect(vm.find(Icon).exists()).toBe(true);
});
}); });
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