Commit b7fc4b31 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'browse-locked-artifact' into 'master'

Update artifacts section to show when an artifact is locked

See merge request gitlab-org/gitlab!32992
parents 3b95696a 7ca92969
......@@ -17,11 +17,14 @@ export default {
},
computed: {
isExpired() {
return this.artifact.expired;
return this.artifact?.expired && !this.isLocked;
},
isLocked() {
return this.artifact?.locked;
},
// Only when the key is `false` we can render this block
willExpire() {
return this.artifact.expired === false;
return this.artifact?.expired === false && !this.isLocked;
},
},
};
......@@ -29,42 +32,45 @@ export default {
<template>
<div class="block">
<div class="title font-weight-bold">{{ s__('Job|Job artifacts') }}</div>
<p
v-if="isExpired || willExpire"
:class="{
'js-artifacts-removed': isExpired,
'js-artifacts-will-be-removed': willExpire,
}"
class="build-detail-row"
data-testid="artifacts-remove-timeline"
>
<span v-if="isExpired">{{ s__('Job|The artifacts were removed') }}</span>
<span v-if="willExpire">{{ s__('Job|The artifacts will be removed') }}</span>
<timeago-tooltip v-if="artifact.expire_at" :time="artifact.expire_at" />
</p>
<p v-else-if="isLocked" class="build-detail-row">
<span data-testid="job-locked-message">{{
s__(
'Job|These artifacts are the latest. They will not be deleted (even if expired) until newer artifacts are available.',
)
}}</span>
</p>
<div class="btn-group d-flex prepend-top-10" role="group">
<gl-link
v-if="artifact.keep_path"
:href="artifact.keep_path"
class="js-keep-artifacts btn btn-sm btn-default"
class="btn btn-sm btn-default"
data-method="post"
data-testid="keep-artifacts"
>{{ s__('Job|Keep') }}</gl-link
>
<gl-link
v-if="artifact.download_path"
:href="artifact.download_path"
class="js-download-artifacts btn btn-sm btn-default"
class="btn btn-sm btn-default"
download
rel="nofollow"
data-testid="download-artifacts"
>{{ s__('Job|Download') }}</gl-link
>
<gl-link
v-if="artifact.browse_path"
:href="artifact.browse_path"
class="js-browse-artifacts btn btn-sm btn-default"
class="btn btn-sm btn-default"
data-testid="browse-artifacts"
>{{ s__('Job|Browse') }}</gl-link
>
</div>
......
---
title: Update artifacts section to show when an artifact is locked
merge_request: 32992
author:
type: changed
......@@ -8,6 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: gitlab 1.0.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-06-01 14:24-0400\n"
"PO-Revision-Date: 2020-06-01 14:24-0400\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
......@@ -12469,6 +12471,9 @@ msgstr ""
msgid "Job|The artifacts will be removed"
msgstr ""
msgid "Job|These artifacts are the latest. They will not be deleted (even if expired) until newer artifacts are available."
msgstr ""
msgid "Job|This job failed because the necessary resources were not successfully created."
msgstr ""
......
import Vue from 'vue';
import { mount } from '@vue/test-utils';
import { getTimeago } from '~/lib/utils/datetime_utility';
import component from '~/jobs/components/artifacts_block.vue';
import mountComponent from '../../helpers/vue_mount_component_helper';
import ArtifactsBlock from '~/jobs/components/artifacts_block.vue';
import { trimText } from '../../helpers/text_helper';
describe('Artifacts block', () => {
const Component = Vue.extend(component);
let vm;
let wrapper;
const createWrapper = propsData =>
mount(ArtifactsBlock, {
propsData,
});
const findArtifactRemoveElt = () => wrapper.find('[data-testid="artifacts-remove-timeline"]');
const findJobLockedElt = () => wrapper.find('[data-testid="job-locked-message"]');
const findKeepBtn = () => wrapper.find('[data-testid="keep-artifacts"]');
const findDownloadBtn = () => wrapper.find('[data-testid="download-artifacts"]');
const findBrowseBtn = () => wrapper.find('[data-testid="browse-artifacts"]');
const expireAt = '2018-08-14T09:38:49.157Z';
const timeago = getTimeago();
const formattedDate = timeago.format(expireAt);
const lockedText =
'These artifacts are the latest. They will not be deleted (even if expired) until newer artifacts are available.';
const expiredArtifact = {
expire_at: expireAt,
expired: true,
locked: false,
};
const nonExpiredArtifact = {
......@@ -23,97 +35,127 @@ describe('Artifacts block', () => {
keep_path: '/gitlab-org/gitlab-foss/-/jobs/98314558/artifacts/keep',
expire_at: expireAt,
expired: false,
locked: false,
};
const lockedExpiredArtifact = {
...expiredArtifact,
download_path: '/gitlab-org/gitlab-foss/-/jobs/98314558/artifacts/download',
browse_path: '/gitlab-org/gitlab-foss/-/jobs/98314558/artifacts/browse',
expired: true,
locked: true,
};
const lockedNonExpiredArtifact = {
...nonExpiredArtifact,
keep_path: undefined,
locked: true,
};
afterEach(() => {
vm.$destroy();
wrapper.destroy();
wrapper = null;
});
describe('with expired artifacts', () => {
it('renders expired artifact date and info', () => {
vm = mountComponent(Component, {
describe('with expired artifacts that are not locked', () => {
beforeEach(() => {
wrapper = createWrapper({
artifact: expiredArtifact,
});
});
expect(vm.$el.querySelector('.js-artifacts-removed')).not.toBeNull();
expect(vm.$el.querySelector('.js-artifacts-will-be-removed')).toBeNull();
expect(trimText(vm.$el.querySelector('.js-artifacts-removed').textContent)).toEqual(
it('renders expired artifact date and info', () => {
expect(trimText(findArtifactRemoveElt().text())).toBe(
`The artifacts were removed ${formattedDate}`,
);
});
it('does not show the keep button', () => {
expect(findKeepBtn().exists()).toBe(false);
});
it('does not show the download button', () => {
expect(findDownloadBtn().exists()).toBe(false);
});
it('does not show the browse button', () => {
expect(findBrowseBtn().exists()).toBe(false);
});
});
describe('with artifacts that will expire', () => {
it('renders will expire artifact date and info', () => {
vm = mountComponent(Component, {
beforeEach(() => {
wrapper = createWrapper({
artifact: nonExpiredArtifact,
});
});
expect(vm.$el.querySelector('.js-artifacts-removed')).toBeNull();
expect(vm.$el.querySelector('.js-artifacts-will-be-removed')).not.toBeNull();
expect(trimText(vm.$el.querySelector('.js-artifacts-will-be-removed').textContent)).toEqual(
it('renders will expire artifact date and info', () => {
expect(trimText(findArtifactRemoveElt().text())).toBe(
`The artifacts will be removed ${formattedDate}`,
);
});
});
describe('with keep path', () => {
it('renders the keep button', () => {
vm = mountComponent(Component, {
artifact: nonExpiredArtifact,
expect(findKeepBtn().exists()).toBe(true);
});
expect(vm.$el.querySelector('.js-keep-artifacts')).not.toBeNull();
});
it('renders the download button', () => {
expect(findDownloadBtn().exists()).toBe(true);
});
describe('without keep path', () => {
it('does not render the keep button', () => {
vm = mountComponent(Component, {
artifact: expiredArtifact,
it('renders the browse button', () => {
expect(findBrowseBtn().exists()).toBe(true);
});
});
expect(vm.$el.querySelector('.js-keep-artifacts')).toBeNull();
describe('with expired locked artifacts', () => {
beforeEach(() => {
wrapper = createWrapper({
artifact: lockedExpiredArtifact,
});
});
describe('with download path', () => {
it('renders the download button', () => {
vm = mountComponent(Component, {
artifact: nonExpiredArtifact,
it('renders the information that the artefacts are locked', () => {
expect(findArtifactRemoveElt().exists()).toBe(false);
expect(trimText(findJobLockedElt().text())).toBe(lockedText);
});
expect(vm.$el.querySelector('.js-download-artifacts')).not.toBeNull();
});
it('does not render the keep button', () => {
expect(findKeepBtn().exists()).toBe(false);
});
describe('without download path', () => {
it('does not render the keep button', () => {
vm = mountComponent(Component, {
artifact: expiredArtifact,
it('renders the download button', () => {
expect(findDownloadBtn().exists()).toBe(true);
});
expect(vm.$el.querySelector('.js-download-artifacts')).toBeNull();
it('renders the browse button', () => {
expect(findBrowseBtn().exists()).toBe(true);
});
});
describe('with browse path', () => {
it('does not render the browse button', () => {
vm = mountComponent(Component, {
artifact: nonExpiredArtifact,
describe('with non expired locked artifacts', () => {
beforeEach(() => {
wrapper = createWrapper({
artifact: lockedNonExpiredArtifact,
});
});
expect(vm.$el.querySelector('.js-browse-artifacts')).not.toBeNull();
it('renders the information that the artefacts are locked', () => {
expect(findArtifactRemoveElt().exists()).toBe(false);
expect(trimText(findJobLockedElt().text())).toBe(lockedText);
});
it('does not render the keep button', () => {
expect(findKeepBtn().exists()).toBe(false);
});
describe('without browse path', () => {
it('does not render the browse button', () => {
vm = mountComponent(Component, {
artifact: expiredArtifact,
it('renders the download button', () => {
expect(findDownloadBtn().exists()).toBe(true);
});
expect(vm.$el.querySelector('.js-browse-artifacts')).toBeNull();
it('renders the browse button', () => {
expect(findBrowseBtn().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