debian-mirror-gitlab/app/assets/javascripts/deploy_keys/components/key.vue

112 lines
2.6 KiB
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
import actionBtn from './action_btn.vue';
2018-03-17 18:26:18 +05:30
import { getTimeago } from '../../lib/utils/datetime_utility';
import tooltip from '../../vue_shared/directives/tooltip';
2017-08-17 22:00:37 +05:30
export default {
2018-03-17 18:26:18 +05:30
components: {
actionBtn,
},
directives: {
tooltip,
},
2017-08-17 22:00:37 +05:30
props: {
deployKey: {
type: Object,
required: true,
},
store: {
type: Object,
required: true,
},
2017-09-10 17:25:29 +05:30
endpoint: {
type: String,
required: true,
},
2017-08-17 22:00:37 +05:30
},
computed: {
timeagoDate() {
2018-03-17 18:26:18 +05:30
return getTimeago().format(this.deployKey.created_at);
2017-08-17 22:00:37 +05:30
},
2017-09-10 17:25:29 +05:30
editDeployKeyPath() {
return `${this.endpoint}/${this.deployKey.id}/edit`;
},
2017-08-17 22:00:37 +05:30
},
methods: {
isEnabled(id) {
return this.store.findEnabledKey(id) !== undefined;
},
2018-03-17 18:26:18 +05:30
tooltipTitle(project) {
return project.can_push ? 'Write access allowed' : 'Read access only';
},
2017-08-17 22:00:37 +05:30
},
};
</script>
<template>
<div>
<div class="pull-left append-right-10 hidden-xs">
<i
aria-hidden="true"
2017-09-10 17:25:29 +05:30
class="fa fa-key key-icon"
>
2017-08-17 22:00:37 +05:30
</i>
</div>
<div class="deploy-key-content key-list-item-info">
2018-03-17 18:26:18 +05:30
<strong class="title qa-key-title">
2017-08-17 22:00:37 +05:30
{{ deployKey.title }}
</strong>
2018-03-17 18:26:18 +05:30
<div class="description qa-key-fingerprint">
2017-08-17 22:00:37 +05:30
{{ deployKey.fingerprint }}
</div>
</div>
<div class="deploy-key-content prepend-left-default deploy-key-projects">
<a
2018-03-17 18:26:18 +05:30
v-for="(deployKeysProject, i) in deployKey.deploy_keys_projects"
:key="i"
2017-08-17 22:00:37 +05:30
class="label deploy-project-label"
2018-03-17 18:26:18 +05:30
:href="deployKeysProject.project.full_path"
:title="tooltipTitle(deployKeysProject)"
v-tooltip
2017-09-10 17:25:29 +05:30
>
2018-03-17 18:26:18 +05:30
{{ deployKeysProject.project.full_name }}
<i
v-if="!deployKeysProject.can_push"
aria-hidden="true"
class="fa fa-lock"
>
</i>
2017-08-17 22:00:37 +05:30
</a>
</div>
<div class="deploy-key-content">
<span class="key-created-at">
created {{ timeagoDate }}
</span>
2017-09-10 17:25:29 +05:30
<a
v-if="deployKey.can_edit"
2018-03-17 18:26:18 +05:30
class="btn btn-sm"
2017-09-10 17:25:29 +05:30
:href="editDeployKeyPath"
>
Edit
</a>
2017-08-17 22:00:37 +05:30
<action-btn
v-if="!isEnabled(deployKey.id)"
:deploy-key="deployKey"
2017-09-10 17:25:29 +05:30
type="enable"
/>
2017-08-17 22:00:37 +05:30
<action-btn
v-else-if="deployKey.destroyed_when_orphaned && deployKey.almost_orphaned"
:deploy-key="deployKey"
btn-css-class="btn-warning"
2017-09-10 17:25:29 +05:30
type="remove"
/>
2017-08-17 22:00:37 +05:30
<action-btn
v-else
:deploy-key="deployKey"
btn-css-class="btn-warning"
2017-09-10 17:25:29 +05:30
type="disable"
/>
2017-08-17 22:00:37 +05:30
</div>
</div>
</template>