Skip to content

Commit f98d649

Browse files
move update actions into channel selection area (#69)
Move Update Now and Copy & Update buttons from the section actions into the channel field's channelActions so they appear mutually exclusive with the Switch Channel button. Check for Updates remains as a standalone section action. Amp-Thread-ID: https://ampcode.com/threads/T-019ca6df-24c7-750c-bbc0-fdefff59f674 Co-authored-by: Amp <amp@ampcode.com>
1 parent 11c2296 commit f98d649

5 files changed

Lines changed: 35 additions & 19 deletions

File tree

src/main/sources/portable.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,11 @@ export const portable: SourcePlugin = {
155155
}
156156
})
157157

158-
const updateFields: Record<string, unknown>[] = [
159-
{ id: 'updateChannel', label: t('portable.updateChannel'), value: channel, editable: true,
160-
refreshSection: true, onChangeAction: 'check-update', editType: 'channel-cards', options: channelOptions },
161-
]
162-
const updateActions: Record<string, unknown>[] = []
158+
const channelActions: Record<string, unknown>[] = []
163159
if (info && releaseCache.isUpdateAvailable(installation, channel, info)) {
164160
const msgKey = channel === 'latest' ? 'portable.updateConfirmMessageLatest' : 'portable.updateConfirmMessage'
165161
const notes = truncateNotes(info.releaseNotes || '', 2000)
166-
updateActions.push({
162+
channelActions.push({
167163
id: 'update-comfyui', label: t('portable.updateNow'), style: 'primary', enabled: installed,
168164
showProgress: true, progressTitle: t('portable.updatingTitle', { version: info.latestTag || '' }),
169165
confirm: {
@@ -177,9 +173,14 @@ export const portable: SourcePlugin = {
177173
},
178174
})
179175
}
180-
updateActions.push({
181-
id: 'check-update', label: t('actions.checkForUpdate'), style: 'default', enabled: installed,
182-
})
176+
const updateFields: Record<string, unknown>[] = [
177+
{ id: 'updateChannel', label: t('portable.updateChannel'), value: channel, editable: true,
178+
refreshSection: true, onChangeAction: 'check-update', editType: 'channel-cards', options: channelOptions,
179+
channelActions: channelActions.length ? channelActions : undefined },
180+
]
181+
const updateActions: Record<string, unknown>[] = [
182+
{ id: 'check-update', label: t('actions.checkForUpdate'), style: 'default', enabled: installed },
183+
]
183184
sections.push({
184185
tab: 'update',
185186
title: t('portable.updates'),

src/main/sources/standalone.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,7 @@ export const standalone: SourcePlugin = {
348348
}
349349
})
350350

351-
const updateFields: Record<string, unknown>[] = [
352-
{ id: 'updateChannel', label: t('standalone.updateChannel'), value: channel, editable: true,
353-
refreshSection: true, onChangeAction: 'check-update', editType: 'channel-cards', options: channelOptions },
354-
]
355-
const updateActions: Record<string, unknown>[] = []
351+
const channelActions: Record<string, unknown>[] = []
356352
if (info && releaseCache.isUpdateAvailable(installation, channel, info) && hasGit) {
357353
const installedDisplay = (installation.version as string | undefined) || info.installedTag || 'unknown'
358354
const latestDisplay = info.releaseName || info.latestTag || '—'
@@ -361,7 +357,7 @@ export const standalone: SourcePlugin = {
361357
: channel === 'latest' ? 'standalone.updateConfirmMessageLatest'
362358
: 'standalone.updateConfirmMessage'
363359
const notes = truncateNotes(info.releaseNotes || '', 2000)
364-
updateActions.push({
360+
channelActions.push({
365361
id: 'update-comfyui', label: t('standalone.updateNow'), style: 'primary', enabled: installed,
366362
showProgress: true, progressTitle: t('standalone.updatingTitle', { version: latestDisplay }),
367363
confirm: {
@@ -374,7 +370,7 @@ export const standalone: SourcePlugin = {
374370
}),
375371
},
376372
})
377-
updateActions.push({
373+
channelActions.push({
378374
id: 'copy-update', label: t('standalone.copyAndUpdate'), style: 'default', enabled: installed,
379375
showProgress: true, progressTitle: t('standalone.copyUpdatingTitle', { version: latestDisplay }),
380376
cancellable: true,
@@ -388,9 +384,14 @@ export const standalone: SourcePlugin = {
388384
},
389385
})
390386
}
391-
updateActions.push({
392-
id: 'check-update', label: t('actions.checkForUpdate'), style: 'default', enabled: installed,
393-
})
387+
const updateFields: Record<string, unknown>[] = [
388+
{ id: 'updateChannel', label: t('standalone.updateChannel'), value: channel, editable: true,
389+
refreshSection: true, onChangeAction: 'check-update', editType: 'channel-cards', options: channelOptions,
390+
channelActions: channelActions.length ? channelActions : undefined },
391+
]
392+
const updateActions: Record<string, unknown>[] = [
393+
{ id: 'check-update', label: t('actions.checkForUpdate'), style: 'default', enabled: installed },
394+
]
394395
sections.push({
395396
tab: 'update',
396397
title: t('standalone.updates'),

src/renderer/src/assets/main.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ input[type="checkbox"]:checked::after { transform: translateX(16px); }
409409
.channel-preview-label { font-size: 13px; color: var(--text-muted); }
410410
.channel-preview-value { font-size: 13px; color: var(--text); }
411411
.channel-switch-btn { margin-top: 10px; }
412+
.channel-actions { display: flex; gap: 8px; margin-top: 10px; }
412413
.detail-item-list {
413414
background: var(--surface); border: 1px solid var(--border);
414415
border-radius: 8px; margin-bottom: 8px;

src/renderer/src/components/DetailSection.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ v-for="a in item.actions" :key="a.id"
166166
<div v-else-if="getDraft(f) !== String(f.value)" class="channel-preview channel-preview-empty">
167167
{{ $t('channelCards.noInfo') }}
168168
</div>
169+
<!-- Switch Channel: shown when a different channel is selected -->
169170
<button
170171
v-if="getDraft(f) !== String(f.value)"
171172
class="primary channel-switch-btn"
@@ -174,6 +175,17 @@ v-for="a in item.actions" :key="a.id"
174175
>
175176
{{ switchingChannel ? $t('channelCards.switching') : $t('channelCards.switchChannel') }}
176177
</button>
178+
<!-- Channel actions (e.g. Update Now): shown when current channel is selected -->
179+
<div v-else-if="f.channelActions?.length" class="channel-actions">
180+
<button
181+
v-for="a in f.channelActions" :key="a.id"
182+
:class="[a.style, { 'looks-disabled': a.enabled === false && a.disabledMessage }]"
183+
:disabled="a.enabled === false && !a.disabledMessage"
184+
@click="handleAction(a, $event)"
185+
>
186+
{{ a.label }}
187+
</button>
188+
</div>
177189
</template>
178190
<template v-else>
179191
<div class="detail-field-label">{{ f.label }}</div>

src/types/ipc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export interface DetailField {
9898
editable?: boolean
9999
editType?: 'select' | 'boolean' | 'text' | 'channel-cards'
100100
options?: DetailFieldOption[]
101+
channelActions?: ActionDef[]
101102
refreshSection?: boolean
102103
onChangeAction?: string
103104
}

0 commit comments

Comments
 (0)