summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/deploy_keys/components/key.vue
blob: 0a06a481b96861e343a15551292b48ddb120d2c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<script>
  import actionBtn from './action_btn.vue';

  export default {
    props: {
      deployKey: {
        type: Object,
        required: true,
      },
      store: {
        type: Object,
        required: true,
      },
    },
    components: {
      actionBtn,
    },
    computed: {
      timeagoDate() {
        return gl.utils.getTimeago().format(this.deployKey.created_at);
      },
    },
    methods: {
      isEnabled(id) {
        return this.store.findEnabledKey(id) !== undefined;
      },
    },
  };
</script>

<template>
  <div>
    <div class="pull-left append-right-10 hidden-xs">
      <i
        aria-hidden="true"
        class="fa fa-key key-icon">
      </i>
    </div>
    <div class="deploy-key-content key-list-item-info">
      <strong class="title">
        {{ deployKey.title }}
      </strong>
      <div class="description">
        {{ deployKey.fingerprint }}
      </div>
      <div
        v-if="deployKey.can_push"
        class="write-access-allowed">
        Write access allowed
      </div>
    </div>
    <div class="deploy-key-content prepend-left-default deploy-key-projects">
      <a
        v-for="project in deployKey.projects"
        class="label deploy-project-label"
        :href="project.full_path">
        {{ project.full_name }}
      </a>
    </div>
    <div class="deploy-key-content">
      <span class="key-created-at">
        created {{ timeagoDate }}
      </span>
      <action-btn
        v-if="!isEnabled(deployKey.id)"
        :deploy-key="deployKey"
        type="enable"/>
      <action-btn
        v-else-if="deployKey.destroyed_when_orphaned && deployKey.almost_orphaned"
        :deploy-key="deployKey"
        btn-css-class="btn-warning"
        type="remove" />
      <action-btn
        v-else
        :deploy-key="deployKey"
        btn-css-class="btn-warning"
        type="disable" />
    </div>
  </div>
</template>