Skip to content

Commit 0e4a8c0

Browse files
authored
iris: add job name copy btn (#3651)
Add job name copy button to the jobs and job view.
1 parent 078a192 commit 0e4a8c0

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

lib/iris/dashboard/src/components/controller/JobDetail.vue

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ const tasks = ref<TaskStatus[]>([])
3333
const loading = ref(true)
3434
const error = ref<string | null>(null)
3535
const profilingTaskId = ref<string | null>(null)
36+
const copiedName = ref(false)
37+
38+
async function copyJobName() {
39+
const name = job.value?.name
40+
if (!name) return
41+
await navigator.clipboard.writeText(name)
42+
copiedName.value = true
43+
setTimeout(() => { copiedName.value = false }, 1500)
44+
}
3645
3746
// -- Fetch --
3847
@@ -210,6 +219,24 @@ async function handleProfile(taskId: string, profilerType: string, format: strin
210219

211220
<template>
212221
<PageShell :title="pageTitle" back-to="/" back-label="Jobs">
222+
<template v-if="job?.name" #title-suffix>
223+
<button
224+
class="inline-flex items-center gap-1 px-1.5 py-0.5 text-xs text-text-muted hover:text-text
225+
border border-surface-border rounded hover:bg-surface-raised transition-colors"
226+
title="Copy job name"
227+
@click="copyJobName"
228+
>
229+
<svg v-if="copiedName" class="w-3 h-3 text-status-success" viewBox="0 0 20 20" fill="currentColor">
230+
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" />
231+
</svg>
232+
<svg v-else class="w-3 h-3" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
233+
<rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
234+
<path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1" />
235+
</svg>
236+
{{ copiedName ? 'Copied' : 'Copy name' }}
237+
</button>
238+
</template>
239+
213240
<!-- Subtitle (job ID when name differs) -->
214241
<p v-if="subtitle" class="text-sm text-text-secondary font-mono -mt-4 mb-6">
215242
{{ subtitle }}

lib/iris/dashboard/src/components/controller/JobsTab.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ const SORT_FIELD_MAP: Record<string, string> = {
2222
type SortField = 'date' | 'name' | 'state' | 'failures' | 'preemptions'
2323
type SortDir = 'asc' | 'desc'
2424
25+
const copiedJob = ref<string | null>(null)
26+
27+
async function copyJobName(name: string) {
28+
await navigator.clipboard.writeText(name)
29+
copiedJob.value = name
30+
setTimeout(() => { copiedJob.value = null }, 1500)
31+
}
32+
2533
const EXPANDED_JOBS_KEY = 'iris.controller.expandedJobs'
2634
2735
// -- State --
@@ -359,7 +367,7 @@ function sortIndicator(field: SortField): string {
359367
<tr
360368
v-for="node in flattenedJobs"
361369
:key="node.job.jobId"
362-
class="border-b border-surface-border-subtle hover:bg-surface-raised transition-colors"
370+
class="group/row border-b border-surface-border-subtle hover:bg-surface-raised transition-colors"
363371
>
364372
<!-- Name -->
365373
<td
@@ -381,6 +389,20 @@ function sortIndicator(field: SortField): string {
381389
>
382390
{{ node.depth > 0 ? getLeafName(node.job.name) : (node.job.name || 'unnamed') }}
383391
</RouterLink>
392+
<button
393+
v-if="node.job.name"
394+
class="ml-1 text-text-muted hover:text-text opacity-0 group-hover/row:opacity-100 transition-opacity"
395+
title="Copy job name"
396+
@click.stop="copyJobName(node.job.name)"
397+
>
398+
<svg v-if="copiedJob === node.job.name" class="w-3.5 h-3.5 text-status-success" viewBox="0 0 20 20" fill="currentColor">
399+
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" />
400+
</svg>
401+
<svg v-else class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
402+
<rect x="9" y="9" width="13" height="13" rx="2" ry="2" />
403+
<path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1" />
404+
</svg>
405+
</button>
384406
</span>
385407
</td>
386408

lib/iris/dashboard/src/components/layout/PageShell.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ defineProps<{
1919
&larr; {{ backLabel ?? 'Back' }}
2020
</RouterLink>
2121
</div>
22-
<h2 class="text-xl font-semibold text-text font-mono mb-6">{{ title }}</h2>
22+
<div class="flex items-center gap-2 mb-6">
23+
<h2 class="text-xl font-semibold text-text font-mono">{{ title }}</h2>
24+
<slot name="title-suffix" />
25+
</div>
2326
<slot />
2427
</div>
2528
</template>

0 commit comments

Comments
 (0)