main
vue 90 lines 2.6 KB
Raw
1 <template>
2 <CardEntity>
3 <template #headerMain>
4 <div class="flex items-center gap-3">
5 <Icon name="codicon:organization" :size="20" />
6
7 <div class="text-default font-display text-lg font-semibold">
8 {{ config.organization }}
9 </div>
10 </div>
11 </template>
12 <template #headerExtra>
13 <div class="flex items-center justify-end gap-2">
14 <n-tag v-if="config.enabled" type="success" size="small">Enabled</n-tag>
15 <n-tag v-else type="error" size="small">Disabled</n-tag>
16
17 <n-tag v-if="config.auto_audit_enabled" type="success" size="small">Scheduled</n-tag>
18 <n-tag v-else type="error" size="small">Not scheduled</n-tag>
19 </div>
20 </template>
21 <template #default>
22 <GitHubAuditConfigSummary :config meta-fields="card" />
23 </template>
24 <template #footerMain>
25 <GitHubAuditScopeFlags :config />
26 </template>
27 <template #footerExtra>
28 <div class="flex flex-wrap items-center justify-end gap-2">
29 <n-button size="small" quaternary :loading="running" @click.stop="runAudit">
30 <template #icon>
31 <Icon :name="PlayIcon" />
32 </template>
33 Run Audit
34 </n-button>
35 <n-button size="small" @click.stop="$emit('edit', config)">
36 <template #icon>
37 <Icon :name="EditIcon" />
38 </template>
39 Edit
40 </n-button>
41 <n-button size="small" type="primary" secondary @click.stop="$emit('click', config)">
42 <template #icon>
43 <Icon :name="DetailIcon" />
44 </template>
45 View Details
46 </n-button>
47 </div>
48 </template>
49 </CardEntity>
50 </template>
51
52 <script setup lang="ts">
53 import type { GitHubAuditConfig } from "@/types/githubAudit.d"
54 import { NButton, NTag, useMessage } from "naive-ui"
55 import { ref } from "vue"
56 import Api from "@/api"
57 import Icon from "@/components/common/Icon.vue"
58 import CardEntity from "../common/cards/CardEntity.vue"
59 import GitHubAuditConfigSummary from "./GitHubAuditConfigSummary.vue"
60 import GitHubAuditScopeFlags from "./GitHubAuditScopeFlags.vue"
61
62 const props = defineProps<{
63 config: GitHubAuditConfig
64 }>()
65 const emit = defineEmits<{
66 (e: "click", config: GitHubAuditConfig): void
67 (e: "edit", config: GitHubAuditConfig): void
68 (e: "audit-complete"): void
69 }>()
70
71 const PlayIcon = "carbon:play"
72 const EditIcon = "carbon:edit"
73 const DetailIcon = "carbon:view"
74
75 const message = useMessage()
76 const running = ref(false)
77
78 async function runAudit() {
79 running.value = true
80 try {
81 await Api.githubAudit.runAuditFromConfig(props.config.id)
82 message.success("Audit completed successfully")
83 emit("audit-complete")
84 } catch (error: any) {
85 message.error(error.response?.data?.detail || "Failed to run audit")
86 } finally {
87 running.value = false
88 }
89 }
90 </script>