Commit 74b1c699 authored by Emily Ring's avatar Emily Ring Committed by Jacques Erasmus

Fixes for missing users for Terraform State

Udated terraform vue to handle missing user info
Updated associated tests and translations
parent c7c3323e
<script> <script>
import { GlBadge, GlIcon, GlSprintf, GlTable, GlTooltip } from '@gitlab/ui'; import { GlBadge, GlIcon, GlSprintf, GlTable, GlTooltip } from '@gitlab/ui';
import { s__ } from '~/locale';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago'; import timeagoMixin from '~/vue_shared/mixins/timeago';
...@@ -34,6 +35,17 @@ export default { ...@@ -34,6 +35,17 @@ export default {
]; ];
}, },
}, },
methods: {
createdByUserName(item) {
return item.latestVersion?.createdByUser?.name;
},
lockedByUserName(item) {
return item.lockedByUser?.name || s__('Terraform|Unknown User');
},
updatedTime(item) {
return item.latestVersion?.updatedAt || item.updatedAt;
},
},
}; };
</script> </script>
...@@ -58,7 +70,7 @@ export default { ...@@ -58,7 +70,7 @@ export default {
> >
<gl-sprintf :message="s__('Terraform|Locked by %{user} %{timeAgo}')"> <gl-sprintf :message="s__('Terraform|Locked by %{user} %{timeAgo}')">
<template #user> <template #user>
{{ item.lockedByUser.name }} {{ lockedByUserName(item) }}
</template> </template>
<template #timeAgo> <template #timeAgo>
...@@ -75,18 +87,12 @@ export default { ...@@ -75,18 +87,12 @@ export default {
<gl-sprintf :message="s__('Terraform|%{user} updated %{timeAgo}')"> <gl-sprintf :message="s__('Terraform|%{user} updated %{timeAgo}')">
<template #user> <template #user>
<span v-if="item.latestVersion"> <span v-if="item.latestVersion">
{{ item.latestVersion.createdByUser.name }} {{ createdByUserName(item) }}
</span> </span>
</template> </template>
<template #timeAgo> <template #timeAgo>
<span v-if="item.latestVersion"> <time-ago-tooltip :time="updatedTime(item)" />
<time-ago-tooltip :time="item.latestVersion.updatedAt" />
</span>
<span v-else>
<time-ago-tooltip :time="item.updatedAt" />
</span>
</template> </template>
</gl-sprintf> </gl-sprintf>
</p> </p>
......
---
title: Fix for missing user info for Terraform State
merge_request: 47814
author:
type: fixed
...@@ -26590,6 +26590,9 @@ msgstr "" ...@@ -26590,6 +26590,9 @@ msgstr ""
msgid "Terraform|The Terraform report %{name} was generated in your pipelines." msgid "Terraform|The Terraform report %{name} was generated in your pipelines."
msgstr "" msgstr ""
msgid "Terraform|Unknown User"
msgstr ""
msgid "Test" msgid "Test"
msgstr "" msgstr ""
......
...@@ -39,6 +39,16 @@ describe('StatesTable', () => { ...@@ -39,6 +39,16 @@ describe('StatesTable', () => {
}, },
}, },
}, },
{
name: 'state-4',
lockedAt: '2020-10-10T00:00:00Z',
lockedByUser: null,
updatedAt: '2020-10-10T00:00:00Z',
latestVersion: {
updatedAt: '2020-10-09T00:00:00Z',
createdByUser: null,
},
},
], ],
}; };
...@@ -53,10 +63,11 @@ describe('StatesTable', () => { ...@@ -53,10 +63,11 @@ describe('StatesTable', () => {
}); });
it.each` it.each`
name | toolTipText | locked | lineNumber name | toolTipText | locked | lineNumber
${'state-1'} | ${'Locked by user-1 2 days ago'} | ${true} | ${0} ${'state-1'} | ${'Locked by user-1 2 days ago'} | ${true} | ${0}
${'state-2'} | ${null} | ${false} | ${1} ${'state-2'} | ${null} | ${false} | ${1}
${'state-3'} | ${'Locked by user-2 5 days ago'} | ${true} | ${2} ${'state-3'} | ${'Locked by user-2 5 days ago'} | ${true} | ${2}
${'state-4'} | ${'Locked by Unknown User 5 days ago'} | ${true} | ${3}
`( `(
'displays the name and locked information "$name" for line "$lineNumber"', 'displays the name and locked information "$name" for line "$lineNumber"',
({ name, toolTipText, locked, lineNumber }) => { ({ name, toolTipText, locked, lineNumber }) => {
...@@ -80,6 +91,7 @@ describe('StatesTable', () => { ...@@ -80,6 +91,7 @@ describe('StatesTable', () => {
${'updated 2 days ago'} | ${0} ${'updated 2 days ago'} | ${0}
${'updated 5 days ago'} | ${1} ${'updated 5 days ago'} | ${1}
${'user-3 updated 4 days ago'} | ${2} ${'user-3 updated 4 days ago'} | ${2}
${'updated 6 days ago'} | ${3}
`('displays the time "$updateTime" for line "$lineNumber"', ({ updateTime, lineNumber }) => { `('displays the time "$updateTime" for line "$lineNumber"', ({ updateTime, lineNumber }) => {
const states = wrapper.findAll('[data-testid="terraform-states-table-updated"]'); const states = wrapper.findAll('[data-testid="terraform-states-table-updated"]');
......
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