clean up prefill flow

This commit is contained in:
Matt Hill
2026-02-24 07:19:56 -07:00
parent 5294e8f444
commit d1162272f0
4 changed files with 39 additions and 56 deletions

View File

@@ -305,21 +305,21 @@ export class PluginAddressesComponent {
if (!group.tableAction || !group.pluginPkgInfo) return if (!group.tableAction || !group.pluginPkgInfo) return
const iface = this.value() const iface = this.value()
const prefill: Record<string, unknown> = {} if (!iface) return
if (iface) { const { addressInfo } = iface
prefill['urlPluginMetadata'] = {
packageId: this.packageId() || null,
hostId: iface.addressInfo.hostId,
interfaceId: iface.id,
internalPort: iface.addressInfo.internalPort,
}
}
this.actionService.present({ this.actionService.present({
pkgInfo: group.pluginPkgInfo, pkgInfo: group.pluginPkgInfo,
actionInfo: group.tableAction, actionInfo: group.tableAction,
prefill, prefill: {
urlPluginMetadata: {
packageId: this.packageId() || null,
hostId: addressInfo.hostId,
interfaceId: iface.id,
internalPort: addressInfo.internalPort,
},
},
}) })
} }
@@ -332,26 +332,30 @@ export class PluginAddressesComponent {
if (!group.pluginPkgInfo) return if (!group.pluginPkgInfo) return
const iface = this.value() const iface = this.value()
const prefill: Record<string, unknown> = {} if (!iface) return
if (iface && address.hostnameInfo.metadata.kind === 'plugin') { const { hostnameInfo } = address
prefill['urlPluginMetadata'] = { const { addressInfo } = iface
packageId: this.packageId() || null, const hostMeta = hostnameInfo.metadata
hostId: iface.addressInfo.hostId,
interfaceId: iface.id, if (hostMeta.kind !== 'plugin') return
internalPort: iface.addressInfo.internalPort,
hostname: address.hostnameInfo.hostname,
port: address.hostnameInfo.port,
ssl: address.hostnameInfo.ssl,
public: address.hostnameInfo.public,
info: address.hostnameInfo.metadata.info,
}
}
this.actionService.present({ this.actionService.present({
pkgInfo: group.pluginPkgInfo, pkgInfo: group.pluginPkgInfo,
actionInfo: { id: actionId, metadata }, actionInfo: { id: actionId, metadata },
prefill, prefill: {
urlPluginMetadata: {
packageId: this.packageId() || null,
hostId: addressInfo.hostId,
interfaceId: iface.id,
internalPort: addressInfo.internalPort,
hostname: hostnameInfo.hostname,
port: hostnameInfo.port,
ssl: hostnameInfo.ssl,
public: hostnameInfo.public,
info: hostMeta.info,
},
},
}) })
} }
} }

View File

@@ -154,20 +154,21 @@ export class ServiceTaskComponent {
} }
async handle() { async handle() {
const task = this.task()
const title = this.title() const title = this.title()
const pkg = this.pkg() const pkg = this.pkg()
const metadata = pkg?.actions[this.task().actionId] const metadata = pkg?.actions[task.actionId]
if (title && pkg && metadata) { if (title && pkg && metadata) {
this.actionService.present({ this.actionService.present({
pkgInfo: { pkgInfo: {
id: this.task().packageId, id: task.packageId,
title, title,
status: getInstalledBaseStatus(pkg.statusInfo), status: getInstalledBaseStatus(pkg.statusInfo),
icon: pkg.icon, icon: pkg.icon,
}, },
actionInfo: { id: this.task().actionId, metadata }, actionInfo: { id: task.actionId, metadata },
requestInfo: this.task(), prefill: task.input?.value,
}) })
} }
} }

View File

