Commit 486ea8e0 authored by Jacques Erasmus's avatar Jacques Erasmus

Merge branch 'emilyring-terraform-fixes' into 'master'

Handle missing users for Terraform State

See merge request gitlab-org/gitlab!47814
parents a374ce23 74b1c699
<script>
import { GlBadge, GlIcon, GlSprintf, GlTable, GlTooltip } from '@gitlab/ui';
import { s__ } from '~/locale';
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import timeagoMixin from '~/vue_shared/mixins/timeago';
......@@ -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>
......@@ -58,7 +70,7 @@ export default {
>
<gl-sprintf :message="s__('Terraform|Locked by %{user} %{timeAgo}')">
<template #user>
{{ item.lockedByUser.name }}
{{ lockedByUserName(item) }}
</template>
<template #timeAgo>
......@@ -75,18 +87,12 @@ export default {
<gl-sprintf :message="s__('Terraform|%{user} updated %{timeAgo}')">
<template #user>
<span v-if="item.latestVersion">
{{ item.latestVersion.createdByUser.name }}
{{ createdByUserName(item) }}
</span>
</template>
<template #timeAgo>
<span v-if="item.latestVersion">
<time-ago-tooltip :time="item.latestVersion.updatedAt" />
</span>
<span v-else>
<time-ago-tooltip :time="item.updatedAt" />
</span>
<time-ago-tooltip :time="updatedTime(item)" />
</template>
</gl-sprintf>
</p>
......
---
title: Fix for missing user info for Terraform State
merge_request: 47814
author:
type: fixed
......@@ -26596,6 +26596,9 @@ msgstr ""
msgid "Terraform|The Terraform report %{name} was generated in your pipelines."
msgstr ""
msgid "Terraform|Unknown User"
msgstr ""
msgid "Test"
msgstr ""
......
......@@ -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', () => {
});
it.each`
name | toolTipText | locked | lineNumber
${'state-1'} | ${'Locked by user-1 2 days ago'} | ${true} | ${0}
${'state-2'} | ${null} | ${false} | ${1}
${'state-3'} | ${'Locked by user-2 5 days ago'} | ${true} | ${2}
name | toolTipText | locked | lineNumber
${'state-1'} | ${'Locked by user-1 2 days ago'} | ${true} | ${0}
${'state-2'} | ${null} | ${false} | ${1}
${'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"',
({ name, toolTipText, locked, lineNumber }) => {
......@@ -80,6 +91,7 @@ describe('StatesTable', () => {
${'updated 2 days ago'} | ${0}
${'updated 5 days ago'} | ${1}
${'user-3 updated 4 days ago'} | ${2}
${'updated 6 days ago'} | ${3}
`('displays the time "$updateTime" for line "$lineNumber"', ({ updateTime, lineNumber }) => {
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