gitlab-org--gitlab-foss/app/assets/javascripts/vue_shared/components/header_ci_component.vue

182 lines
3.8 KiB
Vue
Raw Normal View History

<script>
2018-11-16 19:29:11 +00:00
import { GlTooltipDirective, GlLink, GlButton } from '@gitlab/ui';
import CiIconBadge from './ci_badge_link.vue';
import TimeagoTooltip from './time_ago_tooltip.vue';
import UserAvatarImage from './user_avatar/user_avatar_image.vue';
import LoadingButton from '~/vue_shared/components/loading_button.vue';
2018-01-08 20:01:49 +00:00
/**
* 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,
GlLink,
GlButton,
LoadingButton,
},
directives: {
GlTooltip: GlTooltipDirective,
},
props: {
status: {
type: Object,
required: true,
},
itemName: {
type: String,
required: true,
},
itemId: {
type: Number,
required: true,
},
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,
},
},
computed: {
userAvatarAltText() {
return `${this.user.name}'s avatar`;
},
},
methods: {
onClickAction(action) {
this.$emit('actionClicked', action);
},
onClickSidebarButton() {
this.$emit('clickedSidebarButton');
},
},
};
</script>
<template>
<header class="page-content-header ci-header-container">
<section class="header-main-content">
<ci-icon-badge :status="status" />
<strong>
2018-01-08 20:01:49 +00:00
{{ itemName }} #{{ itemId }}
</strong>
2018-01-05 16:18:01 +00:00
<template v-if="shouldRenderTriggeredLabel">
triggered
</template>
<template v-else>
created
</template>
<timeago-tooltip :time="time" />
by
<template v-if="user">
<gl-link
v-gl-tooltip
:href="user.path"
:title="user.email"
2018-01-08 20:01:49 +00:00
class="js-user-link commit-committer-link"
>
<user-avatar-image
:img-src="user.avatar_url"
:img-alt="userAvatarAltText"
:tooltip-text="user.name"
:img-size="24"
2018-01-08 20:01:49 +00:00
/>
2018-01-08 20:01:49 +00:00
{{ user.name }}
</gl-link>
<span
v-if="user.status_tooltip_html"
v-html="user.status_tooltip_html"></span>
</template>
</section>
<section
v-if="actions.length"
2018-06-11 09:49:47 +00:00
class="header-action-buttons"
>
<template
2018-01-08 20:01:49 +00:00
v-for="(action, i) in actions"
>
<gl-link
v-if="action.type === 'link'"
:key="i"
:href="action.path"
2018-01-08 20:01:49 +00:00
:class="action.cssClass"
>
{{ action.label }}
</gl-link>
<gl-link
v-else-if="action.type === 'ujs-link'"
:key="i"
:href="action.path"
2018-01-08 20:01:49 +00:00
:class="action.cssClass"
2018-06-11 09:49:47 +00:00
data-method="post"
rel="nofollow"
2018-01-08 20:01:49 +00:00
>
{{ action.label }}
</gl-link>
<loading-button
v-else-if="action.type === 'button'"
:key="i"
:loading="action.isLoading"
:disabled="action.isLoading"
:class="action.cssClass"
container-class="d-inline"
:label="action.label"
2018-06-11 09:49:47 +00:00
@click="onClickAction(action)"
/>
</template>
</section>
<gl-button
v-if="hasSidebarButton"
id="toggleSidebar"
class="d-block d-sm-none
sidebar-toggle-btn js-sidebar-build-toggle js-sidebar-build-toggle-header"
@click="onClickSidebarButton"
>
<i
class="fa fa-angle-double-left"
aria-hidden="true"
aria-labelledby="toggleSidebar"
2018-01-08 20:01:49 +00:00
>
</i>
</gl-button>
</header>
</template>