@lesliechan721/aw 0.1.0-beta.87 → 0.1.0-beta.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring/assets/command-runtime-config.mjs +40 -12
- package/dist/authoring/assets/command-runtime-config.mjs.map +1 -1
- package/dist/authoring/scripts/validate-plugin.mjs +14 -3
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/scripts/aw-skill-eval-materializer.js +10 -2
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
- package/dist/src/commands/aw-capabilities.d.ts +1 -1
- package/dist/src/commands/aw-capabilities.js +1 -0
- package/dist/src/commands/aw-capabilities.js.map +1 -1
- package/dist/src/commands/catalog-source.js +1 -1
- package/dist/src/commands/catalog-source.js.map +1 -1
- package/dist/src/commands/lifecycle-command-package.d.ts +1 -0
- package/dist/src/commands/lifecycle-command-package.js +14 -10
- package/dist/src/commands/lifecycle-command-package.js.map +1 -1
- package/dist/src/commands/managed-commands.js +8 -16
- package/dist/src/commands/managed-commands.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.js +4 -0
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/public-lifecycle-result.js +2 -1
- package/dist/src/commands/public-lifecycle-result.js.map +1 -1
- package/dist/src/generators/local-plugin.js +6 -0
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/generators/permissions.d.ts +2 -1
- package/dist/src/generators/permissions.js +5 -5
- package/dist/src/generators/permissions.js.map +1 -1
- package/dist/src/index.js +82 -9
- package/dist/src/index.js.map +1 -1
- package/dist/src/output/command-receipt.js +4 -2
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/public-result.js +16 -4
- package/dist/src/output/public-result.js.map +1 -1
- package/dist/src/output/receipt-projection.js +5 -4
- package/dist/src/output/receipt-projection.js.map +1 -1
- package/dist/src/platforms/grok-permission-config.d.ts +2 -1
- package/dist/src/platforms/grok-permission-config.js +4 -4
- package/dist/src/platforms/grok-permission-config.js.map +1 -1
- package/dist/src/platforms/projection.js +2 -2
- package/dist/src/platforms/projection.js.map +1 -1
- package/dist/src/recovery/status.js +2 -2
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/review/skill-materialization.d.ts +1 -0
- package/dist/src/review/skill-materialization.js +5 -1
- package/dist/src/review/skill-materialization.js.map +1 -1
- package/dist/src/tui/config-array-draft.d.ts +2 -1
- package/dist/src/tui/config-array-draft.js +3 -0
- package/dist/src/tui/config-array-draft.js.map +1 -1
- package/dist/src/tui/config-leaf-editor.d.ts +2 -1
- package/dist/src/tui/config-leaf-editor.js +7 -4
- package/dist/src/tui/config-leaf-editor.js.map +1 -1
- package/dist/src/tui/config-suggestions.d.ts +22 -0
- package/dist/src/tui/config-suggestions.js +54 -0
- package/dist/src/tui/config-suggestions.js.map +1 -0
- package/dist/src/tui/config-value-presentation.d.ts +1 -0
- package/dist/src/tui/config-value-presentation.js +26 -1
- package/dist/src/tui/config-value-presentation.js.map +1 -1
- package/dist/src/tui/console-app-v4.js +284 -87
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +14 -0
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +4 -0
- package/dist/src/tui/controller.js +46 -4
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/operation-review-planner.js +2 -2
- package/dist/src/tui/operation-review-planner.js.map +1 -1
- package/dist/src/tui/router.d.ts +17 -18
- package/dist/src/tui/router.js.map +1 -1
- package/dist/src/tui/screen-registry.d.ts +2 -8
- package/dist/src/types.d.ts +1 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/bundle-layout.js +7 -0
- package/dist/src/utils/bundle-layout.js.map +1 -1
- package/dist/src/utils/component-command-preparation.js +2 -3
- package/dist/src/utils/component-command-preparation.js.map +1 -1
- package/dist/src/utils/managed-command-cli-review.d.ts +11 -1
- package/dist/src/utils/managed-command-cli-review.js +82 -40
- package/dist/src/utils/managed-command-cli-review.js.map +1 -1
- package/dist/src/utils/managed-command-materialization.js +2 -2
- package/dist/src/utils/managed-command-materialization.js.map +1 -1
- package/dist/src/utils/managed-command-review.js +2 -2
- package/dist/src/utils/managed-command-review.js.map +1 -1
- package/dist/src/utils/managed-command-runtime.d.ts +2 -0
- package/dist/src/utils/managed-command-runtime.js +5 -3
- package/dist/src/utils/managed-command-runtime.js.map +1 -1
- package/dist/src/utils/managed-command-snapshots.d.ts +8 -1
- package/dist/src/utils/managed-command-snapshots.js +16 -11
- package/dist/src/utils/managed-command-snapshots.js.map +1 -1
- package/dist/src/utils/managed-command-store.d.ts +6 -1
- package/dist/src/utils/managed-command-store.js +47 -8
- package/dist/src/utils/managed-command-store.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +10 -0
- package/dist/src/utils/native-cli.js +24 -18
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/platform-empty-state.js +3 -2
- package/dist/src/utils/platform-empty-state.js.map +1 -1
- package/dist/src/utils/plugin-config-command-apply.js +7 -5
- package/dist/src/utils/plugin-config-command-apply.js.map +1 -1
- package/dist/src/utils/plugin-config-impact.d.ts +1 -0
- package/dist/src/utils/plugin-config-impact.js +2 -1
- package/dist/src/utils/plugin-config-impact.js.map +1 -1
- package/dist/src/utils/plugin-config-references.d.ts +2 -0
- package/dist/src/utils/plugin-config-references.js +12 -2
- package/dist/src/utils/plugin-config-references.js.map +1 -1
- package/dist/src/utils/plugin-config-suggestion-runner.d.ts +50 -0
- package/dist/src/utils/plugin-config-suggestion-runner.js +167 -0
- package/dist/src/utils/plugin-config-suggestion-runner.js.map +1 -0
- package/dist/src/utils/plugin-config-suggestions.d.ts +47 -0
- package/dist/src/utils/plugin-config-suggestions.js +274 -0
- package/dist/src/utils/plugin-config-suggestions.js.map +1 -0
- package/dist/src/utils/plugin-config.d.ts +5 -1
- package/dist/src/utils/plugin-config.js +48 -22
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-scripts.d.ts +2 -0
- package/dist/src/utils/plugin-scripts.js +101 -28
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/dist/src/utils/rendered-contract.js +2 -2
- package/dist/src/utils/rendered-contract.js.map +1 -1
- package/dist/vitest.config.js +1 -0
- package/dist/vitest.config.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { configReferenceKey, configReferenceValues, configReferenceScalars, configReferenceSelection, configReferenceMessage, configReferenceSource, configCrossLayerDependencies } from './config-references.js';
|
|
3
|
-
import { arrayDraftChanged, arrayDraftValue, createConfigArrayDraft, editConfigArrayDraft } from './config-array-draft.js';
|
|
4
|
-
import { PLATFORM_TARGETS, PLUGIN_CONFIG_ARRAY_MAX_ITEMS } from '@lesliechan721/aw-plugin-core';
|
|
3
|
+
import { arrayDraftChanged, arrayDraftValue, createConfigArrayDraft, editConfigArrayDraft, isNestedConfigObjectArray } from './config-array-draft.js';
|
|
4
|
+
import { formatPluginConfigIssue, PLATFORM_TARGETS, PLUGIN_CONFIG_ARRAY_MAX_ITEMS } from '@lesliechan721/aw-plugin-core';
|
|
5
5
|
import { presentConfigValue, safeConfigText } from './config-value-presentation.js';
|
|
6
6
|
import { ConfigLeafEditor } from './config-leaf-editor.js';
|
|
7
|
+
import { configSuggestionScalar, useConfigSuggestions } from './config-suggestions.js';
|
|
7
8
|
import { Box, Text, useInput, useWindowSize } from 'ink';
|
|
8
9
|
import { AgentManagement } from './agent-management.js';
|
|
9
10
|
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
@@ -403,8 +404,10 @@ function commandPackageResultLines(result, removal) {
|
|
|
403
404
|
return [
|
|
404
405
|
`命令包 ${result.selector} · ${result.action} · ${result.availability} · ${result.state}`,
|
|
405
406
|
...(removal && result.action === 'unchanged' ? [`保留命令包 ${result.packageId} · 所有项目共用`] : []),
|
|
406
|
-
...result.
|
|
407
|
-
|
|
407
|
+
...(result.invocationSelectors ?? [result.selector]).flatMap((invocationSelector) => [
|
|
408
|
+
...result.subcommands.map((name) => `aw command run ${invocationSelector} -- ${name}`),
|
|
409
|
+
...(result.hasFallback ? [`通用入口 · aw command run ${invocationSelector} --`] : []),
|
|
410
|
+
]),
|
|
408
411
|
...result.errors.map(({ code, message }) => `${code} · ${message}`),
|
|
409
412
|
...result.recoveryActions,
|
|
410
413
|
];
|
|
@@ -504,6 +507,28 @@ function configPageMatches(page, route) {
|
|
|
504
507
|
&& page.profile === route.layer.profile
|
|
505
508
|
&& page.context === (route.layer.context ?? 'user'));
|
|
506
509
|
}
|
|
510
|
+
function configArrayItemField(field, draft, item) {
|
|
511
|
+
if (!item || field?.definition.type !== 'array')
|
|
512
|
+
return field;
|
|
513
|
+
const index = draft?.rows.findIndex((row) => row.rowId === item.rowId) ?? -1;
|
|
514
|
+
const value = draft?.rows[index]?.value;
|
|
515
|
+
const definition = field.definition.items;
|
|
516
|
+
return {
|
|
517
|
+
...field,
|
|
518
|
+
type: definition.type,
|
|
519
|
+
definition,
|
|
520
|
+
title: item.rowId === undefined ? '新增项' : `第 ${index + 1} 项`,
|
|
521
|
+
description: definition.description,
|
|
522
|
+
choices: definition.choices?.presets,
|
|
523
|
+
allowCustom: definition.choices?.allowCustom ?? true,
|
|
524
|
+
value, draftValue: value, configured: value !== undefined,
|
|
525
|
+
min: definition.type === 'number' ? definition.validation?.minimum : undefined,
|
|
526
|
+
max: definition.type === 'number' ? definition.validation?.maximum : undefined,
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
function configObjectValue(value) {
|
|
530
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
531
|
+
}
|
|
507
532
|
const CONFIG_PROFILE_KEYS = ['common', ...PLATFORM_TARGETS];
|
|
508
533
|
function configReadOptions(layer) {
|
|
509
534
|
return {
|
|
@@ -2123,33 +2148,57 @@ export function ConsoleAppV4(props) {
|
|
|
2123
2148
|
|| route.name === 'configFieldAction'
|
|
2124
2149
|
? currentConfigPage?.groups.flatMap((group) => group.fields).find((field) => field.key === route.fieldKey)
|
|
2125
2150
|
: undefined;
|
|
2126
|
-
const
|
|
2127
|
-
|
|
2128
|
-
const
|
|
2151
|
+
const editorRoute = route.name === 'configFieldEditor' || route.name === 'configObjectPropertyEditor' ? route : undefined;
|
|
2152
|
+
const arrayItem = editorRoute?.arrayItem;
|
|
2153
|
+
const nestedArray = editorRoute?.nestedArray;
|
|
2154
|
+
const topFieldKey = activeTopField && configRoute
|
|
2129
2155
|
? `${configEditorOwnerKey(configRoute.pluginId, configRoute.layer)}\0${activeTopField.key}` : undefined;
|
|
2130
|
-
const
|
|
2131
|
-
const
|
|
2132
|
-
|
|
2133
|
-
const
|
|
2156
|
+
const topArrayKey = activeTopField?.definition.type === 'array' ? topFieldKey : undefined;
|
|
2157
|
+
const topArrayDraft = topArrayKey ? arrayDrafts[topArrayKey] : undefined;
|
|
2158
|
+
const parentItem = nestedArray ? nestedArray.parentItem : arrayItem;
|
|
2159
|
+
const parentField = configArrayItemField(activeTopField, topArrayDraft, parentItem);
|
|
2160
|
+
const parentObjectKey = parentField?.type === 'object' && topFieldKey
|
|
2161
|
+
? `${topFieldKey}${parentItem ? `\0${parentItem.rowId ?? 'new'}` : ''}` : undefined;
|
|
2162
|
+
const activeCandidateMutation = !parentItem && activeTopField && configCandidate && configCandidate.layer.profile === editingProfile
|
|
2163
|
+
&& (configCandidate.layer.context ?? 'user') === configContext ? configCandidate.mutations[activeTopField.key] : undefined;
|
|
2164
|
+
const parentObjectInitial = configObjectValue(activeCandidateMutation?.kind === 'set' ? activeCandidateMutation.value : undefined)
|
|
2165
|
+
?? configObjectValue(!parentItem && activeTopField ? draftUpdates[activeTopField.key] : undefined)
|
|
2166
|
+
?? configObjectValue(parentField?.draftValue);
|
|
2167
|
+
const parentObjectDraft = parentObjectKey ? objectDrafts[parentObjectKey] ?? parentObjectInitial ?? {} : undefined;
|
|
2168
|
+
const parentObjectProperties = parentField?.definition.type === 'object' && parentObjectDraft
|
|
2169
|
+
? resolvePluginConfigObjectProperties(parentField.definition, parentObjectDraft, parentField.key).properties
|
|
2170
|
+
: undefined;
|
|
2171
|
+
const nestedDefinition = nestedArray ? parentObjectProperties?.[nestedArray.propertyKey] : undefined;
|
|
2172
|
+
const nestedValue = nestedArray ? parentObjectDraft?.[nestedArray.propertyKey] : undefined;
|
|
2173
|
+
const nestedField = parentField && nestedArray && isNestedConfigObjectArray(nestedDefinition)
|
|
2134
2174
|
? {
|
|
2135
|
-
...
|
|
2136
|
-
type:
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
choices:
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2175
|
+
...parentField,
|
|
2176
|
+
type: 'array', definition: nestedDefinition,
|
|
2177
|
+
title: nestedDefinition.title ?? nestedArray.propertyKey,
|
|
2178
|
+
description: nestedDefinition.description,
|
|
2179
|
+
value: nestedValue, draftValue: nestedValue, configured: nestedValue !== undefined,
|
|
2180
|
+
choices: undefined, itemSummary: undefined, summary: undefined,
|
|
2181
|
+
}
|
|
2182
|
+
: undefined;
|
|
2183
|
+
const activeArrayKey = nestedArray
|
|
2184
|
+
? nestedField && `${parentObjectKey}\0property\0${nestedArray.propertyKey}` : topArrayKey;
|
|
2185
|
+
const activeArrayDraft = activeArrayKey ? arrayDrafts[activeArrayKey] : undefined;
|
|
2186
|
+
const activeField = nestedArray ? configArrayItemField(nestedField, activeArrayDraft, arrayItem) : parentField;
|
|
2187
|
+
const itemValue = arrayItem ? activeField?.draftValue : undefined;
|
|
2188
|
+
const parentPath = [activeTopField?.key ?? '', ...(parentItem ? [
|
|
2189
|
+
parentItem.rowId === undefined ? topArrayDraft?.rows.length ?? 0
|
|
2190
|
+
: Math.max(0, topArrayDraft?.rows.findIndex((row) => row.rowId === parentItem.rowId) ?? 0),
|
|
2191
|
+
] : [])];
|
|
2192
|
+
const activeFieldPath = nestedArray ? [...parentPath, nestedArray.propertyKey, ...(arrayItem ? [
|
|
2193
|
+
arrayItem.rowId === undefined ? activeArrayDraft?.rows.length ?? 0
|
|
2194
|
+
: Math.max(0, activeArrayDraft?.rows.findIndex((row) => row.rowId === arrayItem.rowId) ?? 0),
|
|
2195
|
+
] : [])] : parentPath;
|
|
2147
2196
|
useEffect(() => {
|
|
2148
2197
|
if (!activeArrayKey || activeArrayDraft || !activeTopField || route.name !== 'configFieldEditor')
|
|
2149
2198
|
return;
|
|
2150
|
-
const value = draftUpdates[activeTopField.key] ?? activeTopField.draftValue ?? activeTopField.value;
|
|
2199
|
+
const value = nestedArray ? nestedValue : draftUpdates[activeTopField.key] ?? activeTopField.draftValue ?? activeTopField.value;
|
|
2151
2200
|
setArrayDrafts((current) => ({ ...current, [activeArrayKey]: { ...createConfigArrayDraft(Array.isArray(value) ? value : undefined), evidence: currentConfigPage?.editEvidence } }));
|
|
2152
|
-
}, [activeArrayKey, activeArrayDraft, activeTopField, route.name, editingProfile]);
|
|
2201
|
+
}, [activeArrayKey, activeArrayDraft, activeTopField, nestedArray, nestedValue, route.name, editingProfile]);
|
|
2153
2202
|
useEffect(() => {
|
|
2154
2203
|
if (route.name !== 'configFieldEditor' || route.editor !== 'array' || !activeArrayKey || !activeArrayDraft)
|
|
2155
2204
|
return;
|
|
@@ -2176,30 +2225,18 @@ export function ConsoleAppV4(props) {
|
|
|
2176
2225
|
props.controller.replace({ ...route, name: 'configFieldEditor', editor: activeField.type });
|
|
2177
2226
|
}
|
|
2178
2227
|
}, [props.controller, route, activeField]);
|
|
2179
|
-
const activeObjectKey =
|
|
2180
|
-
? `${
|
|
2181
|
-
:
|
|
2182
|
-
const
|
|
2183
|
-
|
|
2184
|
-
?
|
|
2185
|
-
:
|
|
2186
|
-
const
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
: undefined;
|
|
2192
|
-
const objectValueFromField = activeField?.draftValue !== null
|
|
2193
|
-
&& typeof activeField?.draftValue === 'object'
|
|
2194
|
-
&& !Array.isArray(activeField.draftValue)
|
|
2195
|
-
? activeField.draftValue
|
|
2196
|
-
: undefined;
|
|
2197
|
-
const activeObjectDraft = activeObjectKey
|
|
2198
|
-
? objectDrafts[activeObjectKey] ?? objectValueFromCandidate ?? objectValueFromUpdate ?? objectValueFromField ?? {}
|
|
2199
|
-
: undefined;
|
|
2200
|
-
const activeObjectProperties = activeField?.definition.type === 'object' && activeObjectDraft
|
|
2201
|
-
? resolvePluginConfigObjectProperties(activeField.definition, activeObjectDraft, activeField.key).properties
|
|
2202
|
-
: undefined;
|
|
2228
|
+
const activeObjectKey = nestedArray
|
|
2229
|
+
? arrayItem && activeArrayKey ? `${activeArrayKey}\0${arrayItem.rowId ?? 'new'}` : undefined
|
|
2230
|
+
: parentObjectKey;
|
|
2231
|
+
const activeObjectInitial = nestedArray ? configObjectValue(itemValue) : parentObjectInitial;
|
|
2232
|
+
const activeObjectDraft = nestedArray
|
|
2233
|
+
? activeObjectKey ? objectDrafts[activeObjectKey] ?? activeObjectInitial ?? {} : undefined
|
|
2234
|
+
: parentObjectDraft;
|
|
2235
|
+
const activeObjectProperties = nestedArray
|
|
2236
|
+
? activeField?.definition.type === 'object' && activeObjectDraft
|
|
2237
|
+
? resolvePluginConfigObjectProperties(activeField.definition, activeObjectDraft, activeField.key).properties
|
|
2238
|
+
: undefined
|
|
2239
|
+
: parentObjectProperties;
|
|
2203
2240
|
const activePropertyDefinition = route.name === 'configObjectPropertyEditor'
|
|
2204
2241
|
&& activeField?.definition.type === 'object' && route.propertyKey !== undefined
|
|
2205
2242
|
? activeObjectProperties?.[route.propertyKey]
|
|
@@ -2215,6 +2252,47 @@ export function ConsoleAppV4(props) {
|
|
|
2215
2252
|
|| activePropertyDefinition?.sensitive === true;
|
|
2216
2253
|
const activeFieldIsConst = activeField && 'const' in activeField.definition && activeField.definition.const !== undefined;
|
|
2217
2254
|
const activePropertyIsConst = activePropertyDefinition && 'const' in activePropertyDefinition && activePropertyDefinition.const !== undefined;
|
|
2255
|
+
const suggestedScalar = configSuggestionScalar(route.name === 'configFieldEditor' ? activeField?.definition
|
|
2256
|
+
: route.name === 'configObjectPropertyEditor' && (route.stage === 'custom' || route.stage === 'choices')
|
|
2257
|
+
? activePropertyDefinition : undefined);
|
|
2258
|
+
const suggestionMenu = Boolean(suggestedScalar && (route.name === 'configFieldEditor' && route.mode !== 'custom'
|
|
2259
|
+
|| route.name === 'configObjectPropertyEditor' && route.stage === 'choices'));
|
|
2260
|
+
const suggestionLookup = (() => {
|
|
2261
|
+
if (!suggestedScalar || !editorRoute || !activeTopField || !configFieldCanSet(activeTopField))
|
|
2262
|
+
return undefined;
|
|
2263
|
+
const property = editorRoute.name === 'configObjectPropertyEditor' ? editorRoute.propertyKey : undefined;
|
|
2264
|
+
const selectedDraft = editorRoute.layer.profile === 'common' ? undefined : configDrafts[editorRoute.layer.profile];
|
|
2265
|
+
const commonDraft = configDrafts.common;
|
|
2266
|
+
const lookup = {
|
|
2267
|
+
pluginId: editorRoute.pluginId,
|
|
2268
|
+
options: configReadOptions(editorRoute.layer),
|
|
2269
|
+
fieldPath: property === undefined ? activeFieldPath : [...activeFieldPath, property],
|
|
2270
|
+
dependencyValues: property === undefined ? {} : activeObjectDraft,
|
|
2271
|
+
draftLayers: {
|
|
2272
|
+
...(commonDraft ? { common: { updates: commonDraft.updates, removes: commonDraft.removes } } : {}),
|
|
2273
|
+
...(selectedDraft ? { platform: { updates: selectedDraft.updates, removes: selectedDraft.removes } } : {}),
|
|
2274
|
+
},
|
|
2275
|
+
};
|
|
2276
|
+
if (property !== undefined && activeObjectDraft) {
|
|
2277
|
+
let workingObject = activeObjectDraft;
|
|
2278
|
+
if (nestedArray && arrayItem && activeArrayDraft && parentObjectDraft) {
|
|
2279
|
+
const workingArray = editConfigArrayDraft(activeArrayDraft, { kind: 'set', rowId: arrayItem.rowId, value: activeObjectDraft });
|
|
2280
|
+
workingObject = { ...parentObjectDraft, [nestedArray.propertyKey]: arrayDraftValue(workingArray) };
|
|
2281
|
+
}
|
|
2282
|
+
const workingValue = parentItem && topArrayDraft
|
|
2283
|
+
? arrayDraftValue(editConfigArrayDraft(topArrayDraft, { kind: 'set', rowId: parentItem.rowId, value: workingObject }))
|
|
2284
|
+
: workingObject;
|
|
2285
|
+
lookup.draftValues = { [activeTopField.key]: workingValue };
|
|
2286
|
+
}
|
|
2287
|
+
return lookup;
|
|
2288
|
+
})();
|
|
2289
|
+
const suggestions = useConfigSuggestions(props.controller, snapshot.router.currentFrameId, suggestionLookup, suggestedScalar);
|
|
2290
|
+
useLayoutEffect(() => {
|
|
2291
|
+
if (suggestionMenu) {
|
|
2292
|
+
setFocus(0);
|
|
2293
|
+
setScrollOffset(0);
|
|
2294
|
+
}
|
|
2295
|
+
}, [suggestions.items, suggestionMenu]);
|
|
2218
2296
|
const referenceNotice = (scalar, value) => {
|
|
2219
2297
|
const selection = referenceContext?.selections[configReferenceKey(scalar, referenceContext.platform)];
|
|
2220
2298
|
const message = referenceContextError && !selection ? `来源 ${configReferenceSource(scalar)}:${referenceContextError}`
|
|
@@ -2225,6 +2303,15 @@ export function ConsoleAppV4(props) {
|
|
|
2225
2303
|
return [message, pendingSource ? `来源 ${source} 在公共设置有未保存修改。请先保存来源配置,再编辑或保存引用配置。` : undefined]
|
|
2226
2304
|
.filter(Boolean).join(' ') || undefined;
|
|
2227
2305
|
};
|
|
2306
|
+
const invalidReferenceNotice = (definition, value) => {
|
|
2307
|
+
for (const { scalar, value: selected } of configReferenceValues(definition, value)) {
|
|
2308
|
+
const reference = referenceContext?.selections[configReferenceKey(scalar, referenceContext.platform)];
|
|
2309
|
+
if (!reference || reference.issues.length || !reference.choices.some((choice) => choice.value === selected)) {
|
|
2310
|
+
return referenceNotice(scalar, selected) ?? '引用选项已变化,请重新选择。';
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
return undefined;
|
|
2314
|
+
};
|
|
2228
2315
|
const openReferenceSource = (scalar, leaf) => {
|
|
2229
2316
|
const ref = 'valueRef' in scalar ? scalar.valueRef : undefined;
|
|
2230
2317
|
if (!ref?.plugin || !configRoute || !draftOwner)
|
|
@@ -2245,7 +2332,7 @@ export function ConsoleAppV4(props) {
|
|
|
2245
2332
|
useEffect(() => {
|
|
2246
2333
|
if (route.name !== 'configFieldEditor' || !activeField)
|
|
2247
2334
|
return;
|
|
2248
|
-
const candidate = activeCandidateMutation;
|
|
2335
|
+
const candidate = nestedArray ? undefined : activeCandidateMutation;
|
|
2249
2336
|
const draft = arrayItem ? itemValue : candidate?.kind === 'set' ? candidate.value : draftUpdates[activeField.key];
|
|
2250
2337
|
setInputValue(activeField.sensitive
|
|
2251
2338
|
? draft === undefined ? '' : String(draft)
|
|
@@ -2351,7 +2438,9 @@ export function ConsoleAppV4(props) {
|
|
|
2351
2438
|
|| Boolean(route.name === 'result' && snapshot.result && 'operationKind' in snapshot.result
|
|
2352
2439
|
&& (snapshot.result.operationKind === 'portableInstall'
|
|
2353
2440
|
|| ('summary' in snapshot.result && snapshot.result.summary?.configDiagnostics?.length))));
|
|
2354
|
-
const characterInput = !activeVariantPreview && !activeFieldIsConst && !activePropertyIsConst
|
|
2441
|
+
const characterInput = !activeVariantPreview && !activeFieldIsConst && !activePropertyIsConst
|
|
2442
|
+
&& !suggestionMenu && !(suggestedScalar?.type === 'boolean' && route.name === 'configObjectPropertyEditor')
|
|
2443
|
+
&& isCharacterInputMode(route, searchFocus)
|
|
2355
2444
|
|| route.name === 'operationReportPreview' && reportSaveMode;
|
|
2356
2445
|
const canOpenHelp = !tooSmall && !characterInput && !preparationRunning;
|
|
2357
2446
|
useEffect(() => {
|
|
@@ -2407,6 +2496,20 @@ export function ConsoleAppV4(props) {
|
|
|
2407
2496
|
+ Math.max(0, wrapConsoleText(actionError ?? description ?? '', size.columns - 2).length - 1)
|
|
2408
2497
|
+ Math.max(0, wrapConsoleText(title, size.columns - 2).length - 1),
|
|
2409
2498
|
});
|
|
2499
|
+
const suggestionActions = (scalar, current, select, custom) => [
|
|
2500
|
+
{ label: '自定义', run: custom },
|
|
2501
|
+
...(suggestions.items.length ? suggestions.items : scalar.choices?.presets ?? []).map((item) => ({
|
|
2502
|
+
label: `${safeConfigText(item.title)}${item.recommended ? '(推荐)' : ''}`,
|
|
2503
|
+
description: item.description ? safeConfigText(item.description) : undefined,
|
|
2504
|
+
selected: item.value === current,
|
|
2505
|
+
run: () => select(item.value),
|
|
2506
|
+
})),
|
|
2507
|
+
];
|
|
2508
|
+
const suggestionRows = (items) => {
|
|
2509
|
+
const compact = policy.mode === 'compact';
|
|
2510
|
+
const viewport = actionViewport(items, compact, focus, scrollOffset, pageActionBudget(2));
|
|
2511
|
+
return _jsx(SemanticRows, { actions: items, focus: focus, kind: "choice", compact: compact, offset: viewport.offset, limit: viewport.limit });
|
|
2512
|
+
};
|
|
2410
2513
|
let detailNavigation;
|
|
2411
2514
|
const detailCardContent = (subject, completionLines = []) => {
|
|
2412
2515
|
const cardWidth = size.columns - 2;
|
|
@@ -3575,7 +3678,8 @@ export function ConsoleAppV4(props) {
|
|
|
3575
3678
|
const fieldEditor = (field) => {
|
|
3576
3679
|
return field.type;
|
|
3577
3680
|
};
|
|
3578
|
-
const fieldEditorMode = (field) => (field.choices?.length ?? 0) > 0 || 'valueRef' in field.definition && field.definition.valueRef
|
|
3681
|
+
const fieldEditorMode = (field) => (field.choices?.length ?? 0) > 0 || 'valueRef' in field.definition && field.definition.valueRef
|
|
3682
|
+
|| configSuggestionScalar(field.definition) ? { mode: 'choices' } : {};
|
|
3579
3683
|
const openConfigTarget = (candidate) => {
|
|
3580
3684
|
const currentFlowId = snapshot.router.currentFlowId;
|
|
3581
3685
|
const storedAnchor = configOverviewAnchors.current.get(candidate.pluginId);
|
|
@@ -3596,13 +3700,11 @@ export function ConsoleAppV4(props) {
|
|
|
3596
3700
|
return;
|
|
3597
3701
|
setConfigActionError(undefined);
|
|
3598
3702
|
if (activeField && editingProfile) {
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
return;
|
|
3605
|
-
}
|
|
3703
|
+
const error = invalidReferenceNotice(activeField.definition, value);
|
|
3704
|
+
if (error) {
|
|
3705
|
+
setObjectError(error);
|
|
3706
|
+
setInputError(error);
|
|
3707
|
+
return;
|
|
3606
3708
|
}
|
|
3607
3709
|
}
|
|
3608
3710
|
if (arrayItem && activeArrayKey && activeArrayDraft && activeField) {
|
|
@@ -3655,10 +3757,17 @@ export function ConsoleAppV4(props) {
|
|
|
3655
3757
|
go({
|
|
3656
3758
|
name: 'configFieldEditor', pluginId: configRoute.pluginId, layer: configRoute.layer,
|
|
3657
3759
|
fieldKey: activeField.key, editor: activeField.definition.items.type,
|
|
3658
|
-
...(activeField.definition.items.choices || 'valueRef' in activeField.definition.items && activeField.definition.items.valueRef
|
|
3760
|
+
...(activeField.definition.items.choices || 'valueRef' in activeField.definition.items && activeField.definition.items.valueRef
|
|
3761
|
+
|| configSuggestionScalar(activeField.definition.items) ? { mode: 'choices' } : {}),
|
|
3659
3762
|
arrayItem: { rowId },
|
|
3763
|
+
...(nestedArray ? { nestedArray } : {}),
|
|
3660
3764
|
});
|
|
3661
3765
|
};
|
|
3766
|
+
const closeNestedArray = () => {
|
|
3767
|
+
setArrayDrafts((current) => Object.fromEntries(Object.entries(current).filter(([key]) => key !== activeArrayKey)));
|
|
3768
|
+
setObjectError(undefined);
|
|
3769
|
+
back();
|
|
3770
|
+
};
|
|
3662
3771
|
const commitArray = () => {
|
|
3663
3772
|
if (!activeField || activeField.definition.type !== 'array' || !activeArrayDraft || !activeArrayKey)
|
|
3664
3773
|
return;
|
|
@@ -3668,6 +3777,19 @@ export function ConsoleAppV4(props) {
|
|
|
3668
3777
|
setObjectError(issues.slice(0, 2).map(objectIssueText).join(';'));
|
|
3669
3778
|
return;
|
|
3670
3779
|
}
|
|
3780
|
+
if (nestedArray && parentObjectKey && parentObjectDraft) {
|
|
3781
|
+
const error = invalidReferenceNotice(activeField.definition, value);
|
|
3782
|
+
if (error) {
|
|
3783
|
+
setObjectError(error);
|
|
3784
|
+
return;
|
|
3785
|
+
}
|
|
3786
|
+
if (arrayDraftChanged(activeArrayDraft))
|
|
3787
|
+
writeObjectDraft(parentObjectKey, parentObjectInitial, {
|
|
3788
|
+
...parentObjectDraft, [nestedArray.propertyKey]: value,
|
|
3789
|
+
});
|
|
3790
|
+
closeNestedArray();
|
|
3791
|
+
return;
|
|
3792
|
+
}
|
|
3671
3793
|
if (!arrayDraftChanged(activeArrayDraft)) {
|
|
3672
3794
|
setArrayDrafts((current) => Object.fromEntries(Object.entries(current).filter(([key]) => key !== activeArrayKey)));
|
|
3673
3795
|
back();
|
|
@@ -3689,18 +3811,28 @@ export function ConsoleAppV4(props) {
|
|
|
3689
3811
|
};
|
|
3690
3812
|
openConfigTarget(candidate);
|
|
3691
3813
|
};
|
|
3692
|
-
const
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
setChangedObjectDraftKeys((current) => configValuesEqual(initial, value)
|
|
3698
|
-
? current.filter((key) => key !== activeObjectKey)
|
|
3699
|
-
: [...new Set([...current, activeObjectKey])]);
|
|
3814
|
+
const writeObjectDraft = (key, initial, value) => {
|
|
3815
|
+
setObjectDrafts((current) => ({ ...current, [key]: value }));
|
|
3816
|
+
setChangedObjectDraftKeys((current) => configValuesEqual(initial ?? {}, value)
|
|
3817
|
+
? current.filter((currentKey) => currentKey !== key)
|
|
3818
|
+
: [...new Set([...current, key])]);
|
|
3700
3819
|
setObjectError(undefined);
|
|
3701
3820
|
setConfigActionError(undefined);
|
|
3702
3821
|
};
|
|
3822
|
+
const updateObjectDraft = (value) => {
|
|
3823
|
+
if (activeObjectKey)
|
|
3824
|
+
writeObjectDraft(activeObjectKey, activeObjectInitial, value);
|
|
3825
|
+
};
|
|
3826
|
+
const formatNestedIssue = (issue, path) => {
|
|
3827
|
+
const suffix = issue.path.segments?.slice(1) ?? (issue.path.property === undefined ? [] : [issue.path.property]);
|
|
3828
|
+
return safeConfigText(formatPluginConfigIssue({
|
|
3829
|
+
...issue, path: { ...issue.path, segments: [...path, ...suffix] },
|
|
3830
|
+
}));
|
|
3831
|
+
};
|
|
3703
3832
|
const objectIssueText = (issue) => {
|
|
3833
|
+
if (nestedArray || (issue.path.segments?.length ?? 0) > 3) {
|
|
3834
|
+
return formatNestedIssue(issue, activeFieldPath);
|
|
3835
|
+
}
|
|
3704
3836
|
const index = issue.path.segments?.find((part) => typeof part === 'number');
|
|
3705
3837
|
const itemDefinition = activeTopField?.definition.type === 'array' ? activeTopField.definition.items : undefined;
|
|
3706
3838
|
const property = issue.path.property;
|
|
@@ -3722,7 +3854,8 @@ export function ConsoleAppV4(props) {
|
|
|
3722
3854
|
setChangedObjectDraftKeys((current) => current.filter((key) => key !== activeObjectKey));
|
|
3723
3855
|
}
|
|
3724
3856
|
};
|
|
3725
|
-
const objectPropertyStage = (definition) => definition.type === 'boolean' ||
|
|
3857
|
+
const objectPropertyStage = (definition) => definition.type === 'boolean' || 'choices' in definition && definition.choices
|
|
3858
|
+
|| 'valueRef' in definition && definition.valueRef || configSuggestionScalar(definition) ? 'choices' : 'custom';
|
|
3726
3859
|
const openObjectProperty = (propertyKey, dynamic) => {
|
|
3727
3860
|
if (!activeField || activeField.definition.type !== 'object')
|
|
3728
3861
|
return;
|
|
@@ -3732,6 +3865,18 @@ export function ConsoleAppV4(props) {
|
|
|
3732
3865
|
: activeField.definition.additionalProperties);
|
|
3733
3866
|
if (!definition || 'const' in definition && definition.const !== undefined && !('valueRef' in definition && definition.valueRef))
|
|
3734
3867
|
return;
|
|
3868
|
+
if (isNestedConfigObjectArray(definition)) {
|
|
3869
|
+
setObjectError(undefined);
|
|
3870
|
+
go({
|
|
3871
|
+
name: 'configFieldEditor',
|
|
3872
|
+
pluginId: configRoute.pluginId,
|
|
3873
|
+
layer: configRoute.layer,
|
|
3874
|
+
fieldKey: activeField.key,
|
|
3875
|
+
editor: 'array',
|
|
3876
|
+
nestedArray: { propertyKey, ...(arrayItem ? { parentItem: arrayItem } : {}) },
|
|
3877
|
+
});
|
|
3878
|
+
return;
|
|
3879
|
+
}
|
|
3735
3880
|
const exists = activeObjectDraft && Object.hasOwn(activeObjectDraft, propertyKey);
|
|
3736
3881
|
go({
|
|
3737
3882
|
name: 'configObjectPropertyEditor',
|
|
@@ -3742,20 +3887,17 @@ export function ConsoleAppV4(props) {
|
|
|
3742
3887
|
dynamic,
|
|
3743
3888
|
stage: exists ? 'action' : objectPropertyStage(definition),
|
|
3744
3889
|
...(arrayItem ? { arrayItem } : {}),
|
|
3890
|
+
...(nestedArray ? { nestedArray } : {}),
|
|
3745
3891
|
});
|
|
3746
3892
|
};
|
|
3747
3893
|
const updateObjectProperty = (propertyKey, value) => {
|
|
3748
3894
|
if (!activeField || activeField.definition.type !== 'object' || !activeObjectDraft)
|
|
3749
3895
|
return false;
|
|
3750
3896
|
const definition = activeObjectProperties?.[propertyKey] ?? activeField.definition.additionalProperties;
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
setInputError(referenceNotice(scalar, selected) ?? '引用选项已变化,请重新选择。');
|
|
3756
|
-
return false;
|
|
3757
|
-
}
|
|
3758
|
-
}
|
|
3897
|
+
const referenceError = definition && value !== undefined ? invalidReferenceNotice(definition, value) : undefined;
|
|
3898
|
+
if (referenceError) {
|
|
3899
|
+
setInputError(referenceError);
|
|
3900
|
+
return false;
|
|
3759
3901
|
}
|
|
3760
3902
|
const candidate = { ...activeObjectDraft, [propertyKey]: value };
|
|
3761
3903
|
if (value === undefined)
|
|
@@ -6690,7 +6832,7 @@ export function ConsoleAppV4(props) {
|
|
|
6690
6832
|
const showChoices = Boolean(scalarReference) || (activeField.choices?.length ?? 0) > 0 && route.mode !== 'custom';
|
|
6691
6833
|
const targetFields = [route.layer.profile].flatMap((profile) => configLayerPages[profile]?.groups.flatMap((group) => group.fields).filter((field) => field.key === activeField.key) ?? []);
|
|
6692
6834
|
const canSet = targetFields.some(configFieldCanSet);
|
|
6693
|
-
const canUnset = !arrayItem && targetFields.some(configFieldCanUnset);
|
|
6835
|
+
const canUnset = !arrayItem && !nestedArray && targetFields.some(configFieldCanUnset);
|
|
6694
6836
|
if (!canSet) {
|
|
6695
6837
|
title = activeField.title;
|
|
6696
6838
|
description = activeField.invalidOverrideIssue ?? '此旧值不允许修改;可以删除覆盖并恢复继承。';
|
|
@@ -6718,6 +6860,18 @@ export function ConsoleAppV4(props) {
|
|
|
6718
6860
|
? [{ label: '写入此固定值', run: () => updateDraft(activeField.key, constant) }] : [];
|
|
6719
6861
|
content = _jsxs(Box, { flexDirection: "column", children: [_jsx(StaticRow, { title: `固定值 · ${presentConfigValue({ definition: activeField.definition, value: constant }).text}`, compact: true }), _jsx(SemanticRows, { actions: actions, focus: focus, kind: "action", compact: true })] });
|
|
6720
6862
|
}
|
|
6863
|
+
else if (suggestionMenu && suggestedScalar) {
|
|
6864
|
+
title = `选择${activeField.title}`;
|
|
6865
|
+
description = suggestions.notice;
|
|
6866
|
+
help = '↑↓ 移动 · Enter 使用 · r 刷新建议 · Esc 取消';
|
|
6867
|
+
actions = suggestionActions(suggestedScalar, (arrayItem ? itemValue : draftUpdates[activeField.key])
|
|
6868
|
+
?? activeField.draftValue ?? activeField.value, (value) => updateDraft(activeField.key, value), () => {
|
|
6869
|
+
props.controller.replace({ ...route, mode: 'custom' });
|
|
6870
|
+
setFocus(0);
|
|
6871
|
+
setScrollOffset(0);
|
|
6872
|
+
});
|
|
6873
|
+
content = suggestionRows(actions);
|
|
6874
|
+
}
|
|
6721
6875
|
else if (showChoices) {
|
|
6722
6876
|
title = `选择${activeField.title}`;
|
|
6723
6877
|
description = activeField.type !== 'boolean' && activeField.allowCustom
|
|
@@ -6758,8 +6912,9 @@ export function ConsoleAppV4(props) {
|
|
|
6758
6912
|
}
|
|
6759
6913
|
else if (route.editor === 'array' && activeField.definition.type === 'array') {
|
|
6760
6914
|
title = activeField.title;
|
|
6761
|
-
description = objectError ?? `${activeArrayDraft?.rows.length ?? 0} 项 ·
|
|
6762
|
-
|
|
6915
|
+
description = objectError ?? `${activeArrayDraft?.rows.length ?? 0} 项 · ${nestedArray
|
|
6916
|
+
? '确认后更新当前对象草稿' : '顺序将按当前列表保存'}`;
|
|
6917
|
+
help = '↑↓ 移动 · Enter 编辑 · a 操作 · c 使用此列表 · Esc 取消';
|
|
6763
6918
|
const rows = activeArrayDraft?.rows ?? [];
|
|
6764
6919
|
const definition = activeField.definition;
|
|
6765
6920
|
const errors = activeArrayDraft ? validatePluginConfigValue(definition, arrayDraftValue(activeArrayDraft), activeField.key) : [];
|
|
@@ -6775,6 +6930,14 @@ export function ConsoleAppV4(props) {
|
|
|
6775
6930
|
label: '调整当前项', disabled: rows.length === 0 ? '列表为空' : undefined,
|
|
6776
6931
|
run: () => { setArrayToolFocus(0); setArrayToolsOpen(true); },
|
|
6777
6932
|
}, { label: '使用此列表 [c]', run: commitArray }];
|
|
6933
|
+
if (nestedArray && parentObjectKey && parentObjectDraft && nestedValue !== undefined) {
|
|
6934
|
+
bottomActions.push({ label: '删除属性', status: 'error', run: () => {
|
|
6935
|
+
const next = { ...parentObjectDraft };
|
|
6936
|
+
delete next[nestedArray.propertyKey];
|
|
6937
|
+
writeObjectDraft(parentObjectKey, parentObjectInitial, next);
|
|
6938
|
+
closeNestedArray();
|
|
6939
|
+
} });
|
|
6940
|
+
}
|
|
6778
6941
|
actions = [...itemActions, ...bottomActions];
|
|
6779
6942
|
content = _jsxs(Box, { flexDirection: "column", children: [rows.length === 0 ? _jsx(Text, { children: "\u7A7A\u5217\u8868\uFF1B\u786E\u8BA4\u4F7F\u7528\u540E\u8986\u76D6\u539F\u503C\u3002" }) : null, errors.length ? _jsx(Text, { color: tuiTheme.colors.warning, children: errors.slice(0, 2).map(objectIssueText).join(';') }) : null, _jsx(SequenceRows, { actions: actions, itemCount: itemActions.length, focus: focus, scrollOffset: scrollOffset, compact: true, columns: size.columns, rowBudget: pageActionBudget(errors.length ? 5 : 3) })] });
|
|
6780
6943
|
}
|
|
@@ -6810,6 +6973,7 @@ export function ConsoleAppV4(props) {
|
|
|
6810
6973
|
const presentation = presentConfigValue({ definition,
|
|
6811
6974
|
value: activeObjectDraft[property], privateValue: activeField.sensitive,
|
|
6812
6975
|
configured: Object.hasOwn(activeObjectDraft, property),
|
|
6976
|
+
nestedArray: isNestedConfigObjectArray(definition),
|
|
6813
6977
|
});
|
|
6814
6978
|
return presentation.state === 'unset' && 'required' in definition && definition.required
|
|
6815
6979
|
? '必填 · 未设置' : presentation.text;
|
|
@@ -6886,12 +7050,12 @@ export function ConsoleAppV4(props) {
|
|
|
6886
7050
|
help = '输入 · Enter 使用 · Ctrl-U 清空输入 · Esc 取消';
|
|
6887
7051
|
description = route.editor === 'number'
|
|
6888
7052
|
? `允许范围:${activeField.min ?? '不限'}–${activeField.max ?? '不限'}${activeField.unit ? ` ${activeField.unit}` : ''}。`
|
|
6889
|
-
: activeField.sensitive ? '当前值不会回显;留空不会自动删除旧值。' : activeField.description ?? '';
|
|
7053
|
+
: activeField.sensitive ? '当前值不会回显;留空不会自动删除旧值。' : suggestions.notice ?? activeField.description ?? '';
|
|
6890
7054
|
content = _jsx(InputCard, { focused: true, title: _jsx(InputDisplay, { value: inputValue, sensitive: activeField.sensitive, placeholder: activeField.placeholder, columns: Math.max(8, size.columns - 8) }), description: inputError ?? (activeField.sensitive ? '输入已隐藏。' : activeField.placeholder ?? '按 Enter 使用输入值。'), status: inputError ? 'error' : undefined });
|
|
6891
7055
|
}
|
|
6892
7056
|
if (canUnset) {
|
|
6893
7057
|
const unset = { label: '恢复继承', description: '选择要删除覆盖值的位置', run: () => removeDraft(activeField.key) };
|
|
6894
|
-
const inputEditor = canSet && !showChoices && (route.editor === 'number' || route.editor === 'string');
|
|
7058
|
+
const inputEditor = canSet && !suggestionMenu && !showChoices && (route.editor === 'number' || route.editor === 'string');
|
|
6895
7059
|
help += ' · Ctrl-R 恢复继承';
|
|
6896
7060
|
if (!inputEditor) {
|
|
6897
7061
|
const offset = actions.length;
|
|
@@ -6903,7 +7067,7 @@ export function ConsoleAppV4(props) {
|
|
|
6903
7067
|
else if (route.name === 'configObjectPropertyEditor' && plugin
|
|
6904
7068
|
&& activeField?.definition.type === 'object' && activeObjectDraft) {
|
|
6905
7069
|
const property = route.propertyKey;
|
|
6906
|
-
const definition = activePropertyDefinition;
|
|
7070
|
+
const definition = isNestedConfigObjectArray(activePropertyDefinition) ? undefined : activePropertyDefinition;
|
|
6907
7071
|
const propertyTitle = definition && property ? definition.title ?? property : '动态键';
|
|
6908
7072
|
breadcrumb = `${plugin.displayName} / 设置 / ${activeField.title} / ${propertyTitle}`;
|
|
6909
7073
|
if (activeVariantPreview) {
|
|
@@ -6984,6 +7148,27 @@ export function ConsoleAppV4(props) {
|
|
|
6984
7148
|
];
|
|
6985
7149
|
content = _jsx(SemanticRows, { actions: actions, focus: focus, kind: "action", compact: policy.mode === 'compact' });
|
|
6986
7150
|
}
|
|
7151
|
+
else if (property !== undefined && suggestionMenu && suggestedScalar) {
|
|
7152
|
+
title = `选择${propertyTitle}`;
|
|
7153
|
+
description = suggestions.notice;
|
|
7154
|
+
help = '↑↓ 移动 · Enter 使用 · r 刷新建议 · Esc 取消';
|
|
7155
|
+
actions = suggestionActions(suggestedScalar, activeObjectDraft[property], (value) => { if (updateObjectProperty(property, value))
|
|
7156
|
+
back(); }, () => {
|
|
7157
|
+
props.controller.replace({ ...route, stage: 'custom' });
|
|
7158
|
+
setFocus(0);
|
|
7159
|
+
setScrollOffset(0);
|
|
7160
|
+
});
|
|
7161
|
+
content = suggestionRows(actions);
|
|
7162
|
+
}
|
|
7163
|
+
else if (property !== undefined && suggestedScalar?.type === 'boolean' && route.stage === 'custom') {
|
|
7164
|
+
title = `选择${propertyTitle}`;
|
|
7165
|
+
actions = [true, false].map((value) => ({
|
|
7166
|
+
label: value ? '开启' : '关闭', selected: activeObjectDraft[property] === value,
|
|
7167
|
+
run: () => { if (updateObjectProperty(property, value))
|
|
7168
|
+
back(); },
|
|
7169
|
+
}));
|
|
7170
|
+
content = _jsx(SemanticRows, { actions: actions, focus: focus, kind: "choice", compact: true });
|
|
7171
|
+
}
|
|
6987
7172
|
else if (property !== undefined && definition && route.stage === 'choices') {
|
|
6988
7173
|
title = `选择${propertyTitle}`;
|
|
6989
7174
|
description = definition.type !== 'boolean' && definition.choices?.allowCustom
|
|
@@ -7040,7 +7225,7 @@ export function ConsoleAppV4(props) {
|
|
|
7040
7225
|
title = `编辑${propertyTitle}`;
|
|
7041
7226
|
description = '确认后更新当前对象草稿;Esc 取消此属性的全部修改。';
|
|
7042
7227
|
help = '↑↓ 移动 · Enter 编辑 · a 操作 · c 使用 · Esc 取消';
|
|
7043
|
-
content = _jsx(ConfigLeafEditor, { definition: definition, value: activeObjectDraft[property], propertyKey: property, referenceContext: referenceContext, referenceNotice: referenceNotice, initialDraft: referenceLeafDrafts.current.get(snapshot.router.currentFrameId), onOpenReferenceSource: openReferenceSource, columns: size.columns, rowBudget: pageActionBudget(1), active: !overlay && !tooSmall && !busy, error: inputError, onDraftChange: setNestedPropertyRevision, onCancel: () => { referenceLeafDrafts.current.delete(snapshot.router.currentFrameId); back(); }, onConfirm: (value) => {
|
|
7228
|
+
content = _jsx(ConfigLeafEditor, { definition: definition, value: activeObjectDraft[property], propertyKey: property, formatIssue: nestedArray ? (issue, item) => formatNestedIssue(issue, [...activeFieldPath, property, ...(item === undefined ? [] : [item])]) : undefined, referenceContext: referenceContext, referenceNotice: referenceNotice, initialDraft: referenceLeafDrafts.current.get(snapshot.router.currentFrameId), onOpenReferenceSource: openReferenceSource, columns: size.columns, rowBudget: pageActionBudget(1), active: !overlay && !tooSmall && !busy, error: inputError, onDraftChange: setNestedPropertyRevision, onCancel: () => { referenceLeafDrafts.current.delete(snapshot.router.currentFrameId); back(); }, onConfirm: (value) => {
|
|
7044
7229
|
if (!updateObjectProperty(property, value))
|
|
7045
7230
|
return false;
|
|
7046
7231
|
referenceLeafDrafts.current.delete(snapshot.router.currentFrameId);
|
|
@@ -7050,7 +7235,7 @@ export function ConsoleAppV4(props) {
|
|
|
7050
7235
|
}
|
|
7051
7236
|
else if (property !== undefined && definition) {
|
|
7052
7237
|
title = activePropertySensitive ? '输入敏感值' : `输入${propertyTitle}`;
|
|
7053
|
-
description = inputError ?? (activePropertySensitive ? '输入已隐藏。' : definition.description ?? '按 Enter 使用输入值。');
|
|
7238
|
+
description = inputError ?? (activePropertySensitive ? '输入已隐藏。' : suggestions.notice ?? definition.description ?? '按 Enter 使用输入值。');
|
|
7054
7239
|
help = '输入 · Enter 使用 · Ctrl-U 清空输入 · Esc 取消';
|
|
7055
7240
|
content = _jsx(InputCard, { focused: true, title: _jsx(InputDisplay, { value: inputValue, sensitive: activePropertySensitive, columns: Math.max(8, size.columns - 8) }), description: description, status: inputError ? 'error' : undefined });
|
|
7056
7241
|
}
|
|
@@ -10871,6 +11056,10 @@ export function ConsoleAppV4(props) {
|
|
|
10871
11056
|
setSourceInputError(undefined);
|
|
10872
11057
|
return;
|
|
10873
11058
|
}
|
|
11059
|
+
if (suggestionMenu && input.toLowerCase() === 'r' && !key.ctrl && !key.meta) {
|
|
11060
|
+
suggestions.refresh();
|
|
11061
|
+
return;
|
|
11062
|
+
}
|
|
10874
11063
|
if (route.name === 'configFieldEditor' && route.mode !== 'choices' && input === 'c'
|
|
10875
11064
|
&& (route.editor === 'array' || route.editor === 'object')) {
|
|
10876
11065
|
if (route.editor === 'array')
|
|
@@ -10879,7 +11068,7 @@ export function ConsoleAppV4(props) {
|
|
|
10879
11068
|
commitObjectDraft();
|
|
10880
11069
|
return;
|
|
10881
11070
|
}
|
|
10882
|
-
if (route.name === 'configFieldEditor' && !arrayItem && activeField && key.ctrl && input.toLowerCase() === 'r') {
|
|
11071
|
+
if (route.name === 'configFieldEditor' && !arrayItem && !nestedArray && activeField && key.ctrl && input.toLowerCase() === 'r') {
|
|
10883
11072
|
const canUnset = [route.layer.profile].some((profile) => configLayerPages[profile]?.groups.flatMap((group) => group.fields)
|
|
10884
11073
|
.some((field) => field.key === activeField.key && configFieldCanUnset(field)));
|
|
10885
11074
|
if (canUnset)
|
|
@@ -10887,6 +11076,7 @@ export function ConsoleAppV4(props) {
|
|
|
10887
11076
|
return;
|
|
10888
11077
|
}
|
|
10889
11078
|
if (route.name === 'configFieldEditor'
|
|
11079
|
+
&& !suggestionMenu
|
|
10890
11080
|
&& !activeFieldIsConst
|
|
10891
11081
|
&& !(activeField && 'valueRef' in activeField.definition && activeField.definition.valueRef)
|
|
10892
11082
|
&& (route.editor === 'string' || route.editor === 'number')
|
|
@@ -10935,6 +11125,7 @@ export function ConsoleAppV4(props) {
|
|
|
10935
11125
|
}
|
|
10936
11126
|
if (route.name === 'configObjectPropertyEditor'
|
|
10937
11127
|
&& (route.stage === 'key' || route.stage === 'custom')
|
|
11128
|
+
&& suggestedScalar?.type !== 'boolean'
|
|
10938
11129
|
&& !activeVariantPreview
|
|
10939
11130
|
&& !activePropertyIsConst
|
|
10940
11131
|
&& !(activePropertyDefinition && 'valueRef' in activePropertyDefinition && activePropertyDefinition.valueRef && route.stage !== 'key')
|
|
@@ -11241,9 +11432,15 @@ export function ConsoleAppV4(props) {
|
|
|
11241
11432
|
}
|
|
11242
11433
|
else if (globalAction === 'back'
|
|
11243
11434
|
&& (route.name === 'configFieldEditor' || route.name === 'configFieldAction')) {
|
|
11435
|
+
if (nestedArray && !arrayItem) {
|
|
11436
|
+
closeNestedArray();
|
|
11437
|
+
return;
|
|
11438
|
+
}
|
|
11244
11439
|
const returnToReferenceScope = false;
|
|
11245
|
-
if (!returnToReferenceScope)
|
|
11440
|
+
if (!returnToReferenceScope && !nestedArray)
|
|
11246
11441
|
setConfigCandidate(undefined);
|
|
11442
|
+
if (nestedArray)
|
|
11443
|
+
setObjectError(undefined);
|
|
11247
11444
|
if (activeArrayKey && !arrayItem && !returnToReferenceScope) {
|
|
11248
11445
|
setArrayDrafts((current) => Object.fromEntries(Object.entries(current).filter(([key]) => key !== activeArrayKey)));
|
|
11249
11446
|
setObjectError(undefined);
|