-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathActionCard.vue
More file actions
96 lines (83 loc) · 2.51 KB
/
ActionCard.vue
File metadata and controls
96 lines (83 loc) · 2.51 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
<template>
<div v-if="suggestions.length > 0" class="action-card">
<div class="action-header">Quick Actions</div>
<div class="action-list">
<GButton
v-for="action in sortedSuggestions"
:key="`${action.action_type}-${action.description}`"
outline
size="small"
:color="action.priority === 1 ? 'blue' : 'grey'"
:disabled="processingAction"
@click="$emit('handle-action', action)">
<FontAwesomeIcon :icon="getIcon(action.action_type)" fixed-width />
<span>{{ action.description }}</span>
</GButton>
</div>
</div>
</template>
<script setup lang="ts">
import type { IconDefinition } from "@fortawesome/fontawesome-svg-core";
import {
faBook,
faExternalLinkAlt,
faFileImport,
faLifeRing,
faPencilAlt,
faPlay,
faSave,
faWrench,
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { computed } from "vue";
import { type ActionSuggestion, ActionType } from "@/composables/agentActions";
import GButton from "@/components/BaseComponents/GButton.vue";
interface Props {
suggestions: ActionSuggestion[];
processingAction?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
processingAction: false,
});
defineEmits<{
"handle-action": [action: ActionSuggestion];
}>();
const sortedSuggestions = computed(() => {
return [...props.suggestions].sort((a, b) => a.priority - b.priority);
});
const iconMap: Record<ActionType, IconDefinition> = {
[ActionType.TOOL_RUN]: faPlay,
[ActionType.SAVE_TOOL]: faSave,
[ActionType.CONTACT_SUPPORT]: faLifeRing,
[ActionType.REFINE_QUERY]: faPencilAlt,
[ActionType.DOCUMENTATION]: faBook,
[ActionType.VIEW_EXTERNAL]: faExternalLinkAlt,
[ActionType.WORKFLOW_IMPORT]: faFileImport,
};
function getIcon(actionType: ActionType): IconDefinition {
return iconMap[actionType] || faWrench;
}
</script>
<style lang="scss" scoped>
@import "@/style/scss/theme/blue.scss";
.action-card {
background: $white;
border: $border-default;
border-radius: $border-radius-base;
padding: 0.75rem;
margin-top: 0.75rem;
}
.action-header {
font-size: 0.75rem;
font-weight: 600;
color: $text-muted;
text-transform: uppercase;
letter-spacing: 0.025em;
margin-bottom: 0.5rem;
}
.action-list {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
</style>