Sha256: 56fdec59823f711ea6ac633fcf686d52db2f1c11c7f8157a6d8a954106e876da

Contents?: true

Size: 1.53 KB

Versions: 18

Compression:

Stored size: 1.53 KB

Contents

<template>
  <div class="control" v-if="!isDeleted">
    <div
      class="tags has-addons are-medium"
      v-on:mouseover="showDeleteButton"
      v-on:mouseleave="hideDeleteButton"
    >
      <router-link
        class="tag is-link is-light"
        :to="{ name: 'Artifact', params: { id: artifact.id } }"
        >{{ artifact.data }}</router-link
      >
      <span class="tag is-delete" v-if="isDeleteButtonEnabled" @click="deleteArtifact"></span>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, type PropType, ref } from "vue"

import { generateDeleteArtifactTask } from "@/api-helper"
import type { Artifact } from "@/types"

export default defineComponent({
  name: "ArtifactTag",
  props: {
    artifact: {
      type: Object as PropType<Artifact>,
      required: true
    }
  },
  setup(props) {
    const isDeleted = ref(false)
    const isDeleteButtonEnabled = ref(false)

    const deleteArtifactTask = generateDeleteArtifactTask()

    const deleteArtifact = async () => {
      const result = window.confirm(`Are you sure you want to delete ${props.artifact.data}?`)

      if (result) {
        await deleteArtifactTask.perform(props.artifact.id)
        isDeleted.value = true
      }
    }

    const showDeleteButton = () => {
      isDeleteButtonEnabled.value = true
    }

    const hideDeleteButton = () => {
      isDeleteButtonEnabled.value = false
    }

    return {
      isDeleted,
      deleteArtifact,
      showDeleteButton,
      hideDeleteButton,
      isDeleteButtonEnabled
    }
  }
})
</script>

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mihari-5.7.0 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.6.2 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.6.1 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.6.0 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.5.0 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.4.9 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.4.8 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.4.7 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.4.6 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.4.5 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.4.4 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.4.3 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.4.2 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.4.1 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.4.0 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.3.2 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.3.1 frontend/src/components/artifact/ArtifactTag.vue
mihari-5.3.0 frontend/src/components/artifact/ArtifactTag.vue