WorkflowActions.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <ui-card padding="p-1">
  3. <button
  4. v-for="item in modalActions"
  5. :key="item.id"
  6. v-tooltip.group="item.name"
  7. class="hoverable p-2 rounded-lg"
  8. @click="$emit('showModal', item.id)"
  9. >
  10. <v-remixicon :name="item.icon" />
  11. </button>
  12. </ui-card>
  13. <ui-card padding="p-1 ml-4">
  14. <button
  15. v-if="!workflow.isDisabled"
  16. v-tooltip.group="t('common.execute')"
  17. icon
  18. class="hoverable p-2 rounded-lg"
  19. @click="$emit('execute')"
  20. >
  21. <v-remixicon name="riPlayLine" />
  22. </button>
  23. <button
  24. v-else
  25. v-tooltip="t('workflow.clickToEnable')"
  26. class="p-2"
  27. @click="$emit('update', { isDisabled: false })"
  28. >
  29. {{ t('common.disabled') }}
  30. </button>
  31. </ui-card>
  32. <ui-card padding="p-1 ml-4 space-x-1">
  33. <ui-popover>
  34. <template #trigger>
  35. <button class="rounded-lg p-2 hoverable">
  36. <v-remixicon name="riMore2Line" />
  37. </button>
  38. </template>
  39. <ui-list class="w-36">
  40. <ui-list-item
  41. class="cursor-pointer"
  42. @click="$emit('update', { isDisabled: !workflow.isDisabled })"
  43. >
  44. <v-remixicon name="riToggleLine" class="mr-2 -ml-1" />
  45. {{ t(`common.${workflow.isDisabled ? 'enable' : 'disable'}`) }}
  46. </ui-list-item>
  47. <ui-list-item
  48. v-for="item in moreActions"
  49. :key="item.id"
  50. v-close-popover
  51. class="cursor-pointer"
  52. @click="$emit(item.id)"
  53. >
  54. <v-remixicon :name="item.icon" class="mr-2 -ml-1" />
  55. {{ item.name }}
  56. </ui-list-item>
  57. </ui-list>
  58. </ui-popover>
  59. <ui-button variant="accent" class="relative" @click="$emit('save')">
  60. <span
  61. v-if="isDataChanged"
  62. class="flex h-3 w-3 absolute top-0 left-0 -ml-1 -mt-1"
  63. >
  64. <span
  65. class="
  66. animate-ping
  67. absolute
  68. inline-flex
  69. h-full
  70. w-full
  71. rounded-full
  72. bg-primary
  73. opacity-75
  74. "
  75. ></span>
  76. <span
  77. class="relative inline-flex rounded-full h-3 w-3 bg-blue-600"
  78. ></span>
  79. </span>
  80. <v-remixicon name="riSaveLine" class="mr-2 -ml-1 my-1" />
  81. {{ t('common.save') }}
  82. </ui-button>
  83. </ui-card>
  84. </template>
  85. <script setup>
  86. import { useI18n } from 'vue-i18n';
  87. import { useGroupTooltip } from '@/composable/groupTooltip';
  88. defineProps({
  89. isDataChanged: {
  90. type: Boolean,
  91. default: false,
  92. },
  93. workflow: {
  94. type: Object,
  95. default: () => ({}),
  96. },
  97. });
  98. defineEmits([
  99. 'showModal',
  100. 'execute',
  101. 'rename',
  102. 'delete',
  103. 'save',
  104. 'export',
  105. 'update',
  106. ]);
  107. useGroupTooltip();
  108. const { t } = useI18n();
  109. const modalActions = [
  110. {
  111. id: 'data-columns',
  112. name: t('workflow.dataColumns.title'),
  113. icon: 'riKey2Line',
  114. },
  115. {
  116. id: 'global-data',
  117. name: t('common.globalData'),
  118. icon: 'riDatabase2Line',
  119. },
  120. {
  121. id: 'settings',
  122. name: t('common.settings'),
  123. icon: 'riSettings3Line',
  124. },
  125. ];
  126. const moreActions = [
  127. {
  128. id: 'export',
  129. name: t('common.export'),
  130. icon: 'riDownloadLine',
  131. },
  132. {
  133. id: 'rename',
  134. name: t('common.rename'),
  135. icon: 'riPencilLine',
  136. },
  137. {
  138. id: 'delete',
  139. name: t('common.delete'),
  140. icon: 'riDeleteBin7Line',
  141. },
  142. ];
  143. </script>