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>
2020-03-13 15:44:24 +05:30
import { isString } from 'lodash';
2021-03-11 19:13:27 +05:30
import { visitUrl } from '~/lib/utils/url_utility';
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';
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() {
2020-03-13 15:44:24 +05:30
if (!isString(this.func.description)) {
2019-07-07 11:18:12 +05:30
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">
2020-03-13 15:44:24 +05:30
<div class="group-row-contents py-2" role="button" @click="openDetails">
2019-03-02 22:35:43 +05:30
<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>
2020-06-23 00:09:42 +05:30
<url :uri="targetUrl" class="gl-mt-3 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>