WorkflowsShared.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <shared-card
  3. v-for="workflow in workflows"
  4. :key="workflow.id"
  5. :data="workflow"
  6. :show-details="false"
  7. @execute="executeWorkflow(workflow)"
  8. @click="$router.push(`/workflows/${$event.id}/shared`)"
  9. />
  10. </template>
  11. <script setup>
  12. import { computed } from 'vue';
  13. import { useSharedWorkflowStore } from '@/stores/sharedWorkflow';
  14. import { arraySorter } from '@/utils/helper';
  15. import { executeWorkflow } from '@/newtab/workflowEngine';
  16. import SharedCard from '@/components/newtab/shared/SharedCard.vue';
  17. const props = defineProps({
  18. search: {
  19. type: String,
  20. default: '',
  21. },
  22. sort: {
  23. type: Object,
  24. default: () => ({
  25. by: '',
  26. order: '',
  27. }),
  28. },
  29. });
  30. const sharedWorkflowStore = useSharedWorkflowStore();
  31. const workflows = computed(() => {
  32. const filtered = sharedWorkflowStore.toArray.filter(({ name }) =>
  33. name.toLocaleLowerCase().includes(props.search.toLocaleLowerCase())
  34. );
  35. return arraySorter({
  36. data: filtered,
  37. key: props.sort.by,
  38. order: props.sort.order,
  39. });
  40. });
  41. </script>