debian-mirror-gitlab/app/assets/javascripts/serverless/components/function_row.vue

78 lines
1.6 KiB
Vue
Raw Normal View History

2019-02-15 15:39:39 +05:30
<script>
2019-07-07 11:18:12 +05:30
import _ from 'underscore';
2019-02-15 15:39:39 +05:30
import Timeago from '~/vue_shared/components/time_ago_tooltip.vue';
2019-03-02 22:35:43 +05:30
import Url from './url.vue';
import { visitUrl } from '~/lib/utils/url_utility';
2019-02-15 15:39:39 +05:30
export default {
components: {
Timeago,
2019-03-02 22:35:43 +05:30
Url,
2019-02-15 15:39:39 +05:30
},
props: {
func: {
type: Object,
required: true,
},
},
computed: {
name() {
return this.func.name;
},
2019-03-02 22:35:43 +05:30
description() {
2019-07-07 11:18:12 +05:30
if (!_.isString(this.func.description)) {
return '';
}
2019-03-02 22:35:43 +05:30
const desc = this.func.description.split('\n');
if (desc.length > 1) {
return desc[1];
}
return desc[0];
},
detailUrl() {
return this.func.detail_url;
},
targetUrl() {
2019-02-15 15:39:39 +05:30
return this.func.url;
},
image() {
return this.func.image;
},
timestamp() {
return this.func.created_at;
},
},
2019-03-02 22:35:43 +05:30
methods: {
checkClass(element) {
if (element.closest('.no-expand') === null) {
return true;
}
return false;
},
openDetails(e) {
if (this.checkClass(e.target)) {
visitUrl(this.detailUrl);
}
},
},
2019-02-15 15:39:39 +05:30
};
</script>
<template>
2019-03-02 22:35:43 +05:30
<li :id="name" class="group-row">
<div class="group-row-contents" role="button" @click="openDetails">
<p class="float-right text-right">
<span>{{ image }}</span
><br />
<timeago :time="timestamp" />
</p>
<b>{{ name }}</b>
<div v-for="line in description.split('\n')" :key="line">{{ line }}</div>
<url :uri="targetUrl" class="prepend-top-8 no-expand" />
2019-02-15 15:39:39 +05:30
</div>
2019-03-02 22:35:43 +05:30
</li>
2019-02-15 15:39:39 +05:30
</template>