debian-mirror-gitlab/app/assets/javascripts/vue_shared/components/header_ci_component.vue

182 lines
3.7 KiB
Vue
Raw Normal View History

2017-09-10 17:25:29 +05:30
<script>
2018-10-15 14:42:47 +05:30
import CiIconBadge from './ci_badge_link.vue';
import TimeagoTooltip from './time_ago_tooltip.vue';
import tooltip from '../directives/tooltip';
import UserAvatarImage from './user_avatar/user_avatar_image.vue';
2018-03-17 18:26:18 +05:30
2018-10-15 14:42:47 +05:30
/**
* Renders header component for job and pipeline page based on UI mockups
*
* Used in:
* - job show page
* - pipeline show page
*/
export default {
components: {
CiIconBadge,
TimeagoTooltip,
UserAvatarImage,
},
directives: {
tooltip,
},
props: {
status: {
type: Object,
required: true,
2017-09-10 17:25:29 +05:30
},
2018-10-15 14:42:47 +05:30
itemName: {
type: String,
required: true,
2017-09-10 17:25:29 +05:30
},
2018-10-15 14:42:47 +05:30
itemId: {
type: Number,
required: true,
2017-09-10 17:25:29 +05:30
},
2018-10-15 14:42:47 +05:30
time: {
type: String,
required: true,
},
user: {
type: Object,
required: false,
default: () => ({}),
},
actions: {
type: Array,
required: false,
default: () => [],
},
hasSidebarButton: {
type: Boolean,
required: false,
default: false,
},
shouldRenderTriggeredLabel: {
type: Boolean,
required: false,
default: true,
},
},
2017-09-10 17:25:29 +05:30
2018-10-15 14:42:47 +05:30
computed: {
userAvatarAltText() {
return `${this.user.name}'s avatar`;
2017-09-10 17:25:29 +05:30
},
2018-10-15 14:42:47 +05:30
},
2017-09-10 17:25:29 +05:30
2018-10-15 14:42:47 +05:30
methods: {
onClickAction(action) {
this.$emit('actionClicked', action);
2017-09-10 17:25:29 +05:30
},
2018-10-15 14:42:47 +05:30
},
};
2017-09-10 17:25:29 +05:30
</script>
<template>
<header class="page-content-header ci-header-container">
<section class="header-main-content">
<ci-icon-badge :status="status" />
<strong>
2018-03-17 18:26:18 +05:30
{{ itemName }} #{{ itemId }}
2017-09-10 17:25:29 +05:30
</strong>
2018-03-17 18:26:18 +05:30
<template v-if="shouldRenderTriggeredLabel">
triggered
</template>
<template v-else>
created
</template>
2017-09-10 17:25:29 +05:30
<timeago-tooltip :time="time" />
by
<template v-if="user">
<a
v-tooltip
:href="user.path"
:title="user.email"
2018-03-17 18:26:18 +05:30
class="js-user-link commit-committer-link"
>
2017-09-10 17:25:29 +05:30
<user-avatar-image
:img-src="user.avatar_url"
:img-alt="userAvatarAltText"
:tooltip-text="user.name"
:img-size="24"
2018-03-17 18:26:18 +05:30
/>
2017-09-10 17:25:29 +05:30
2018-03-17 18:26:18 +05:30
{{ user.name }}
2017-09-10 17:25:29 +05:30
</a>
2018-11-18 11:00:15 +05:30
<span
v-if="user.status_tooltip_html"
v-html="user.status_tooltip_html"></span>
2017-09-10 17:25:29 +05:30
</template>
</section>
<section
2018-03-27 19:54:05 +05:30
v-if="actions.length"
2018-11-08 19:23:39 +05:30
class="header-action-buttons"
2018-03-27 19:54:05 +05:30
>
2017-09-10 17:25:29 +05:30
<template
2018-03-17 18:26:18 +05:30
v-for="(action, i) in actions"
>
2017-09-10 17:25:29 +05:30
<a
v-if="action.type === 'link'"
2018-12-05 23:21:45 +05:30
:key="i"
2017-09-10 17:25:29 +05:30
:href="action.path"
2018-03-17 18:26:18 +05:30
:class="action.cssClass"
>
{{ action.label }}
2017-09-10 17:25:29 +05:30
</a>
<a
v-else-if="action.type === 'ujs-link'"
2018-12-05 23:21:45 +05:30
:key="i"
2017-09-10 17:25:29 +05:30
:href="action.path"
2018-03-17 18:26:18 +05:30
:class="action.cssClass"
2018-11-08 19:23:39 +05:30
data-method="post"
rel="nofollow"
2018-03-17 18:26:18 +05:30
>
{{ action.label }}
2017-09-10 17:25:29 +05:30
</a>
<button
v-else-if="action.type === 'button'"
2018-12-05 23:21:45 +05:30
:key="i"
2017-09-10 17:25:29 +05:30
:disabled="action.isLoading"
:class="action.cssClass"
2018-11-08 19:23:39 +05:30
type="button"
@click="onClickAction(action)"
2018-03-17 18:26:18 +05:30
>
{{ action.label }}
2017-09-10 17:25:29 +05:30
<i
v-show="action.isLoading"
class="fa fa-spin fa-spinner"
2018-03-17 18:26:18 +05:30
aria-hidden="true"
>
2017-09-10 17:25:29 +05:30
</i>
</button>
</template>
<button
v-if="hasSidebarButton"
2018-11-08 19:23:39 +05:30
id="toggleSidebar"
2017-09-10 17:25:29 +05:30
type="button"
2018-11-08 19:23:39 +05:30
class="btn btn-default d-block d-sm-none d-md-none
sidebar-toggle-btn js-sidebar-build-toggle js-sidebar-build-toggle-header"
2017-09-10 17:25:29 +05:30
aria-label="Toggle Sidebar"
2018-03-17 18:26:18 +05:30
>
2017-09-10 17:25:29 +05:30
<i
class="fa fa-angle-double-left"
aria-hidden="true"
2018-03-17 18:26:18 +05:30
aria-labelledby="toggleSidebar"
>
2017-09-10 17:25:29 +05:30
</i>
</button>
</section>
</header>
</template>