debian-mirror-gitlab/app/assets/javascripts/ide/components/ide_status_bar.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

138 lines
3.7 KiB
Vue
Raw Normal View History

2018-05-09 12:01:36 +05:30
<script>
2020-04-22 19:07:51 +05:30
/* eslint-disable @gitlab/vue-require-i18n-strings */
2021-01-03 14:25:43 +05:30
import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { mapActions, mapState, mapGetters } from 'vuex';
2018-05-09 12:01:36 +05:30
import timeAgoMixin from '~/vue_shared/mixins/timeago';
2022-06-21 17:19:12 +05:30
import CiIcon from '~/vue_shared/components/ci_icon.vue';
2022-10-11 01:57:18 +05:30
import UserAvatarImage from '~/vue_shared/components/user_avatar/user_avatar_image.vue';
2018-11-18 11:00:15 +05:30
import { rightSidebarViews } from '../constants';
2021-03-11 19:13:27 +05:30
import IdeStatusList from './ide_status_list.vue';
import IdeStatusMr from './ide_status_mr.vue';
2018-05-09 12:01:36 +05:30
export default {
components: {
2020-11-24 15:15:51 +05:30
GlIcon,
2022-10-11 01:57:18 +05:30
UserAvatarImage,
2018-11-08 19:23:39 +05:30
CiIcon,
2019-09-04 21:01:54 +05:30
IdeStatusList,
2020-03-13 15:44:24 +05:30
IdeStatusMr,
2018-05-09 12:01:36 +05:30
},
directives: {
2021-01-03 14:25:43 +05:30
GlTooltip: GlTooltipDirective,
2018-05-09 12:01:36 +05:30
},
mixins: [timeAgoMixin],
2018-10-15 14:42:47 +05:30
data() {
return {
2020-01-01 13:55:28 +05:30
lastCommitFormattedAge: null,
2018-10-15 14:42:47 +05:30
};
},
computed: {
2018-11-08 19:23:39 +05:30
...mapState(['currentBranchId', 'currentProjectId']),
2020-03-13 15:44:24 +05:30
...mapGetters(['currentProject', 'lastCommit', 'currentMergeRequest']),
2018-11-08 19:23:39 +05:30
...mapState('pipelines', ['latestPipeline']),
},
watch: {
2022-07-23 23:45:48 +05:30
lastCommit: {
handler() {
this.initPipelinePolling();
},
immediate: true,
2018-11-08 19:23:39 +05:30
},
2018-10-15 14:42:47 +05:30
},
mounted() {
this.startTimer();
},
beforeDestroy() {
if (this.intervalId) {
clearInterval(this.intervalId);
}
2018-11-08 19:23:39 +05:30
this.stopPipelinePolling();
2018-10-15 14:42:47 +05:30
},
methods: {
2018-12-05 23:21:45 +05:30
...mapActions('rightPane', {
openRightPane: 'open',
}),
2018-11-08 19:23:39 +05:30
...mapActions('pipelines', ['fetchLatestPipeline', 'stopPipelinePolling']),
2018-10-15 14:42:47 +05:30
startTimer() {
this.intervalId = setInterval(() => {
this.commitAgeUpdate();
}, 1000);
},
2018-11-08 19:23:39 +05:30
initPipelinePolling() {
if (this.lastCommit) {
this.fetchLatestPipeline();
}
},
2018-10-15 14:42:47 +05:30
commitAgeUpdate() {
if (this.lastCommit) {
2020-01-01 13:55:28 +05:30
this.lastCommitFormattedAge = this.timeFormatted(this.lastCommit.committed_date);
2018-10-15 14:42:47 +05:30
}
},
getCommitPath(shortSha) {
return `${this.currentProject.web_url}/commit/${shortSha}`;
2018-05-09 12:01:36 +05:30
},
},
2018-11-18 11:00:15 +05:30
rightSidebarViews,
2018-05-09 12:01:36 +05:30
};
</script>
<template>
2018-10-15 14:42:47 +05:30
<footer class="ide-status-bar">
2019-02-15 15:39:39 +05:30
<div v-if="lastCommit" class="ide-status-branch">
<span v-if="latestPipeline && latestPipeline.details" class="ide-status-pipeline">
2018-11-18 11:00:15 +05:30
<button
type="button"
2020-03-13 15:44:24 +05:30
class="p-0 border-0 bg-transparent"
2019-03-02 22:35:43 +05:30
@click="openRightPane($options.rightSidebarViews.pipelines)"
2018-11-18 11:00:15 +05:30
>
<ci-icon
2021-01-03 14:25:43 +05:30
v-gl-tooltip
2018-11-18 11:00:15 +05:30
:status="latestPipeline.details.status"
:title="latestPipeline.details.status.text"
/>
</button>
2018-11-08 19:23:39 +05:30
Pipeline
2019-02-15 15:39:39 +05:30
<a :href="latestPipeline.details.status.details_path" class="monospace"
>#{{ latestPipeline.id }}</a
>
{{ latestPipeline.details.status.text }} for
2018-11-08 19:23:39 +05:30
</span>
2020-11-24 15:15:51 +05:30
<gl-icon name="commit" />
2018-10-15 14:42:47 +05:30
<a
2021-01-03 14:25:43 +05:30
v-gl-tooltip
2018-10-15 14:42:47 +05:30
:title="lastCommit.message"
:href="getCommitPath(lastCommit.short_id)"
2018-11-08 19:23:39 +05:30
class="commit-sha"
2020-11-24 15:15:51 +05:30
data-qa-selector="commit_sha_content"
2019-02-15 15:39:39 +05:30
>{{ lastCommit.short_id }}</a
>
2019-03-02 22:35:43 +05:30
by
<user-avatar-image
css-classes="ide-status-avatar"
2022-07-16 23:28:13 +05:30
:size="16"
2019-03-02 22:35:43 +05:30
:img-src="latestPipeline && latestPipeline.commit.author_gravatar_url"
:img-alt="lastCommit.author_name"
:tooltip-text="lastCommit.author_name"
/>
{{ lastCommit.author_name }}
2018-10-15 14:42:47 +05:30
<time
2021-01-03 14:25:43 +05:30
v-gl-tooltip
2018-10-15 14:42:47 +05:30
:datetime="lastCommit.committed_date"
:title="tooltipTitle(lastCommit.committed_date)"
2018-11-08 19:23:39 +05:30
data-placement="top"
data-container="body"
2020-01-01 13:55:28 +05:30
>{{ lastCommitFormattedAge }}</time
2018-10-15 14:42:47 +05:30
>
2018-05-09 12:01:36 +05:30
</div>
2020-03-13 15:44:24 +05:30
<ide-status-mr
v-if="currentMergeRequest"
class="mx-3"
:url="currentMergeRequest.web_url"
:text="currentMergeRequest.references.short"
/>
2019-09-04 21:01:54 +05:30
<ide-status-list class="ml-auto" />
2018-10-15 14:42:47 +05:30
</footer>
2018-05-09 12:01:36 +05:30
</template>