api-client/components/environments/Environment.vue

92 lines
2.2 KiB
Vue
Raw Normal View History

2020-02-23 16:38:15 +00:00
<template>
2021-07-08 08:06:37 +00:00
<div class="flex items-center group">
<span
class="cursor-pointer flex w-10 justify-center items-center truncate"
2021-07-08 08:06:37 +00:00
@click="$emit('edit-environment')"
>
<i class="material-icons">layers</i>
</span>
<span
class="
cursor-pointer
flex flex-1
2021-07-17 17:40:28 +00:00
min-w-0
py-2
2021-07-17 17:40:28 +00:00
pr-2
2021-07-08 08:06:37 +00:00
transition
2021-07-17 17:40:28 +00:00
group-hover:text-secondaryDark
2021-07-08 08:06:37 +00:00
"
@click="$emit('edit-environment')"
>
<span class="truncate">
{{ environment.name }}
</span>
</span>
<span>
2021-08-06 16:10:26 +00:00
<tippy ref="options" interactive trigger="click" theme="popover" arrow>
<template #trigger>
<ButtonSecondary
v-tippy="{ theme: 'tooltip' }"
:title="$t('more')"
icon="more_vert"
/>
</template>
<SmartItem
icon="create"
:label="$t('edit')"
@click.native="
$emit('edit-environment')
$refs.options.tippy().hide()
"
/>
<SmartItem
2021-08-17 20:59:05 +00:00
v-if="!(environmentIndex === 'global')"
2021-08-17 07:26:36 +00:00
icon="remove_circle_outline"
color="red"
:label="$t('delete')"
@click.native="
confirmRemove = true
$refs.options.tippy().hide()
"
2021-07-05 12:56:00 +00:00
/>
</tippy>
</span>
<SmartConfirmModal
:show="confirmRemove"
2021-08-02 15:27:18 +00:00
:title="$t('confirm.remove_environment')"
@hide-modal="confirmRemove = false"
@resolve="removeEnvironment"
/>
2020-02-23 16:38:15 +00:00
</div>
</template>
<script lang="ts">
2021-08-17 20:59:05 +00:00
import { PropType } from "@nuxtjs/composition-api"
import Vue from "vue"
import { deleteEnvironment } from "~/newstore/environments"
export default Vue.extend({
2020-02-23 16:38:15 +00:00
props: {
2021-05-18 06:26:59 +00:00
environment: { type: Object, default: () => {} },
2021-08-17 20:59:05 +00:00
environmentIndex: {
type: [Number, String] as PropType<number | "global">,
default: null,
},
2020-02-23 16:38:15 +00:00
},
data() {
return {
confirmRemove: false,
}
},
2020-02-23 16:38:15 +00:00
methods: {
removeEnvironment() {
2021-08-17 20:59:05 +00:00
if (this.environmentIndex !== "global")
deleteEnvironment(this.environmentIndex)
this.$toast.error(this.$t("deleted").toString(), {
2020-08-16 11:56:33 +00:00
icon: "delete",
})
2020-02-24 18:44:50 +00:00
},
},
})
2020-02-23 16:38:15 +00:00
</script>