-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathWorkflowCardList.vue
More file actions
173 lines (151 loc) · 5.58 KB
/
WorkflowCardList.vue
File metadata and controls
173 lines (151 loc) · 5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<script setup lang="ts">
import { reactive, type Ref, ref } from "vue";
import type { WorkflowSummary } from "@/api/workflows";
import { updateWorkflow } from "@/components/Workflow/workflows.services";
import type { SelectedWorkflow } from "./types";
import WorkflowCard from "./WorkflowCard.vue";
import GModal from "@/components/BaseComponents/GModal.vue";
import WorkflowRename from "@/components/Common/RenameModal.vue";
import WorkflowPublished from "@/components/Workflow/Published/WorkflowPublished.vue";
import WorkflowPublishedButtons from "@/components/Workflow/Published/WorkflowPublishedButtons.vue";
interface Props {
workflows: WorkflowSummary[];
gridView?: boolean;
hideRuns?: boolean;
filterable?: boolean;
publishedView?: boolean;
editorView?: boolean;
currentWorkflowId?: string;
selectedWorkflowIds?: SelectedWorkflow[];
itemRefs?: Record<string, Ref<InstanceType<typeof WorkflowCard> | null>>;
rangeSelectAnchor?: WorkflowSummary;
clickable?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
gridView: false,
hideRuns: false,
filterable: true,
publishedView: false,
editorView: false,
currentWorkflowId: "",
selectedWorkflowIds: () => [],
itemRefs: () => ({}),
rangeSelectAnchor: undefined,
});
const emit = defineEmits<{
(e: "select", workflow: WorkflowSummary): void;
(e: "tagClick", tag: string): void;
(e: "refreshList", overlayLoading?: boolean, silent?: boolean): void;
(e: "updateFilter", key: string, value: any): void;
(e: "insertWorkflow", id: string, name: string): void;
(e: "insertWorkflowSteps", id: string, stepCount: number): void;
(e: "on-key-down", workflow: WorkflowSummary, event: KeyboardEvent): void;
(e: "on-workflow-card-click", workflow: WorkflowSummary, event: Event): void;
}>();
const modalOptions = reactive({
rename: {
id: "",
name: "",
},
preview: {
id: "",
},
});
const showRename = ref(false);
const showPreview = ref(false);
function onRenameClose() {
showRename.value = false;
emit("refreshList", true, true);
}
function onRename(id: string, name: string) {
modalOptions.rename.id = id;
modalOptions.rename.name = name;
showRename.value = true;
}
function onPreview(id: string) {
modalOptions.preview.id = id;
showPreview.value = true;
}
// TODO: clean-up types, as soon as better Workflow type is available
function onInsert(workflow: WorkflowSummary) {
emit("insertWorkflow", workflow.latest_workflow_id, workflow.name);
}
function onInsertSteps(workflow: WorkflowSummary) {
emit("insertWorkflowSteps", workflow.id, workflow.number_of_steps as any);
}
const workflowPublished = ref<InstanceType<typeof WorkflowPublished>>();
</script>
<template>
<div class="workflow-card-list d-flex flex-wrap overflow-auto pt-1">
<WorkflowCard
v-for="workflow in workflows"
:ref="props.itemRefs[workflow.id]"
:key="workflow.id"
tabindex="0"
:workflow="workflow"
:selectable="!publishedView && !editorView"
:selected="props.selectedWorkflowIds.some((w) => w.id === workflow.id)"
:grid-view="props.gridView"
:hide-runs="props.hideRuns"
:filterable="props.filterable"
:published-view="props.publishedView"
:editor-view="props.editorView"
:current="workflow.id === props.currentWorkflowId"
:clickable="props.clickable"
:highlighted="props.rangeSelectAnchor?.id === workflow.id"
class="workflow-card-in-list"
@select="(...args) => emit('select', ...args)"
@tagClick="(...args) => emit('tagClick', ...args)"
@refreshList="(...args) => emit('refreshList', ...args)"
@updateFilter="(...args) => emit('updateFilter', ...args)"
@rename="onRename"
@preview="onPreview"
@insert="onInsert(workflow)"
@insertSteps="onInsertSteps(workflow)"
@on-key-down="(...args) => emit('on-key-down', ...args)"
@on-workflow-card-click="(...args) => emit('on-workflow-card-click', ...args)" />
<WorkflowRename
v-if="showRename"
item-type="workflow"
:name="modalOptions.rename.name"
:rename-action="(newName) => updateWorkflow(modalOptions.rename.id, { name: newName })"
@close="onRenameClose" />
<GModal
:show.sync="showPreview"
size="large"
title="Workflow Preview"
hide-header
fixed-height
class="workflow-card-preview-modal"
centered>
<template v-slot:header>
<WorkflowPublishedButtons
v-if="workflowPublished?.workflowInfo"
:id="modalOptions.preview.id"
:workflow-info="workflowPublished?.workflowInfo" />
</template>
<WorkflowPublished
v-if="showPreview"
:id="modalOptions.preview.id"
ref="workflowPublished"
:show-heading="false"
:show-buttons="false"
quick-view />
</GModal>
</div>
</template>
<style lang="scss">
.workflow-card-preview-modal {
max-width: min(1400px, calc(100% - 200px));
.modal-content {
height: min(800px, calc(100vh - 80px));
}
}
</style>
<style scoped lang="scss">
@import "@/style/scss/theme/blue.scss";
@import "@/style/scss/_breakpoints.scss";
.workflow-card-list {
container: cards-list / inline-size;
}
</style>