@@ -23,7 +23,6 @@ import {
FormComponent, FormComponent,
} from 'src/app/routes/portal/components/form.component' } from 'src/app/routes/portal/components/form.component'
import { InvalidService } from 'src/app/routes/portal/components/form/containers/control.directive' import { InvalidService } from 'src/app/routes/portal/components/form/containers/control.directive'
import { TaskInfoComponent } from 'src/app/routes/portal/modals/config-dep.component'
import { ActionService } from 'src/app/services/action.service' import { ActionService } from 'src/app/services/action.service'
import { ApiService } from 'src/app/services/api/embassy-api.service' import { ApiService } from 'src/app/services/api/embassy-api.service'
import { DataModel } from 'src/app/services/patch-db/data-model' import { DataModel } from 'src/app/services/patch-db/data-model'
@@ -41,7 +40,6 @@ export type PackageActionData = {
id: string id: string
metadata: T.ActionMetadata metadata: T.ActionMetadata
} }
requestInfo?: T.Task
prefill?: Record<string, unknown> prefill?: Record<string, unknown>
} }
@@ -63,13 +61,6 @@ export type PackageActionData = {
</tui-notification> </tui-notification>
} }
@if (requestInfo) {
<task-info
[originalValue]="res.originalValue || {}"
[operations]="res.visibleOperations || []"
/>
}
<app-form <app-form
[spec]="res.spec" [spec]="res.spec"
[value]="res.originalValue || {}" [value]="res.originalValue || {}"
@@ -110,14 +101,7 @@ export type PackageActionData = {
} }
} }
`, `,
imports: [ imports: [TuiNotification, TuiLoader, TuiButton, FormComponent, i18nPipe],
TuiNotification,
TuiLoader,
TuiButton,
TaskInfoComponent,
FormComponent,
i18nPipe,
],
providers: [InvalidService], providers: [InvalidService],
}) })
export class ActionInputModal { export class ActionInputModal {
@@ -132,7 +116,7 @@ export class ActionInputModal {
readonly actionId = this.context.data.actionInfo.id readonly actionId = this.context.data.actionInfo.id
readonly warning = this.context.data.actionInfo.metadata.warning readonly warning = this.context.data.actionInfo.metadata.warning
readonly pkgInfo = this.context.data.pkgInfo readonly pkgInfo = this.context.data.pkgInfo
readonly requestInfo = this.context.data.requestInfo readonly prefill = this.context.data.prefill
eventId: string | null = null eventId: string | null = null
buttons: ActionButton<any>[] = [ buttons: ActionButton<any>[] = [
@@ -148,7 +132,7 @@ export class ActionInputModal {
this.api.getActionInput({ this.api.getActionInput({
packageId: this.pkgInfo.id, packageId: this.pkgInfo.id,
actionId: this.actionId, actionId: this.actionId,
prefill: this.context.data.prefill ?? null, prefill: this.prefill ?? null,
}), }),
).pipe( ).pipe(
map(res => { map(res => {
@@ -156,12 +140,12 @@ export class ActionInputModal {
const originalValue = res.value || {} const originalValue = res.value || {}
this.eventId = res.eventId this.eventId = res.eventId
const operations = this.requestInfo?.input const operations = this.prefill
? compare( ? compare(
JSON.parse(JSON.stringify(originalValue)), JSON.parse(JSON.stringify(originalValue)),
utils.deepMerge( utils.deepMerge(
JSON.parse(JSON.stringify(originalValue)), JSON.parse(JSON.stringify(originalValue)),
this.requestInfo.input.value, this.prefill,
) as object, ) as object,
) )
: null : null
@@ -170,11 +154,6 @@ export class ActionInputModal {
spec: res.spec, spec: res.spec,
originalValue, originalValue,
operations, operations,
visibleOperations:
operations?.filter(op => {
const key = op.path.split('/')[1]
return (res.spec[key!] as any)?.type !== 'hidden'
}) ?? null,
} }
}), }),
catchError(e => { catchError(e => {

View File

@@ -27,7 +27,6 @@ export class ActionService {
private readonly formDialog = inject(FormDialogService) private readonly formDialog = inject(FormDialogService)
async present(data: PackageActionData) { async present(data: PackageActionData) {
data.prefill = data.prefill ?? data.requestInfo?.input?.value
const { pkgInfo, actionInfo } = data const { pkgInfo, actionInfo } = data
if (actionInfo.metadata.hasInput) { if (actionInfo.metadata.hasInput) {