|
12 | 12 | import { shouldGuardConfigurationTransition } from "./configurationGuard.js"; |
13 | 13 | import { clearSelectedSourceState } from "./policyEditorState.js"; |
14 | 14 | import { stateModelWorkspaceDialog } from "./stateModelNavigation.js"; |
| 15 | + import { objectSnapshot } from "./editorDirtyState.js"; |
15 | 16 |
|
16 | 17 | const STATE_MODEL_URL = "http://localhost:8090/models"; |
17 | 18 | const CLI_AGENT_SETTING_KEYS = { |
|
347 | 348 | } |
348 | 349 | } |
349 | 350 |
|
| 351 | + async function openVisualSettingsGroup(groupId) { |
| 352 | + await guardConfigurationTransition(async () => { |
| 353 | + openEditorImmediate("settings-form"); |
| 354 | + selectedSettingsGroupId = groupId || selectedSettingsGroupId; |
| 355 | + if (!selectedSettingsGroupId && workspaceDocument?.settingsGroups?.length > 0) { |
| 356 | + selectedSettingsGroupId = workspaceDocument.settingsGroups[0].id; |
| 357 | + } |
| 358 | + }, "settings-form"); |
| 359 | + } |
| 360 | +
|
350 | 361 | async function openPoliciesProperties() { |
351 | 362 | await openEditor("policies-properties"); |
352 | 363 | } |
|
962 | 973 | return (selectedSourceFile.content || "") !== (savedSourceContents[selectedSourceFile.name] || ""); |
963 | 974 | } |
964 | 975 |
|
| 976 | + function hasCurrentSelectedSourceChanges() { |
| 977 | + if (!selectedSourceFile?.category) { |
| 978 | + return false; |
| 979 | + } |
| 980 | +
|
| 981 | + return hasSelectedSourceChanges([selectedSourceFile.category]); |
| 982 | + } |
| 983 | +
|
965 | 984 | function configurationDirtyAreas() { |
966 | 985 | return { |
967 | 986 | settings: hasSettingsChanges(), |
|
1675 | 1694 | currentEditorDocument = null; |
1676 | 1695 | } else if (selectedEditor === "test-settings") { |
1677 | 1696 | currentEditorDocument = { |
1678 | | - title: "Edit test.settings file", |
1679 | | - saveLabel: "Save test.settings", |
| 1697 | + title: "Edit Settings", |
| 1698 | + saveLabel: "Save Settings", |
| 1699 | + dirty: hasSettingsChanges(), |
1680 | 1700 | save: () => saveWorkspaceFile( |
1681 | 1701 | `/api/workspaces/${selectedWorkspaceName}/test-settings`, |
1682 | 1702 | workspaceDocument.testSettings.content |
|
1685 | 1705 | } else if (selectedEditor === "settings-form") { |
1686 | 1706 | currentEditorDocument = { |
1687 | 1707 | title: "Edit Settings", |
1688 | | - saveLabel: "Save settings", |
| 1708 | + saveLabel: "Save Settings", |
| 1709 | + dirty: hasSettingsChanges(), |
1689 | 1710 | save: saveVisualSettings |
1690 | 1711 | }; |
1691 | 1712 | } else if (selectedEditor === "policies-properties") { |
1692 | 1713 | currentEditorDocument = { |
1693 | 1714 | title: "Edit policies.properties", |
1694 | 1715 | saveLabel: "Save policies.properties", |
| 1716 | + dirty: hasPoliciesPropertiesChanges(), |
1695 | 1717 | save: () => saveWorkspaceFile( |
1696 | 1718 | `/api/workspaces/${selectedWorkspaceName}/policies-properties`, |
1697 | 1719 | workspaceDocument.policiesProperties.content |
|
1701 | 1723 | currentEditorDocument = { |
1702 | 1724 | title: "Edit composition.properties", |
1703 | 1725 | saveLabel: "Save composition.properties", |
| 1726 | + dirty: hasCompositionPropertiesChanges(), |
1704 | 1727 | save: () => saveWorkspaceFile( |
1705 | 1728 | `/api/workspaces/${selectedWorkspaceName}/composition-properties`, |
1706 | 1729 | workspaceDocument.compositionProperties.content |
|
1710 | 1733 | currentEditorDocument = { |
1711 | 1734 | title: selectedSourceFile.name, |
1712 | 1735 | saveLabel: "Save source", |
| 1736 | + dirty: hasSelectedSourceChanges([selectedSourceFile.category]), |
1713 | 1737 | save: saveSelectedSource |
1714 | 1738 | }; |
1715 | 1739 | } else { |
1716 | 1740 | currentEditorDocument = null; |
1717 | 1741 | } |
1718 | 1742 |
|
1719 | | - function selectSettingsGroup(groupId) { |
1720 | | - selectedSettingsGroupId = groupId || ""; |
1721 | | - } |
1722 | | -
|
1723 | 1743 | $: if (selectedEditor === "settings-form" && !selectedSettingsGroupId && workspaceDocument?.settingsGroups?.length > 0) { |
1724 | 1744 | selectedSettingsGroupId = workspaceDocument.settingsGroups[0].id; |
1725 | 1745 | } |
|
2127 | 2147 | setWorkspaceSettingByKey(CLI_AGENT_SETTING_KEYS.promptTitle, normalizedSettings.promptTitle); |
2128 | 2148 | setWorkspaceSettingByKey(CLI_AGENT_SETTING_KEYS.promptText, normalizedSettings.promptText); |
2129 | 2149 | await saveVisualSettings(); |
2130 | | - cliAgentSettings = normalizedSettings; |
2131 | | - savedCliAgentSettings = normalizedSettings; |
| 2150 | + cliAgentSettings = objectSnapshot(normalizedSettings); |
| 2151 | + savedCliAgentSettings = objectSnapshot(normalizedSettings); |
2132 | 2152 | showTemporaryMessage("Agent CLI settings saved."); |
2133 | 2153 | return true; |
2134 | 2154 | } catch (cliError) { |
|
2225 | 2245 | openPoliciesProperties={openPoliciesProperties} |
2226 | 2246 | openTestSettings={openTestSettings} |
2227 | 2247 | openVisualSettings={openVisualSettings} |
| 2248 | + openVisualSettingsGroup={openVisualSettingsGroup} |
2228 | 2249 | policySourceFiles={policySourceFiles} |
2229 | 2250 | closeCompositionSourceEditor={closeCompositionSourceEditor} |
2230 | 2251 | closePolicySourceEditor={closePolicySourceEditor} |
|
2234 | 2255 | createPolicySource={createPolicySource} |
2235 | 2256 | javaCompileResult={javaCompileResult} |
2236 | 2257 | regexValidationResults={regexValidationResults} |
| 2258 | + savedCompositionPropertiesContent={savedCompositionPropertiesContent} |
| 2259 | + savedPoliciesPropertiesContent={savedPoliciesPropertiesContent} |
| 2260 | + savedTestSettingsContent={savedTestSettingsContent} |
2237 | 2261 | saving={saving} |
2238 | 2262 | setSettingValue={setSettingValue} |
2239 | 2263 | selectSource={selectSource} |
2240 | 2264 | selectCompositionFlowNode={selectCompositionFlowNode} |
2241 | | - selectSettingsGroup={selectSettingsGroup} |
2242 | 2265 | selectedEditor={selectedEditor} |
2243 | 2266 | selectedCompositionFlowNode={selectedCompositionFlowNode} |
2244 | 2267 | selectedSettingsGroupId={selectedSettingsGroupId} |
2245 | 2268 | selectedSourceFile={selectedSourceFile} |
| 2269 | + selectedSourceDirty={hasCurrentSelectedSourceChanges()} |
| 2270 | + selectedSourceSavedContent={selectedSourceFile?.name ? savedSourceContents[selectedSourceFile.name] || "" : ""} |
2246 | 2271 | restoreSettingDefault={restoreSettingDefault} |
2247 | 2272 | togglePolicySourceActivation={togglePolicySourceActivation} |
2248 | 2273 | validateRegexExpression={validateRegexExpression} |
|
2284 | 2309 | <CliModeView |
2285 | 2310 | cliAgentSettings={cliAgentSettings} |
2286 | 2311 | cliStatus={cliStatus} |
| 2312 | + savedCliAgentSettings={savedCliAgentSettings} |
2287 | 2313 | saving={saving} |
2288 | 2314 | saveCliAgentSettings={saveCliAgentSettings} |
2289 | 2315 | selectedWorkspaceSutConnector={selectedWorkspaceSutConnector} |
|
0 commit comments