Commit dee89133 authored by Vitaly Slobodin's avatar Vitaly Slobodin Committed by David O'Regan

Add last activity time column to seat usage table

Add last activity time column to seat usage table
parent 27260307
...@@ -20,6 +20,7 @@ import { ...@@ -20,6 +20,7 @@ import {
REMOVE_MEMBER_MODAL_ID, REMOVE_MEMBER_MODAL_ID,
} from 'ee/billings/seat_usage/constants'; } from 'ee/billings/seat_usage/constants';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import RemoveMemberModal from './remove_member_modal.vue'; import RemoveMemberModal from './remove_member_modal.vue';
export default { export default {
...@@ -37,6 +38,7 @@ export default { ...@@ -37,6 +38,7 @@ export default {
GlSearchBoxByType, GlSearchBoxByType,
GlTable, GlTable,
RemoveMemberModal, RemoveMemberModal,
TimeAgoTooltip,
}, },
data() { data() {
return { return {
...@@ -151,7 +153,6 @@ export default { ...@@ -151,7 +153,6 @@ export default {
:show-empty="true" :show-empty="true"
data-testid="table" data-testid="table"
:empty-text="emptyText" :empty-text="emptyText"
thead-class="gl-display-none"
> >
<template #cell(user)="data"> <template #cell(user)="data">
<div class="gl-display-flex"> <div class="gl-display-flex">
...@@ -180,6 +181,17 @@ export default { ...@@ -180,6 +181,17 @@ export default {
</div> </div>
</template> </template>
<template #cell(lastActivityTime)="data">
<time-ago-tooltip
v-if="data.item.user.last_activity_on"
:time="data.item.user.last_activity_on"
tooltip-placement="bottom"
/>
<span v-else>
{{ __('Never') }}
</span>
</template>
<template #cell(actions)="data"> <template #cell(actions)="data">
<gl-dropdown icon="ellipsis_h" right data-testid="user-actions"> <gl-dropdown icon="ellipsis_h" right data-testid="user-actions">
<gl-dropdown-item <gl-dropdown-item
......
...@@ -15,6 +15,11 @@ export const FIELDS = [ ...@@ -15,6 +15,11 @@ export const FIELDS = [
label: __('Email'), label: __('Email'),
thClass: thWidthClass(40), thClass: thWidthClass(40),
}, },
{
key: 'lastActivityTime',
label: __('Last activity'),
thClass: thWidthClass(40),
},
{ {
key: 'actions', key: 'actions',
label: '', label: '',
......
export const tableItems = (state) => { export const tableItems = (state) => {
if (state.members.length) { if (state.members.length) {
return state.members.map(({ id, name, username, avatar_url, web_url, email }) => { return state.members.map(
const formattedUserName = `@${username}`; ({ id, name, username, avatar_url, web_url, email, last_activity_on }) => {
const formattedUserName = `@${username}`;
return { user: { id, name, username: formattedUserName, avatar_url, web_url }, email }; return {
}); user: {
id,
name,
username: formattedUserName,
avatar_url,
web_url,
last_activity_on,
},
email,
};
},
);
} }
return []; return [];
}; };
---
title: Add last activity time column to seat usage table
merge_request: 55321
author:
type: added
...@@ -27,7 +27,7 @@ RSpec.describe 'Groups > Billing > Seat Usage', :js do ...@@ -27,7 +27,7 @@ RSpec.describe 'Groups > Billing > Seat Usage', :js do
context 'seat usage table' do context 'seat usage table' do
it 'displays correct number of users' do it 'displays correct number of users' do
within '[data-testid="table"]' do within '[data-testid="table"]' do
expect(all('tr').count).to eq(3) expect(all('tbody tr').count).to eq(3)
end end
end end
end end
...@@ -91,7 +91,7 @@ RSpec.describe 'Groups > Billing > Seat Usage', :js do ...@@ -91,7 +91,7 @@ RSpec.describe 'Groups > Billing > Seat Usage', :js do
wait_for_all_requests wait_for_all_requests
within '[data-testid="table"]' do within '[data-testid="table"]' do
expect(all('tr').count).to eq(2) expect(all('tbody tr').count).to eq(2)
end end
expect(page.find('.flash-container')).to have_content('User was successfully removed') expect(page.find('.flash-container')).to have_content('User was successfully removed')
...@@ -100,7 +100,7 @@ RSpec.describe 'Groups > Billing > Seat Usage', :js do ...@@ -100,7 +100,7 @@ RSpec.describe 'Groups > Billing > Seat Usage', :js do
context 'removing the user from a sub-group' do context 'removing the user from a sub-group' do
it 'updates the seat table of the parent group' do it 'updates the seat table of the parent group' do
within '[data-testid="table"]' do within '[data-testid="table"]' do
expect(all('tr').count).to eq(3) expect(all('tbody tr').count).to eq(3)
end end
visit group_group_members_path(sub_group) visit group_group_members_path(sub_group)
...@@ -118,7 +118,7 @@ RSpec.describe 'Groups > Billing > Seat Usage', :js do ...@@ -118,7 +118,7 @@ RSpec.describe 'Groups > Billing > Seat Usage', :js do
wait_for_all_requests wait_for_all_requests
within '[data-testid="table"]' do within '[data-testid="table"]' do
expect(all('tr').count).to eq(2) expect(all('tbody tr').count).to eq(2)
end end
end end
end end
......
...@@ -74,6 +74,7 @@ export const mockDataSeats = { ...@@ -74,6 +74,7 @@ export const mockDataSeats = {
avatar_url: 'path/to/img_administrator', avatar_url: 'path/to/img_administrator',
web_url: 'path/to/administrator', web_url: 'path/to/administrator',
email: 'administrator@email.com', email: 'administrator@email.com',
last_activity_on: '2020-03-01',
}, },
{ {
id: 3, id: 3,
...@@ -82,6 +83,7 @@ export const mockDataSeats = { ...@@ -82,6 +83,7 @@ export const mockDataSeats = {
avatar_url: 'path/to/img_agustin_walker', avatar_url: 'path/to/img_agustin_walker',
web_url: 'path/to/agustin_walker', web_url: 'path/to/agustin_walker',
email: 'agustin_walker@email.com', email: 'agustin_walker@email.com',
last_activity_on: '2020-03-01',
}, },
{ {
id: 4, id: 4,
...@@ -89,6 +91,7 @@ export const mockDataSeats = { ...@@ -89,6 +91,7 @@ export const mockDataSeats = {
username: 'era', username: 'era',
avatar_url: 'path/to/img_joella_miller', avatar_url: 'path/to/img_joella_miller',
web_url: 'path/to/joella_miller', web_url: 'path/to/joella_miller',
last_activity_on: null,
email: null, email: null,
}, },
], ],
...@@ -108,6 +111,7 @@ export const mockTableItems = [ ...@@ -108,6 +111,7 @@ export const mockTableItems = [
name: 'Administrator', name: 'Administrator',
username: '@root', username: '@root',
web_url: 'path/to/administrator', web_url: 'path/to/administrator',
last_activity_on: '2020-03-01',
}, },
}, },
{ {
...@@ -118,6 +122,7 @@ export const mockTableItems = [ ...@@ -118,6 +122,7 @@ export const mockTableItems = [
name: 'Agustin Walker', name: 'Agustin Walker',
username: '@lester.orn', username: '@lester.orn',
web_url: 'path/to/agustin_walker', web_url: 'path/to/agustin_walker',
last_activity_on: '2020-03-01',
}, },
}, },
{ {
...@@ -128,6 +133,7 @@ export const mockTableItems = [ ...@@ -128,6 +133,7 @@ export const mockTableItems = [
name: 'Joella Miller', name: 'Joella Miller',
username: '@era', username: '@era',
web_url: 'path/to/joella_miller', web_url: 'path/to/joella_miller',
last_activity_on: null,
}, },
}, },
]; ];
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