Skip to content

Commit 780df9f

Browse files
author
Lasim
committed
refactor: remove unused components and consolidate credential table logic
- Deleted `columns.ts`, `GitHubIcon.vue`, `IconCommunity.vue`, `IconDocumentation.vue`, `IconEcosystem.vue`, `IconSupport.vue`, and `IconTooling.vue` as they were no longer needed. - Introduced `CredentialsTable.vue` to encapsulate credential display logic and improve code organization. - Updated `Credentials.vue` to utilize the new `CredentialsTable` component, simplifying the view logic. - Enhanced `CredentialDetail.vue` with dropdown actions for editing and updating credentials. - Added new translation keys for credential actions in `credentials.ts`. - Cleaned up unused imports and variables across various components.
1 parent 34458f2 commit 780df9f

File tree

16 files changed

+208
-624
lines changed

16 files changed

+208
-624
lines changed

services/frontend/src/components/TheWelcome.vue

Lines changed: 0 additions & 94 deletions
This file was deleted.

services/frontend/src/components/WelcomeItem.vue

Lines changed: 0 additions & 87 deletions
This file was deleted.

services/frontend/src/components/credentials/AddCredentialDialog.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script setup lang="ts">
22
import { ref, computed, onMounted, watch } from 'vue'
33
import { useI18n } from 'vue-i18n'
4-
import { z } from 'zod'
54
import { Button } from '@/components/ui/button'
65
import { Card } from '@/components/ui/card'
76
import { Input } from '@/components/ui/input'
@@ -138,7 +137,7 @@ const validateField = (fieldKey: string, value: string) => {
138137
if (!regex.test(value)) {
139138
errors.push(t('credentials.form.validation.pattern', { field: field.label }))
140139
}
141-
} catch (e) {
140+
} catch {
142141
console.warn('Invalid regex pattern for field:', fieldKey, field.validation.pattern)
143142
}
144143
}
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<script setup lang="ts">
2+
import { Badge } from '@/components/ui/badge'
3+
import { Button } from '@/components/ui/button'
4+
import { Settings } from 'lucide-vue-next'
5+
import type { CloudCredential, CloudCredentialBasic } from '@/types/credentials'
6+
7+
interface Props {
8+
credentials: (CloudCredential | CloudCredentialBasic)[]
9+
onManage: (credentialId: string) => void
10+
}
11+
12+
const props = defineProps<Props>()
13+
14+
const formatDate = (dateString: string) => {
15+
const date = new Date(dateString)
16+
return date.toLocaleDateString('en-US', {
17+
year: 'numeric',
18+
month: 'short',
19+
day: 'numeric'
20+
})
21+
}
22+
23+
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
24+
const getCreatedByDisplay = (createdBy: any) => {
25+
if (typeof createdBy === 'object' && createdBy?.username) {
26+
return {
27+
username: createdBy.username,
28+
email: createdBy.email
29+
}
30+
}
31+
return {
32+
username: typeof createdBy === 'string' ? createdBy : 'Unknown',
33+
email: null
34+
}
35+
}
36+
</script>
37+
38+
<template>
39+
<div class="rounded-md border">
40+
<table class="w-full">
41+
<thead>
42+
<tr class="border-b">
43+
<th class="h-12 px-4 text-left align-middle font-medium text-muted-foreground">
44+
Name
45+
</th>
46+
<th class="h-12 px-4 text-left align-middle font-medium text-muted-foreground">
47+
Provider
48+
</th>
49+
<th class="h-12 px-4 text-left align-middle font-medium text-muted-foreground">
50+
Comment
51+
</th>
52+
<th class="h-12 px-4 text-left align-middle font-medium text-muted-foreground">
53+
Created By
54+
</th>
55+
<th class="h-12 px-4 text-left align-middle font-medium text-muted-foreground">
56+
Created
57+
</th>
58+
<th class="h-12 px-4 text-right align-middle font-medium text-muted-foreground">
59+
Manage
60+
</th>
61+
</tr>
62+
</thead>
63+
<tbody>
64+
<tr
65+
v-for="credential in credentials"
66+
:key="credential.id"
67+
class="border-b transition-colors hover:bg-muted/50"
68+
>
69+
<!-- Name -->
70+
<td class="p-4 align-middle">
71+
<div class="font-medium">{{ credential.name }}</div>
72+
</td>
73+
74+
<!-- Provider -->
75+
<td class="p-4 align-middle">
76+
<div class="flex items-center gap-2">
77+
<img
78+
:src="`/images/provider/${credential.provider.id}.svg`"
79+
:alt="credential.provider.name"
80+
class="w-5 h-5"
81+
@error="($event.target as HTMLImageElement).style.display = 'none'"
82+
/>
83+
<Badge variant="secondary">{{ credential.provider.name }}</Badge>
84+
</div>
85+
</td>
86+
87+
<!-- Comment -->
88+
<td class="p-4 align-middle">
89+
<div
90+
:class="credential.comment ? 'text-sm' : 'text-sm text-muted-foreground italic'"
91+
>
92+
{{ credential.comment || 'No comment' }}
93+
</div>
94+
</td>
95+
96+
<!-- Created By -->
97+
<td class="p-4 align-middle">
98+
<div class="text-sm">
99+
<div class="font-medium">{{ getCreatedByDisplay(credential.createdBy).username }}</div>
100+
<div
101+
v-if="getCreatedByDisplay(credential.createdBy).email"
102+
class="text-xs text-muted-foreground"
103+
>
104+
{{ getCreatedByDisplay(credential.createdBy).email }}
105+
</div>
106+
</div>
107+
</td>
108+
109+
<!-- Created -->
110+
<td class="p-4 align-middle">
111+
<div class="text-sm text-muted-foreground">
112+
{{ formatDate(credential.createdAt) }}
113+
</div>
114+
</td>
115+
116+
<!-- Manage -->
117+
<td class="p-4 align-middle">
118+
<div class="flex justify-end">
119+
<Button
120+
variant="outline"
121+
size="sm"
122+
class="h-8 px-3"
123+
@click="props.onManage(credential.id)"
124+
>
125+
<Settings class="h-4 w-4 mr-1" />
126+
Manage
127+
</Button>
128+
</div>
129+
</td>
130+
</tr>
131+
132+
<!-- Empty state -->
133+
<tr v-if="credentials.length === 0">
134+
<td colspan="6" class="h-24 text-center">
135+
No credentials found
136+
</td>
137+
</tr>
138+
</tbody>
139+
</table>
140+
</div>
141+
</template>

0 commit comments

Comments
 (0)