mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
clean up prefill flow
This commit is contained in:
@@ -305,21 +305,21 @@ export class PluginAddressesComponent {
|
||||
if (!group.tableAction || !group.pluginPkgInfo) return
|
||||
|
||||
const iface = this.value()
|
||||
const prefill: Record<string, unknown> = {}
|
||||
if (!iface) return
|
||||
|
||||
if (iface) {
|
||||
prefill['urlPluginMetadata'] = {
|
||||
packageId: this.packageId() || null,
|
||||
hostId: iface.addressInfo.hostId,
|
||||
interfaceId: iface.id,
|
||||
internalPort: iface.addressInfo.internalPort,
|
||||
}
|
||||
}
|
||||
const { addressInfo } = iface
|
||||
|
||||
this.actionService.present({
|
||||
pkgInfo: group.pluginPkgInfo,
|
||||
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
|
||||
|
||||
const iface = this.value()
|
||||
const prefill: Record<string, unknown> = {}
|
||||
if (!iface) return
|
||||
|
||||
if (iface && address.hostnameInfo.metadata.kind === 'plugin') {
|
||||
prefill['urlPluginMetadata'] = {
|
||||
packageId: this.packageId() || null,
|
||||
hostId: iface.addressInfo.hostId,
|
||||
interfaceId: iface.id,
|
||||
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,
|
||||
}
|
||||
}
|
||||
const { hostnameInfo } = address
|
||||
const { addressInfo } = iface
|
||||
const hostMeta = hostnameInfo.metadata
|
||||
|
||||
if (hostMeta.kind !== 'plugin') return
|
||||
|
||||
this.actionService.present({
|
||||
pkgInfo: group.pluginPkgInfo,
|
||||
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,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,20 +154,21 @@ export class ServiceTaskComponent {
|
||||
}
|
||||
|
||||
async handle() {
|
||||
const task = this.task()
|
||||
const title = this.title()
|
||||
const pkg = this.pkg()
|
||||
const metadata = pkg?.actions[this.task().actionId]
|
||||
const metadata = pkg?.actions[task.actionId]
|
||||
|
||||
if (title && pkg && metadata) {
|
||||
this.actionService.present({
|
||||
pkgInfo: {
|
||||
id: this.task().packageId,
|
||||
id: task.packageId,
|
||||
title,
|
||||
status: getInstalledBaseStatus(pkg.statusInfo),
|
||||
icon: pkg.icon,
|
||||
},
|
||||
actionInfo: { id: this.task().actionId, metadata },
|
||||
requestInfo: this.task(),
|
||||
actionInfo: { id: task.actionId, metadata },
|
||||
prefill: task.input?.value,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import {
|
||||
FormComponent,
|
||||
} from 'src/app/routes/portal/components/form.component'
|
||||
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 { ApiService } from 'src/app/services/api/embassy-api.service'
|
||||
import { DataModel } from 'src/app/services/patch-db/data-model'
|
||||
@@ -41,7 +40,6 @@ export type PackageActionData = {
|
||||
id: string
|
||||
metadata: T.ActionMetadata
|
||||
}
|
||||
requestInfo?: T.Task
|
||||
prefill?: Record<string, unknown>
|
||||
}
|
||||
|
||||
@@ -63,13 +61,6 @@ export type PackageActionData = {
|
||||
</tui-notification>
|
||||
}
|
||||
|
||||
@if (requestInfo) {
|
||||
<task-info
|
||||
[originalValue]="res.originalValue || {}"
|
||||
[operations]="res.visibleOperations || []"
|
||||
/>
|
||||
}
|
||||
|
||||
<app-form
|
||||
[spec]="res.spec"
|
||||
[value]="res.originalValue || {}"
|
||||
@@ -110,14 +101,7 @@ export type PackageActionData = {
|
||||
}
|
||||
}
|
||||
`,
|
||||
imports: [
|
||||
TuiNotification,
|
||||
TuiLoader,
|
||||
TuiButton,
|
||||
TaskInfoComponent,
|
||||
FormComponent,
|
||||
i18nPipe,
|
||||
],
|
||||
imports: [TuiNotification, TuiLoader, TuiButton, FormComponent, i18nPipe],
|
||||
providers: [InvalidService],
|
||||
})
|
||||
export class ActionInputModal {
|
||||
@@ -132,7 +116,7 @@ export class ActionInputModal {
|
||||
readonly actionId = this.context.data.actionInfo.id
|
||||
readonly warning = this.context.data.actionInfo.metadata.warning
|
||||
readonly pkgInfo = this.context.data.pkgInfo
|
||||
readonly requestInfo = this.context.data.requestInfo
|
||||
readonly prefill = this.context.data.prefill
|
||||
eventId: string | null = null
|
||||
|
||||
buttons: ActionButton<any>[] = [
|
||||
@@ -148,7 +132,7 @@ export class ActionInputModal {
|
||||
this.api.getActionInput({
|
||||
packageId: this.pkgInfo.id,
|
||||
actionId: this.actionId,
|
||||
prefill: this.context.data.prefill ?? null,
|
||||
prefill: this.prefill ?? null,
|
||||
}),
|
||||
).pipe(
|
||||
map(res => {
|
||||
@@ -156,12 +140,12 @@ export class ActionInputModal {
|
||||
const originalValue = res.value || {}
|
||||
this.eventId = res.eventId
|
||||
|
||||
const operations = this.requestInfo?.input
|
||||
const operations = this.prefill
|
||||
? compare(
|
||||
JSON.parse(JSON.stringify(originalValue)),
|
||||
utils.deepMerge(
|
||||
JSON.parse(JSON.stringify(originalValue)),
|
||||
this.requestInfo.input.value,
|
||||
this.prefill,
|
||||
) as object,
|
||||
)
|
||||
: null
|
||||
@@ -170,11 +154,6 @@ export class ActionInputModal {
|
||||
spec: res.spec,
|
||||
originalValue,
|
||||
operations,
|
||||
visibleOperations:
|
||||
operations?.filter(op => {
|
||||
const key = op.path.split('/')[1]
|
||||
return (res.spec[key!] as any)?.type !== 'hidden'
|
||||
}) ?? null,
|
||||
}
|
||||
}),
|
||||
catchError(e => {
|
||||
|
||||
@@ -27,7 +27,6 @@ export class ActionService {
|
||||
private readonly formDialog = inject(FormDialogService)
|
||||
|
||||
async present(data: PackageActionData) {
|
||||
data.prefill = data.prefill ?? data.requestInfo?.input?.value
|
||||
const { pkgInfo, actionInfo } = data
|
||||
|
||||
if (actionInfo.metadata.hasInput) {
|
||||
|
||||
Reference in New Issue
Block a user