Commit a6dbd65c authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch 'usage-quotas-table-view' into 'master'

Improve projects table in Usage quotas page

See merge request gitlab-org/gitlab!43080
parents ba8bc18b c603aa2f
...@@ -144,13 +144,13 @@ export default { ...@@ -144,13 +144,13 @@ export default {
</div> </div>
<div class="ci-table" role="grid"> <div class="ci-table" role="grid">
<div <div
class="gl-responsive-table-row table-row-header bg-gray-light pl-2 border-top mt-3 lh-100" class="gl-responsive-table-row table-row-header gl-pl-3 gl-border-t-solid gl-border-t-1 gl-border-gray-100 gl-mt-5 gl-line-height-normal gl-text-black-normal gl-font-base"
role="row" role="row"
> >
<div class="table-section section-70 font-weight-bold" role="columnheader"> <div class="table-section section-70 gl-font-weight-bold" role="columnheader">
{{ __('Project') }} {{ __('Project') }}
</div> </div>
<div class="table-section section-30 font-weight-bold" role="columnheader"> <div class="table-section section-30 gl-font-weight-bold" role="columnheader">
{{ __('Usage') }} {{ __('Usage') }}
</div> </div>
</div> </div>
......
<script> <script>
import { GlButton, GlLink, GlIcon } from '@gitlab/ui'; import { GlLink, GlIcon } from '@gitlab/ui';
import ProjectAvatar from '~/vue_shared/components/project_avatar/default.vue'; import ProjectAvatar from '~/vue_shared/components/project_avatar/default.vue';
import { numberToHumanSize, isOdd } from '~/lib/utils/number_utils'; import { numberToHumanSize, isOdd } from '~/lib/utils/number_utils';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import StorageRow from './storage_row.vue'; import StorageRow from './storage_row.vue';
export default { export default {
components: { components: {
GlIcon, GlIcon,
GlButton,
GlLink, GlLink,
ProjectAvatar, ProjectAvatar,
StorageRow, StorageRow,
...@@ -29,7 +29,7 @@ export default { ...@@ -29,7 +29,7 @@ export default {
const { name, id, avatarUrl, webUrl } = this.project; const { name, id, avatarUrl, webUrl } = this.project;
return { return {
name, name,
id: Number(id), id: Number(getIdFromGraphQLId(id)),
avatar_url: avatarUrl, avatar_url: avatarUrl,
path: webUrl, path: webUrl,
}; };
...@@ -54,7 +54,13 @@ export default { ...@@ -54,7 +54,13 @@ export default {
}, },
}, },
methods: { methods: {
toggleProject() { toggleProject(e) {
const NO_EXPAND_CLS = 'js-project-link';
const targetClasses = e.target.classList;
if (targetClasses.contains(NO_EXPAND_CLS)) {
return;
}
this.isOpen = !this.isOpen; this.isOpen = !this.isOpen;
}, },
getFormattedName(name) { getFormattedName(name) {
...@@ -83,27 +89,42 @@ export default { ...@@ -83,27 +89,42 @@ export default {
</script> </script>
<template> <template>
<div> <div>
<div class="gl-responsive-table-row border-bottom" role="row"> <div
<div class="table-section section-wrap section-70 text-truncate" role="gridcell"> class="gl-responsive-table-row gl-border-solid gl-border-b-1 gl-pt-3 gl-pb-3 gl-border-b-gray-100 gl-hover-bg-blue-50 gl-hover-border-blue-200 gl-hover-cursor-pointer"
<div class="table-mobile-header font-weight-bold" role="rowheader">{{ __('Project') }}</div> role="row"
<div class="table-mobile-content"> data-testid="projectTableRow"
<gl-button
class="btn-transparent float-left p-0 mr-2"
:aria-label="__('Toggle project')"
category="tertiary"
@click="toggleProject" @click="toggleProject"
> >
<gl-icon :name="iconName" class="folder-icon" /> <div
</gl-button> class="table-section gl-white-space-normal! gl-flex-sm-wrap section-70 gl-text-truncate"
role="gridcell"
<project-avatar :project="projectAvatar" :size="20" /> >
<div class="table-mobile-header gl-font-weight-bold" role="rowheader">
<gl-link :href="project.webUrl" class="font-weight-bold">{{ name }}</gl-link> {{ __('Project') }}
</div>
<div class="table-mobile-content gl-display-flex gl-align-items-center">
<div class="gl-display-flex gl-mr-3 gl-align-items-center">
<gl-icon :size="10" :name="iconName" class="gl-mr-2" />
<gl-icon name="bookmark" />
</div> </div>
<div>
<project-avatar :project="projectAvatar" :size="32" />
</div>
<gl-link
:href="project.webUrl"
class="js-project-link gl-font-weight-bold gl-text-gray-900!"
>{{ name }}</gl-link
>
</div>
</div>
<div
class="table-section gl-white-space-normal! gl-flex-sm-wrap section-30 gl-text-truncate"
role="gridcell"
>
<div class="table-mobile-header gl-font-weight-bold" role="rowheader">
{{ __('Usage') }}
</div> </div>
<div class="table-section section-wrap section-30 text-truncate" role="gridcell"> <div class="table-mobile-content gl-text-gray-900">{{ storageSize }}</div>
<div class="table-mobile-header font-weight-bold" role="rowheader">{{ __('Usage') }}</div>
<div class="table-mobile-content">{{ storageSize }}</div>
</div> </div>
</div> </div>
...@@ -113,7 +134,7 @@ export default { ...@@ -113,7 +134,7 @@ export default {
:key="index" :key="index"
:name="getFormattedName(statisticsName)" :name="getFormattedName(statisticsName)"
:value="getValue(value)" :value="getValue(value)"
:class="{ 'bg-gray-light': isOdd(index) }" :class="{ 'gl-bg-gray-10': isOdd(index) }"
/> />
</template> </template>
</div> </div>
......
---
title: Improve projects table in Usage quotas page
merge_request: 43080
author:
type: changed
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlButton } from '@gitlab/ui';
import Project from 'ee/storage_counter/components/project.vue'; import Project from 'ee/storage_counter/components/project.vue';
import StorageRow from 'ee/storage_counter/components/storage_row.vue';
import ProjectAvatar from '~/vue_shared/components/project_avatar/default.vue'; import ProjectAvatar from '~/vue_shared/components/project_avatar/default.vue';
import { numberToHumanSize } from '~/lib/utils/number_utils'; import { numberToHumanSize } from '~/lib/utils/number_utils';
...@@ -32,6 +32,9 @@ function factory(project) { ...@@ -32,6 +32,9 @@ function factory(project) {
}); });
} }
const findTableRow = () => wrapper.find('[data-testid="projectTableRow"]');
const findStorageRow = () => wrapper.find(StorageRow);
describe('Storage Counter project component', () => { describe('Storage Counter project component', () => {
beforeEach(() => { beforeEach(() => {
factory(data); factory(data);
...@@ -52,15 +55,18 @@ describe('Storage Counter project component', () => { ...@@ -52,15 +55,18 @@ describe('Storage Counter project component', () => {
describe('toggle row', () => { describe('toggle row', () => {
describe('on click', () => { describe('on click', () => {
it('toggles isOpen', () => { it('toggles isOpen', () => {
expect(wrapper.vm.isOpen).toEqual(false); expect(findStorageRow().exists()).toBe(false);
wrapper.find(GlButton).vm.$emit('click');
expect(wrapper.vm.isOpen).toEqual(true); findTableRow().trigger('click');
wrapper.find(GlButton).vm.$emit('click'); wrapper.vm.$nextTick(() => {
expect(findStorageRow().exists()).toBe(true);
findTableRow().trigger('click');
expect(wrapper.vm.isOpen).toEqual(false); wrapper.vm.$nextTick(() => {
expect(findStorageRow().exists()).toBe(false);
});
});
}); });
}); });
}); });
......
...@@ -26902,9 +26902,6 @@ msgstr "" ...@@ -26902,9 +26902,6 @@ msgstr ""
msgid "Toggle navigation" msgid "Toggle navigation"
msgstr "" msgstr ""
msgid "Toggle project"
msgstr ""
msgid "Toggle sidebar" msgid "Toggle sidebar"
msgstr "" msgstr ""
......
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