mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-08-20 14:11:11 +00:00
Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
54
app/assets/javascripts/environments/components/commit.vue
Normal file
54
app/assets/javascripts/environments/components/commit.vue
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<script>
|
||||||
|
import { GlAvatar, GlAvatarLink, GlLink, GlTooltipDirective as GlTooltip } from '@gitlab/ui';
|
||||||
|
import { escape } from 'lodash';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
GlAvatar,
|
||||||
|
GlAvatarLink,
|
||||||
|
GlLink,
|
||||||
|
},
|
||||||
|
directives: {
|
||||||
|
GlTooltip,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
commit: {
|
||||||
|
required: true,
|
||||||
|
type: Object,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
commitMessage() {
|
||||||
|
return this.commit?.message;
|
||||||
|
},
|
||||||
|
commitAuthorPath() {
|
||||||
|
// eslint-disable-next-line @gitlab/require-i18n-strings
|
||||||
|
return this.commit?.author?.path || `mailto:${escape(this.commit?.authorEmail)}`;
|
||||||
|
},
|
||||||
|
commitAuthorAvatar() {
|
||||||
|
return this.commit?.author?.avatarUrl || this.commit?.authorGravatarUrl;
|
||||||
|
},
|
||||||
|
commitAuthor() {
|
||||||
|
return this.commit?.author?.name || this.commit?.authorName;
|
||||||
|
},
|
||||||
|
commitPath() {
|
||||||
|
return this.commit?.commitPath;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<div data-testid="deployment-commit" class="gl-display-flex gl-align-items-center">
|
||||||
|
<gl-avatar-link v-gl-tooltip :title="commitAuthor" :href="commitAuthorPath">
|
||||||
|
<gl-avatar :size="16" :src="commitAuthorAvatar" />
|
||||||
|
</gl-avatar-link>
|
||||||
|
<gl-link
|
||||||
|
v-gl-tooltip
|
||||||
|
:title="commitMessage"
|
||||||
|
:href="commitPath"
|
||||||
|
class="gl-ml-3 gl-str-truncated"
|
||||||
|
>
|
||||||
|
{{ commitMessage }}
|
||||||
|
</gl-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
@ -5,10 +5,12 @@ import { __, s__ } from '~/locale';
|
|||||||
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
|
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
|
||||||
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
|
import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
|
||||||
import DeploymentStatusBadge from './deployment_status_badge.vue';
|
import DeploymentStatusBadge from './deployment_status_badge.vue';
|
||||||
|
import Commit from './commit.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ClipboardButton,
|
ClipboardButton,
|
||||||
|
Commit,
|
||||||
DeploymentStatusBadge,
|
DeploymentStatusBadge,
|
||||||
GlBadge,
|
GlBadge,
|
||||||
GlButton,
|
GlButton,
|
||||||
@ -41,7 +43,7 @@ export default {
|
|||||||
return this.deployment?.iid;
|
return this.deployment?.iid;
|
||||||
},
|
},
|
||||||
shortSha() {
|
shortSha() {
|
||||||
return this.deployment?.commit?.shortId;
|
return this.commit?.shortId;
|
||||||
},
|
},
|
||||||
createdAt() {
|
createdAt() {
|
||||||
return this.deployment?.createdAt;
|
return this.deployment?.createdAt;
|
||||||
@ -57,6 +59,9 @@ export default {
|
|||||||
detailsButtonClasses() {
|
detailsButtonClasses() {
|
||||||
return this.isMobile ? 'gl-sr-only' : '';
|
return this.isMobile ? 'gl-sr-only' : '';
|
||||||
},
|
},
|
||||||
|
commit() {
|
||||||
|
return this.deployment?.commit;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
toggleCollapse() {
|
toggleCollapse() {
|
||||||
@ -143,6 +148,7 @@ export default {
|
|||||||
{{ detailsButton.text }}
|
{{ detailsButton.text }}
|
||||||
</gl-button>
|
</gl-button>
|
||||||
</div>
|
</div>
|
||||||
|
<commit v-if="commit" :commit="commit" class="gl-mt-3" />
|
||||||
<gl-collapse :visible="visible" />
|
<gl-collapse :visible="visible" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class CleanupBackgroundMigrationPopulateTestReportsIssueId < Gitlab::Database::Migration[1.0]
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
MIGRATION = 'PopulateTestReportsIssueId'
|
||||||
|
|
||||||
|
def up
|
||||||
|
finalize_background_migration(MIGRATION)
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
# no-op
|
||||||
|
end
|
||||||
|
end
|
1
db/schema_migrations/20220201141705
Normal file
1
db/schema_migrations/20220201141705
Normal file
@ -0,0 +1 @@
|
|||||||
|
9eb0c4609fbec79370215d05a9a1faf4208b9dcc2bfeb861feeb7c9f354489ab
|
71
spec/frontend/environments/commit_spec.js
Normal file
71
spec/frontend/environments/commit_spec.js
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import { mountExtended } from 'helpers/vue_test_utils_helper';
|
||||||
|
import Commit from '~/environments/components/commit.vue';
|
||||||
|
import { resolvedEnvironment } from './graphql/mock_data';
|
||||||
|
|
||||||
|
describe('~/environments/components/commit.vue', () => {
|
||||||
|
let commit;
|
||||||
|
let wrapper;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
commit = resolvedEnvironment.lastDeployment.commit;
|
||||||
|
});
|
||||||
|
|
||||||
|
const createWrapper = ({ propsData = {} } = {}) =>
|
||||||
|
mountExtended(Commit, {
|
||||||
|
propsData: {
|
||||||
|
commit,
|
||||||
|
...propsData,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
wrapper?.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('with gitlab user', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
wrapper = createWrapper();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('links to the user profile', () => {
|
||||||
|
const link = wrapper.findByRole('link', { name: commit.author.name });
|
||||||
|
expect(link.attributes('href')).toBe(commit.author.path);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays the user avatar', () => {
|
||||||
|
const avatar = wrapper.findByRole('img', { name: 'avatar' });
|
||||||
|
expect(avatar.attributes('src')).toBe(commit.author.avatarUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('links the commit message to the commit', () => {
|
||||||
|
const message = wrapper.findByRole('link', { name: commit.message });
|
||||||
|
|
||||||
|
expect(message.attributes('href')).toBe(commit.commitPath);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe('without gitlab user', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
commit = {
|
||||||
|
...commit,
|
||||||
|
author: null,
|
||||||
|
};
|
||||||
|
wrapper = createWrapper();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('links to the user profile', () => {
|
||||||
|
const link = wrapper.findByRole('link', { name: commit.authorName });
|
||||||
|
expect(link.attributes('href')).toBe(`mailto:${commit.authorEmail}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays the user avatar', () => {
|
||||||
|
const avatar = wrapper.findByRole('img', { name: 'avatar' });
|
||||||
|
expect(avatar.attributes('src')).toBe(commit.authorGravatarUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays the commit message', () => {
|
||||||
|
const message = wrapper.findByRole('link', { name: commit.message });
|
||||||
|
|
||||||
|
expect(message.attributes('href')).toBe(commit.commitPath);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -6,15 +6,20 @@ import { formatDate } from '~/lib/utils/datetime_utility';
|
|||||||
import { __, s__ } from '~/locale';
|
import { __, s__ } from '~/locale';
|
||||||
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
|
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
|
||||||
import Deployment from '~/environments/components/deployment.vue';
|
import Deployment from '~/environments/components/deployment.vue';
|
||||||
|
import Commit from '~/environments/components/commit.vue';
|
||||||
import DeploymentStatusBadge from '~/environments/components/deployment_status_badge.vue';
|
import DeploymentStatusBadge from '~/environments/components/deployment_status_badge.vue';
|
||||||
import { resolvedEnvironment } from './graphql/mock_data';
|
import { resolvedEnvironment } from './graphql/mock_data';
|
||||||
|
|
||||||
describe('~/environments/components/deployment.vue', () => {
|
describe('~/environments/components/deployment.vue', () => {
|
||||||
useFakeDate(2022, 0, 8, 16);
|
useFakeDate(2022, 0, 8, 16);
|
||||||
|
|
||||||
const deployment = resolvedEnvironment.lastDeployment;
|
let deployment;
|
||||||
let wrapper;
|
let wrapper;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
deployment = resolvedEnvironment.lastDeployment;
|
||||||
|
});
|
||||||
|
|
||||||
const createWrapper = ({ propsData = {} } = {}) =>
|
const createWrapper = ({ propsData = {} } = {}) =>
|
||||||
mountExtended(Deployment, {
|
mountExtended(Deployment, {
|
||||||
propsData: {
|
propsData: {
|
||||||
@ -152,6 +157,32 @@ describe('~/environments/components/deployment.vue', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('commit message', () => {
|
||||||
|
describe('with commit', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
wrapper = createWrapper();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows the commit component', () => {
|
||||||
|
const commit = wrapper.findComponent(Commit);
|
||||||
|
expect(commit.props('commit')).toBe(deployment.commit);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('without a commit', () => {
|
||||||
|
it('displays nothing', () => {
|
||||||
|
const noCommit = {
|
||||||
|
...deployment,
|
||||||
|
commit: null,
|
||||||
|
};
|
||||||
|
wrapper = createWrapper({ propsData: { deployment: noCommit } });
|
||||||
|
|
||||||
|
const commit = wrapper.findComponent(Commit);
|
||||||
|
expect(commit.exists()).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('collapse', () => {
|
describe('collapse', () => {
|
||||||
let collapse;
|
let collapse;
|
||||||
let button;
|
let button;
|
||||||
|
Reference in New Issue
Block a user