|
| 1 | +<script setup lang="ts"> |
| 2 | +import { faBezierCurve, faProjectDiagram, faTrash } from "@fortawesome/free-solid-svg-icons"; |
| 3 | +import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; |
| 4 | +import { BButton, BButtonGroup } from "bootstrap-vue"; |
| 5 | +import { computed, ref, toRef } from "vue"; |
| 6 | +
|
| 7 | +import GraphDetails from "@/components/Graph/GraphDetails.vue"; |
| 8 | +import GraphView from "@/components/Graph/GraphView.vue"; |
| 9 | +import type { GraphNode } from "@/components/Graph/types"; |
| 10 | +import LoadingSpan from "@/components/LoadingSpan.vue"; |
| 11 | +
|
| 12 | +import { buildDetails } from "./historyGraphMapper"; |
| 13 | +import { useHistoryGraphData } from "./useHistoryGraphData"; |
| 14 | +import { type EdgeStyle, useHistoryGraphLayout } from "./useHistoryGraphLayout"; |
| 15 | +
|
| 16 | +interface Props { |
| 17 | + historyId: string; |
| 18 | + seedNodeId?: string; |
| 19 | +} |
| 20 | +
|
| 21 | +const props = defineProps<Props>(); |
| 22 | +
|
| 23 | +// Fetch params — product decisions owned here |
| 24 | +const limit = ref(500); |
| 25 | +const includeDeleted = ref(false); |
| 26 | +
|
| 27 | +const { graphData, loading, error } = useHistoryGraphData( |
| 28 | + toRef(props, "historyId"), |
| 29 | + limit, |
| 30 | + includeDeleted, |
| 31 | + toRef(props, "seedNodeId"), |
| 32 | +); |
| 33 | +
|
| 34 | +// Layout |
| 35 | +const edgeStyle = ref<EdgeStyle>("orthogonal"); |
| 36 | +const { layout, layoutLoading } = useHistoryGraphLayout(graphData, edgeStyle); |
| 37 | +
|
| 38 | +// Selection |
| 39 | +const selectedNode = ref<GraphNode | null>(null); |
| 40 | +const selectedDetails = computed(() => { |
| 41 | + if (!selectedNode.value) { |
| 42 | + return []; |
| 43 | + } |
| 44 | + return buildDetails(selectedNode.value); |
| 45 | +}); |
| 46 | +
|
| 47 | +function onNodeSelected(node: GraphNode | null) { |
| 48 | + selectedNode.value = node; |
| 49 | +} |
| 50 | +
|
| 51 | +const isLoading = computed(() => loading.value || layoutLoading.value); |
| 52 | +const isTruncated = computed(() => { |
| 53 | + const t = graphData.value?.truncated; |
| 54 | + return t?.item_count_capped || t?.tool_request_count_capped || (t?.tool_requests_omitted ?? 0) > 0; |
| 55 | +}); |
| 56 | +</script> |
| 57 | + |
| 58 | +<template> |
| 59 | + <div class="history-graph-view"> |
| 60 | + <LoadingSpan v-if="isLoading" message="Loading history graph" /> |
| 61 | + |
| 62 | + <div v-else-if="error" class="history-graph-error alert alert-danger m-3">{{ error }}</div> |
| 63 | + |
| 64 | + <template v-else> |
| 65 | + <div class="history-graph-toolbar"> |
| 66 | + <BButtonGroup size="sm"> |
| 67 | + <BButton |
| 68 | + :pressed="edgeStyle === 'orthogonal'" |
| 69 | + variant="outline-primary" |
| 70 | + title="Orthogonal edges" |
| 71 | + @click="edgeStyle = 'orthogonal'"> |
| 72 | + <FontAwesomeIcon :icon="faProjectDiagram" /> |
| 73 | + </BButton> |
| 74 | + <BButton |
| 75 | + :pressed="edgeStyle === 'curved'" |
| 76 | + variant="outline-primary" |
| 77 | + title="Curved edges" |
| 78 | + @click="edgeStyle = 'curved'"> |
| 79 | + <FontAwesomeIcon :icon="faBezierCurve" /> |
| 80 | + </BButton> |
| 81 | + </BButtonGroup> |
| 82 | + <BButtonGroup size="sm" class="ml-2"> |
| 83 | + <BButton |
| 84 | + :pressed="includeDeleted" |
| 85 | + variant="outline-primary" |
| 86 | + title="Show deleted items" |
| 87 | + @click="includeDeleted = !includeDeleted"> |
| 88 | + <FontAwesomeIcon :icon="faTrash" /> |
| 89 | + </BButton> |
| 90 | + </BButtonGroup> |
| 91 | + </div> |
| 92 | + <GraphView |
| 93 | + :layout="layout" |
| 94 | + :focus-node-id="seedNodeId ?? null" |
| 95 | + :edge-style="edgeStyle" |
| 96 | + @node-selected="onNodeSelected" /> |
| 97 | + <GraphDetails :node="selectedNode" :details="selectedDetails" /> |
| 98 | + <div v-if="isTruncated" class="history-graph-truncation"> |
| 99 | + Showing a partial graph. Not all connections are visible. |
| 100 | + </div> |
| 101 | + </template> |
| 102 | + </div> |
| 103 | +</template> |
| 104 | + |
| 105 | +<style lang="scss" scoped> |
| 106 | +@import "@/style/scss/theme/blue.scss"; |
| 107 | +
|
| 108 | +.history-graph-view { |
| 109 | + display: flex; |
| 110 | + flex-direction: column; |
| 111 | + height: 100%; |
| 112 | + min-height: 400px; |
| 113 | +} |
| 114 | +
|
| 115 | +.history-graph-toolbar { |
| 116 | + position: absolute; |
| 117 | + top: 0.5rem; |
| 118 | + right: 0.5rem; |
| 119 | + z-index: 20; |
| 120 | +} |
| 121 | +
|
| 122 | +.history-graph-truncation { |
| 123 | + padding: 0.375rem 1rem; |
| 124 | + background: $state-warning-bg; |
| 125 | + color: $state-warning-text; |
| 126 | + font-size: $h6-font-size; |
| 127 | + text-align: center; |
| 128 | + border-top: 1px solid $state-warning-border; |
| 129 | +} |
| 130 | +
|
| 131 | +/* Tool request nodes use primary header (no dataset state) */ |
| 132 | +:deep(.node-tool-request) .graph-node-header { |
| 133 | + background: $brand-primary; |
| 134 | + color: $white; |
| 135 | +} |
| 136 | +
|
| 137 | +/* Dataset/collection nodes use state-driven coloring via data-state attribute */ |
| 138 | +:deep(.node-dataset) .graph-node-header, |
| 139 | +:deep(.node-collection) .graph-node-header { |
| 140 | + color: $text-color; |
| 141 | +} |
| 142 | +
|
| 143 | +:deep(.edge-collection) { |
| 144 | + stroke: $brand-info; |
| 145 | + stroke-dasharray: 6 3; |
| 146 | +} |
| 147 | +
|
| 148 | +:deep(.edge-dataset) { |
| 149 | + stroke: $brand-primary; |
| 150 | +} |
| 151 | +</style> |
0 commit comments