api-client/components/environments/Environment.vue

91 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
2021-08-20 09:38:54 +00:00
class="cursor-pointer flex px-4 justify-center items-center"
2021-07-08 08:06:37 +00:00
@click="$emit('edit-environment')"
>
2021-08-28 00:17:33 +00:00
<SmartIcon class="svg-icons" name="layers" />
2021-07-08 08:06:37 +00:00
</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('action.more')"
2021-08-28 00:17:33 +00:00
svg="more-vertical"
/>
</template>
<SmartItem
2021-08-28 00:17:33 +00:00
svg="edit"
:label="$t('action.edit')"
@click.native="
$emit('edit-environment')
$refs.options.tippy().hide()
"
/>
<SmartItem
v-if="!(environmentIndex === 'Global')"
2021-08-28 00:17:33 +00:00
svg="trash-2"
color="red"
:label="$t('action.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-24 03:44:46 +00:00
import { defineComponent, PropType } from "@nuxtjs/composition-api"
import { deleteEnvironment } from "~/newstore/environments"
2021-08-24 03:44:46 +00:00
export default defineComponent({
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">,
2021-08-17 20:59:05 +00:00
default: null,
},
2020-02-23 16:38:15 +00:00
},
data() {
return {
confirmRemove: false,
}
},
2020-02-23 16:38:15 +00:00
methods: {
removeEnvironment() {
if (this.environmentIndex !== "Global")
2021-08-17 20:59:05 +00:00
deleteEnvironment(this.environmentIndex)
2021-08-20 09:38:54 +00:00
this.$toast.success(this.$t("state.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>