@cognizant-ai-lab/ui-common 1.12.0-main.e044fee.146 → 1.13.0

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.
Files changed (58) hide show
  1. package/dist/components/AgentChat/ChatCommon/ChatCommon.js +6 -1
  2. package/dist/components/Common/Snackbar.js +12 -12
  3. package/dist/components/MultiAgentAccelerator/AgentFlow/AgentFlow.js +12 -5
  4. package/dist/components/MultiAgentAccelerator/Editor/Const.d.ts +2 -0
  5. package/dist/components/MultiAgentAccelerator/Editor/Const.js +5 -0
  6. package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.d.ts +0 -1
  7. package/dist/components/MultiAgentAccelerator/Editor/NetworkEditorDock.js +3 -5
  8. package/dist/components/MultiAgentAccelerator/Publish/Publish.d.ts +36 -0
  9. package/dist/components/MultiAgentAccelerator/Publish/Publish.js +99 -0
  10. package/dist/components/MultiAgentAccelerator/Publish/PublishButton.d.ts +16 -0
  11. package/dist/components/MultiAgentAccelerator/Publish/PublishButton.js +98 -0
  12. package/dist/components/MultiAgentAccelerator/Publish/PublishConfirmation.d.ts +15 -0
  13. package/dist/components/MultiAgentAccelerator/Publish/PublishConfirmation.js +8 -0
  14. package/dist/components/MultiAgentAccelerator/Publish/PublishIconButton.d.ts +17 -0
  15. package/dist/components/MultiAgentAccelerator/Publish/PublishIconButton.js +72 -0
  16. package/dist/components/MultiAgentAccelerator/Publish/PublishPanel.d.ts +13 -0
  17. package/dist/components/MultiAgentAccelerator/Publish/PublishPanel.js +28 -0
  18. package/dist/components/MultiAgentAccelerator/Publish/PublishedNetworkUrl.d.ts +11 -0
  19. package/dist/components/MultiAgentAccelerator/Publish/PublishedNetworkUrl.js +64 -0
  20. package/dist/components/MultiAgentAccelerator/Publish/usePublishTarget.d.ts +6 -0
  21. package/dist/components/MultiAgentAccelerator/Publish/usePublishTarget.js +33 -0
  22. package/dist/components/MultiAgentAccelerator/Sidebar/AgentNetworkTreeItem.js +9 -2
  23. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.d.ts +2 -0
  24. package/dist/components/MultiAgentAccelerator/Sidebar/TreeBuilder.js +2 -0
  25. package/dist/components/Settings/ApiKeyInput.d.ts +1 -0
  26. package/dist/components/Settings/ApiKeyInput.js +8 -3
  27. package/dist/components/Settings/Byok/ByokDialog.d.ts +24 -0
  28. package/dist/components/Settings/Byok/ByokDialog.js +42 -0
  29. package/dist/components/Settings/Byok/ByokInputs.d.ts +38 -0
  30. package/dist/components/Settings/Byok/ByokInputs.js +35 -0
  31. package/dist/components/Settings/Byok/ByokStorageTooltip.d.ts +7 -0
  32. package/dist/components/Settings/Byok/ByokStorageTooltip.js +41 -0
  33. package/dist/components/Settings/Byok/ByokUnsavedChangesModal.d.ts +23 -0
  34. package/dist/components/Settings/Byok/ByokUnsavedChangesModal.js +19 -0
  35. package/dist/components/Settings/Byok/index.d.ts +5 -0
  36. package/dist/components/Settings/Byok/index.js +20 -0
  37. package/dist/components/Settings/Byok/useByokKeyManager.d.ts +59 -0
  38. package/dist/components/Settings/Byok/useByokKeyManager.js +135 -0
  39. package/dist/components/Settings/PublishSettings.d.ts +15 -0
  40. package/dist/components/Settings/PublishSettings.js +109 -0
  41. package/dist/components/Settings/SettingsDialog.js +17 -133
  42. package/dist/components/Settings/SettingsLayout.d.ts +13 -0
  43. package/dist/components/Settings/SettingsLayout.js +59 -0
  44. package/dist/controller/publish/Publish.d.ts +29 -0
  45. package/dist/controller/publish/Publish.js +94 -0
  46. package/dist/generated/neuro-san/NeuroSanClient.d.ts +9 -0
  47. package/dist/index.d.ts +1 -0
  48. package/dist/index.js +1 -0
  49. package/dist/state/Environment.d.ts +4 -0
  50. package/dist/state/Environment.js +4 -0
  51. package/dist/state/Publish.d.ts +39 -0
  52. package/dist/state/Publish.js +41 -0
  53. package/dist/state/Settings.d.ts +18 -0
  54. package/dist/state/Settings.js +4 -0
  55. package/dist/tsconfig.build.tsbuildinfo +1 -1
  56. package/dist/utils/Url.d.ts +12 -0
  57. package/dist/utils/Url.js +32 -0
  58. package/package.json +1 -1
@@ -69,6 +69,8 @@ const EMPTY = {};
69
69
  // How many times to retry the entire agent interaction process. Some networks have a well-defined success condition.
70
70
  // For others, it's just "whenever the stream is done".
71
71
  const MAX_AGENT_RETRIES = 3;
72
+ // Keep long prompts navigable without allowing the input to take over the chat window.
73
+ const MAX_CHAT_INPUT_ROWS = 8;
72
74
  /**
73
75
  * Extract the final answer from the response from a legacy agent
74
76
  * @param response The response from the legacy agent
@@ -689,7 +691,7 @@ export const ChatCommon = ({ ref, ...props }) => {
689
691
  display: "flex",
690
692
  margin: "10px",
691
693
  position: "relative",
692
- }, children: [_jsx(Input, { autoComplete: "off", id: "user-input", multiline: true, placeholder: getPlaceholder(), ref: chatInputRef, sx: {
694
+ }, children: [_jsx(Input, { autoComplete: "off", id: "user-input", maxRows: MAX_CHAT_INPUT_ROWS, multiline: true, placeholder: getPlaceholder(), ref: chatInputRef, sx: {
693
695
  border: "var(--bs-border-style) var(--bs-border-width) var(--bs-gray-light)",
694
696
  borderRadius: "var(--bs-border-radius)",
695
697
  display: "flex",
@@ -701,6 +703,9 @@ export const ChatCommon = ({ ref, ...props }) => {
701
703
  paddingLeft: "1rem",
702
704
  paddingRight: "1rem",
703
705
  transition: "margin-right 0.2s",
706
+ "& textarea": {
707
+ overflowY: "auto",
708
+ },
704
709
  }, onChange: (event) => {
705
710
  setChatInput(event.target.value);
706
711
  }, onKeyDown: async (event) => {
@@ -21,8 +21,7 @@ import { alpha, styled, useTheme } from "@mui/material/styles";
21
21
  import { SnackbarContent, useSnackbar } from "notistack";
22
22
  // #region: Styled Components
23
23
  const IconBox = styled(Box)({
24
- position: "relative",
25
- bottom: "2px",
24
+ display: "flex",
26
25
  "&.success": {
27
26
  color: "var(--bs-success)",
28
27
  },
@@ -45,26 +44,27 @@ export const Snackbar = ({ ref, description, hideIconVariant = false, iconVarian
45
44
  const theme = useTheme();
46
45
  const shadowColor = theme.palette.mode === "dark" ? theme.palette.common.white : theme.palette.common.black;
47
46
  return (_jsx(SnackbarContent, { ref: ref, role: "alert", children: _jsxs(Box, { className: `${variant}-snackbar-notification`, id: `${id}-snackbar-box`, "data-testid": `${id}-snackbar-box`, sx: {
47
+ // A single line of text centers on the icon. With a description, the icon stays at the top.
48
+ alignItems: description ? "flex-start" : "center",
48
49
  background: theme.palette.background.paper,
49
50
  borderColor: "transparent",
50
51
  borderRadius: "var(--bs-border-radius)",
51
52
  borderWidth: "1px",
52
53
  boxShadow: `0 6px 16px 0 ${alpha(shadowColor, 0.08)}, 0 3px 6px -4px ${alpha(shadowColor, 0.12)},
53
54
  0 9px 28px 8px ${alpha(shadowColor, 0.05)}`,
55
+ display: "flex",
54
56
  maxWidth: "450px",
55
57
  minWidth: "250px",
56
58
  padding: "0.9rem",
57
- paddingRight: "4rem",
58
- }, children: [!hideIconVariant && (_jsx(Box, { id: `${id}-snackbar-icon-box-container`, sx: { display: "inline-flex", flexDirection: "column" }, children: _jsx(IconBox, { className: variant, "data-testid": `${id}-snackbar-icon-box`, id: `${id}-snackbar-icon-box`, children: icon }) })), _jsxs(Box, { id: `${id}-snackbar-content-box`, sx: {
59
- display: "inline-flex",
60
- flexDirection: "column",
61
- width: "88%",
62
- wordWrap: "break-word",
63
- }, children: [_jsx(Box, { id: `${id}-snackbar-message-box`, sx: {
64
- display: "block",
59
+ // Room for the close button
60
+ paddingRight: "2.5rem",
61
+ }, children: [!hideIconVariant && (_jsx(Box, { id: `${id}-snackbar-icon-box-container`,
62
+ // With a description, as tall as the title's first line so the icon centers on it
63
+ sx: description
64
+ ? { alignItems: "center", display: "flex", fontSize: "0.95rem", height: "1.5em" }
65
+ : {}, children: _jsx(IconBox, { className: variant, "data-testid": `${id}-snackbar-icon-box`, id: `${id}-snackbar-icon-box`, children: icon }) })), _jsxs(Box, { id: `${id}-snackbar-content-box`, sx: { flex: 1, minWidth: 0, wordWrap: "break-word" }, children: [_jsx(Box, { id: `${id}-snackbar-message-box`, sx: {
65
66
  // If no description, this is the only message, so reduce font size
66
67
  fontSize: description ? "0.95rem" : "0.85rem",
67
- paddingRight: "25px",
68
68
  }, children: message }), _jsx(IconButton, { "aria-label": "close", id: `${id}-close-icon-btn`, onClick: handleCloseSnackbar, sx: {
69
69
  position: "absolute",
70
70
  right: 4,
@@ -72,5 +72,5 @@ export const Snackbar = ({ ref, description, hideIconVariant = false, iconVarian
72
72
  }, children: _jsx(CloseIcon, { "data-testid": `${id}-close-icon`, id: `${id}-close-icon`, sx: {
73
73
  color: "var(--bs-gray-medium)",
74
74
  fontSize: "0.6em",
75
- } }) }), description && (_jsx(Box, { id: `${id}-snackbar-description-box`, sx: { fontSize: "0.8rem", paddingTop: "10px", paddingBottom: "10px" }, children: description }))] })] }) }));
75
+ } }) }), description && (_jsx(Box, { id: `${id}-snackbar-description-box`, sx: { fontSize: "0.8rem", paddingTop: "10px" }, children: description }))] })] }) }));
76
76
  };
@@ -32,11 +32,14 @@ import { AgentNode, NODE_HEIGHT, NODE_WIDTH } from "./AgentNode.js";
32
32
  import { BASE_RADIUS, DEFAULT_FRONTMAN_X_POS, DEFAULT_FRONTMAN_Y_POS, LEVEL_SPACING, } from "../const.js";
33
33
  import { addThoughtBubbleEdge, layoutLinear, layoutRadial } from "./GraphLayouts.js";
34
34
  import { PlasmaEdge } from "./PlasmaEdge.js";
35
+ import { useEnvironmentStore } from "../../../state/Environment.js";
36
+ import { usePublishServerUrl } from "../../../state/Publish.js";
35
37
  import { usePalette, useSettingsStore } from "../../../state/Settings.js";
36
38
  import { useTempNetworksStore } from "../../../state/TemporaryNetworks.js";
37
39
  import { getZIndex } from "../../../utils/zIndexLayers.js";
38
40
  import { AgentNodeEditor } from "../Editor/AgentNodeEditor.js";
39
41
  import { NetworkEditorDock } from "../Editor/NetworkEditorDock.js";
42
+ import { PublishButton } from "../Publish/PublishButton.js";
40
43
  import { isEditableAgent } from "../TemporaryNetworks.js";
41
44
  import { ThoughtBubbleEdge } from "../ThoughtBubbles/ThoughtBubbleEdge.js";
42
45
  import { ThoughtBubbleOverlay } from "../ThoughtBubbles/ThoughtBubbleOverlay.js";
@@ -66,6 +69,7 @@ export const AgentFlow = ({ agentCounts, agentIconSuggestions, agentsInNetwork,
66
69
  const { fitView } = useReactFlow();
67
70
  const flowWrapperRef = useRef(null);
68
71
  const fitViewFrameRef = useRef(null);
72
+ const enablePublishing = useEnvironmentStore((state) => state.enablePublishing);
69
73
  const scheduleFitView = useCallback(() => {
70
74
  if (fitViewFrameRef.current !== null) {
71
75
  window.cancelAnimationFrame(fitViewFrameRef.current);
@@ -136,6 +140,8 @@ export const AgentFlow = ({ agentCounts, agentIconSuggestions, agentsInNetwork,
136
140
  };
137
141
  // Read temporary networks to find agent_network_definition for the currently selected network.
138
142
  const tempNetworks = useTempNetworksStore((state) => state.tempNetworks);
143
+ const publishServerUrl = usePublishServerUrl();
144
+ const currentTempNetwork = useMemo(() => (networkId ? tempNetworks.find((n) => n.agentInfo.agent_name === networkId) : undefined), [networkId, tempNetworks]);
139
145
  // Track conversation IDs we've already processed to prevent re-adding after expiry
140
146
  const processedConversationIdsRef = useRef(new Set());
141
147
  // Track which bubble is currently being hovered
@@ -304,9 +310,6 @@ export const AgentFlow = ({ agentCounts, agentIconSuggestions, agentsInNetwork,
304
310
  if (!isEditableAgent(node.data.displayAs))
305
311
  return;
306
312
  // Find the agent's existing instructions and description from the temp network definition.
307
- const currentTempNetwork = networkId
308
- ? tempNetworks.find((n) => n.agentInfo.agent_name === networkId)
309
- : undefined;
310
313
  const currentAgentDefinition = currentTempNetwork?.agentNetworkDefinition?.find((e) => e.origin === node.id);
311
314
  setSelectedAgent({
312
315
  agentId: node.id,
@@ -315,7 +318,7 @@ export const AgentFlow = ({ agentCounts, agentIconSuggestions, agentsInNetwork,
315
318
  initialDescription: currentAgentDefinition?.description ?? "",
316
319
  });
317
320
  setIsPopupOpen(true);
318
- }, [tempNetworks, isTemporaryNetwork, networkId]);
321
+ }, [currentTempNetwork, isTemporaryNetwork]);
319
322
  const handleNodeClick = useCallback((_event, node) => openNodeEditor(node), [openNodeEditor]);
320
323
  // ReactFlow makes nodes focusable and selects them on Enter, but it never fires onNodeClick from the keyboard.
321
324
  // Route Enter on a focused node to the editor so keyboard users can open a node the same way a click does.
@@ -448,6 +451,10 @@ export const AgentFlow = ({ agentCounts, agentIconSuggestions, agentsInNetwork,
448
451
  const getTitle = () => {
449
452
  if (!networkDisplayName)
450
453
  return null;
454
+ const isPublishingSetUp = enablePublishing && Boolean(publishServerUrl);
455
+ const isViewingNetwork = !isAgentNetworkDesignerMode && !isEditingNetwork;
456
+ const hoconToPublish = currentTempNetwork?.networkHocon;
457
+ const showPublishButton = isPublishingSetUp && isViewingNetwork && currentTempNetwork?.agentNetworkName && hoconToPublish;
451
458
  return (_jsxs(Box, { id: `${id}-network-title-bar`, sx: {
452
459
  alignItems: "center",
453
460
  display: "flex",
@@ -478,7 +485,7 @@ export const AgentFlow = ({ agentCounts, agentIconSuggestions, agentsInNetwork,
478
485
  }, children: networkDisplayName }) }), isTemporaryNetwork && !isEditingNetwork && !isAwaitingLlm && (_jsx(Button, { id: `${id}-enter-edit-mode-btn`, variant: "contained", size: "small", onClick: () => setIsEditingNetwork(true), startIcon: _jsx(EditIcon, {}), sx: {
479
486
  pointerEvents: "auto",
480
487
  "&:hover": { backgroundColor: theme.palette.primary.main },
481
- }, children: "Edit" }))] }));
488
+ }, children: "Edit" })), showPublishButton && (_jsx(Box, { sx: { pointerEvents: "auto" }, children: _jsx(PublishButton, { displayName: networkDisplayName, hocon: hoconToPublish, id: `${id}-publish-button`, networkId: currentTempNetwork.agentInfo.agent_name, networkName: currentTempNetwork.agentNetworkName }) }))] }));
482
489
  };
483
490
  return (_jsxs(Box, { id: `${id}-outer-box`, sx: {
484
491
  display: "flex",
@@ -0,0 +1,2 @@
1
+ export declare const STREAM_TIMEOUT_MS: number;
2
+ export declare const BANNER_AUTO_DISMISS_MS = 5000;
@@ -0,0 +1,5 @@
1
+ // Timeout in milliseconds for the network designer streaming response.
2
+ export const STREAM_TIMEOUT_MS = 3 * 60 * 1000;
3
+ // How long the dock's status banner stays visible before auto-dismissing. Error banners persist until dismissed.
4
+ // Exported for tests.
5
+ export const BANNER_AUTO_DISMISS_MS = 5_000;
@@ -1,6 +1,5 @@
1
1
  import { FC } from "react";
2
2
  import { TemporaryNetwork } from "../../../state/TemporaryNetworks.js";
3
- export declare const BANNER_AUTO_DISMISS_MS = 5000;
4
3
  export type NetworkEditorDockProps = {
5
4
  readonly currentUser: string;
6
5
  readonly id: string;
@@ -19,12 +19,9 @@ import { chatMessageFromChunk } from "../../AgentChat/Common/Utils.js";
19
19
  import { MUIAlert } from "../../Common/MUIAlert.js";
20
20
  import { AGENT_NETWORK_DEFINITION_KEY, AGENT_NETWORK_DESIGNER_ID, AGENT_NETWORK_NAME_KEY, } from "../const.js";
21
21
  import { convertReservationsToNetworks, extractNetworkHocon, extractReservations, mergeNetworks, } from "../TemporaryNetworks.js";
22
+ import { BANNER_AUTO_DISMISS_MS, STREAM_TIMEOUT_MS } from "./Const.js";
22
23
  //#region Constants
23
24
  const PROMPT_PLACEHOLDER = "Describe a change to the network";
24
- const STREAM_TIMEOUT_MS = 120_000;
25
- // How long the dock's status banner stays visible before auto-dismissing. Error banners persist until dismissed.
26
- // Exported for tests.
27
- export const BANNER_AUTO_DISMISS_MS = 5_000;
28
25
  //#endregion Interfaces and Types
29
26
  /**
30
27
  * Implements the dock that appears at the bottom of the screen when the user is editing a network. Allows user to
@@ -236,7 +233,8 @@ export const NetworkEditorDock = ({ neuroSanURL, currentUser, id, isEditingNetwo
236
233
  py: 2.5,
237
234
  borderRadius: 2,
238
235
  maxWidth: 480,
239
- }, children: [_jsx(CircularProgress, { size: 24 }), _jsxs(Box, { sx: { flex: 1 }, children: [_jsx(Typography, { variant: "body1", sx: { fontWeight: "bold" }, children: "Applying changes to network" }), dockPrompt && (_jsx(Typography, { variant: "body2", color: "text.secondary", sx: { mt: 0.25 }, children: dockPrompt }))] }), _jsx(Button, { variant: "outlined", size: "small", startIcon: _jsx("span", { style: { fontSize: "0.65rem" }, children: "\u25A0" }), onClick: handleStopClick, sx: {
236
+ width: "calc(100% - 32px)",
237
+ }, children: [_jsx(CircularProgress, { size: 24 }), _jsxs(Box, { sx: { flex: 1, minWidth: 0 }, children: [_jsx(Typography, { variant: "body1", sx: { fontWeight: "bold" }, children: "Applying changes to network" }), dockPrompt && (_jsx(Typography, { variant: "body2", color: "text.secondary", sx: { mt: 0.25, overflowWrap: "anywhere" }, children: dockPrompt }))] }), _jsx(Button, { variant: "outlined", size: "small", startIcon: _jsx("span", { style: { fontSize: "0.65rem" }, children: "\u25A0" }), onClick: handleStopClick, sx: {
240
238
  whiteSpace: "nowrap",
241
239
  flexShrink: 0,
242
240
  color: theme.palette.common.white,
@@ -0,0 +1,36 @@
1
+ import { Published } from "../../../state/Publish.js";
2
+ export declare const PUBLISH_SETTINGS_REQUIRED_MESSAGE = "Add a publish server and org name in Settings > External Services to publish";
3
+ export declare const PUBLISHED_MESSAGE = "Published and opened in a new tab";
4
+ export declare const PUBLISHED_TAB_BLOCKED_MESSAGE = "Published. Click View live to open it.";
5
+ /** Where networks are published, from Settings */
6
+ export interface PublishTarget {
7
+ readonly serverUrl: string;
8
+ readonly orgName: string;
9
+ }
10
+ export interface PublishNetwork {
11
+ /** The network's id in the app, which the publish store is keyed by */
12
+ readonly id: string;
13
+ /** The agent network name, which it's published under */
14
+ readonly name: string;
15
+ }
16
+ /**
17
+ * Opens a URL in a new tab, cut off from this page.
18
+ * @returns Whether the tab opened. False when the browser blocked it as a popup.
19
+ * @note Sets `opener` by hand because the "noopener" feature makes window.open always return null, which would hide
20
+ * whether the tab opened.
21
+ */
22
+ export declare const openInNewTab: (url: string) => boolean;
23
+ /**
24
+ * Asks the server whether the network is already live, for example after a reload, and remembers it if so. Does
25
+ * nothing if we already know the network's publish state.
26
+ */
27
+ export declare const checkIfPublished: (network: PublishNetwork, { serverUrl, orgName }: PublishTarget) => Promise<void>;
28
+ /**
29
+ * Publishes the network's HOCON, the same file Download gives, waits for it to go live, then opens it in a new tab.
30
+ * Tells the user how it went either way.
31
+ */
32
+ export declare const publish: (network: PublishNetwork, hocon: string, { serverUrl, orgName }: PublishTarget) => Promise<void>;
33
+ /**
34
+ * Takes a live network offline, on the server it was published to.
35
+ */
36
+ export declare const unpublish: (network: PublishNetwork, published: Published) => Promise<void>;
@@ -0,0 +1,99 @@
1
+ /*
2
+ Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+ import { listPublishedNetworks, publishNetwork, unpublishNetwork } from "../../../controller/publish/Publish.js";
17
+ import { PublishStatus, usePublishStore } from "../../../state/Publish.js";
18
+ import { NotificationType, sendNotification } from "../../Common/notification.js";
19
+ export const PUBLISH_SETTINGS_REQUIRED_MESSAGE = "Add a publish server and org name in Settings > External Services to publish";
20
+ export const PUBLISHED_MESSAGE = "Published and opened in a new tab";
21
+ export const PUBLISHED_TAB_BLOCKED_MESSAGE = "Published. Click View live to open it.";
22
+ /**
23
+ * Opens a URL in a new tab, cut off from this page.
24
+ * @returns Whether the tab opened. False when the browser blocked it as a popup.
25
+ * @note Sets `opener` by hand because the "noopener" feature makes window.open always return null, which would hide
26
+ * whether the tab opened.
27
+ */
28
+ export const openInNewTab = (url) => {
29
+ const tab = window.open(url, "_blank");
30
+ if (!tab)
31
+ return false;
32
+ tab.opener = null;
33
+ return true;
34
+ };
35
+ /**
36
+ * Asks the server whether the network is already live, for example after a reload, and remembers it if so. Does
37
+ * nothing if we already know the network's publish state.
38
+ */
39
+ export const checkIfPublished = async (network, { serverUrl, orgName }) => {
40
+ const { networks, publishedList, setPublishedList } = usePublishStore.getState();
41
+ if (networks[network.id])
42
+ return;
43
+ // Every network on screen asks, so they share one request for the org's list
44
+ const key = `${serverUrl} ${orgName}`;
45
+ let request = publishedList?.key === key ? publishedList.request : null;
46
+ if (!request) {
47
+ request = listPublishedNetworks(serverUrl, orgName);
48
+ setPublishedList({ key, request });
49
+ }
50
+ try {
51
+ const published = (await request).find((candidate) => candidate.name === network.name);
52
+ // Don't overwrite a publish the user started while we were asking
53
+ if (!published || usePublishStore.getState().networks[network.id])
54
+ return;
55
+ usePublishStore.getState().setPublishState(network.id, {
56
+ status: PublishStatus.Published,
57
+ serverUrl,
58
+ publishId: published.id,
59
+ url: published.url,
60
+ });
61
+ }
62
+ catch (e) {
63
+ setPublishedList(null);
64
+ console.warn(`Unable to check whether "${network.name}" is published:`, e);
65
+ }
66
+ };
67
+ /**
68
+ * Publishes the network's HOCON, the same file Download gives, waits for it to go live, then opens it in a new tab.
69
+ * Tells the user how it went either way.
70
+ */
71
+ export const publish = async (network, hocon, { serverUrl, orgName }) => {
72
+ const { clearPublishState, setPublishState } = usePublishStore.getState();
73
+ setPublishState(network.id, { status: PublishStatus.Publishing });
74
+ try {
75
+ const ready = await publishNetwork({ serverUrl, orgName, networkName: network.name, hocon });
76
+ setPublishState(network.id, { status: PublishStatus.Published, serverUrl, publishId: ready.id, url: ready.url });
77
+ const message = openInNewTab(ready.url) ? PUBLISHED_MESSAGE : PUBLISHED_TAB_BLOCKED_MESSAGE;
78
+ sendNotification(NotificationType.success, message, "", { vertical: "bottom", horizontal: "center" });
79
+ }
80
+ catch (e) {
81
+ clearPublishState(network.id);
82
+ sendNotification(NotificationType.error, `Failed to publish "${network.name}".`, String(e));
83
+ }
84
+ };
85
+ /**
86
+ * Takes a live network offline, on the server it was published to.
87
+ */
88
+ export const unpublish = async (network, published) => {
89
+ try {
90
+ await unpublishNetwork(published.serverUrl, published.publishId);
91
+ // The shared list still has it as live, so drop the list too
92
+ const { clearPublishState, setPublishedList } = usePublishStore.getState();
93
+ clearPublishState(network.id);
94
+ setPublishedList(null);
95
+ }
96
+ catch (e) {
97
+ sendNotification(NotificationType.error, `Failed to unpublish "${network.name}".`, String(e));
98
+ }
99
+ };
@@ -0,0 +1,16 @@
1
+ import { FC } from "react";
2
+ export declare const SHOW_DETAILS_LABEL = "Show publish details";
3
+ interface PublishButtonProps {
4
+ /** The network's name as people read it, for the confirmation */
5
+ readonly displayName: string;
6
+ readonly hocon: string;
7
+ readonly id: string;
8
+ readonly networkId: string;
9
+ readonly networkName: string;
10
+ }
11
+ /**
12
+ * Split button for publishing a network: "Publish", then "Publishing..." while it goes live, then "View live". The
13
+ * dropdown opens a panel with the progress, or the live URL and Unpublish.
14
+ */
15
+ export declare const PublishButton: FC<PublishButtonProps>;
16
+ export {};
@@ -0,0 +1,98 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /*
3
+ Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+ import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
18
+ import OpenInNewIcon from "@mui/icons-material/OpenInNew";
19
+ import PublicIcon from "@mui/icons-material/Public";
20
+ import Button from "@mui/material/Button";
21
+ import ButtonGroup from "@mui/material/ButtonGroup";
22
+ import CircularProgress from "@mui/material/CircularProgress";
23
+ import Popover from "@mui/material/Popover";
24
+ import Tooltip from "@mui/material/Tooltip";
25
+ import { useState } from "react";
26
+ import { openInNewTab, publish, PUBLISH_SETTINGS_REQUIRED_MESSAGE, unpublish, } from "./Publish.js";
27
+ import { PublishConfirmation } from "./PublishConfirmation.js";
28
+ import { PublishPanel } from "./PublishPanel.js";
29
+ import { usePublishTarget } from "./usePublishTarget.js";
30
+ import { PublishStatus, usePublishStore } from "../../../state/Publish.js";
31
+ import { ConfirmationModal } from "../../Common/ConfirmationModal.js";
32
+ export const SHOW_DETAILS_LABEL = "Show publish details";
33
+ /**
34
+ * Split button for publishing a network: "Publish", then "Publishing..." while it goes live, then "View live". The
35
+ * dropdown opens a panel with the progress, or the live URL and Unpublish.
36
+ */
37
+ export const PublishButton = ({ displayName, hocon, id, networkId, networkName }) => {
38
+ const publishState = usePublishStore((state) => state.networks[networkId]);
39
+ const target = usePublishTarget(networkId, networkName);
40
+ const [anchorEl, setAnchorEl] = useState(null);
41
+ const [isPublishConfirmOpen, setIsPublishConfirmOpen] = useState(false);
42
+ const [isPanelOpen, setIsPanelOpen] = useState(false);
43
+ const [isUnpublishing, setIsUnpublishing] = useState(false);
44
+ // The live network waiting on the user to confirm unpublishing it
45
+ const [networkToUnpublish, setNetworkToUnpublish] = useState(null);
46
+ const network = { id: networkId, name: networkName };
47
+ const handlePublish = async (publishTarget) => {
48
+ setIsPanelOpen(true);
49
+ await publish(network, hocon, publishTarget);
50
+ setIsPanelOpen(false);
51
+ };
52
+ const handleUnpublish = async (published) => {
53
+ setIsUnpublishing(true);
54
+ await unpublish(network, published);
55
+ setIsUnpublishing(false);
56
+ setIsPanelOpen(false);
57
+ };
58
+ const getMainAction = () => {
59
+ switch (publishState?.status) {
60
+ case PublishStatus.Publishing:
61
+ return {
62
+ color: "primary",
63
+ icon: (_jsx(CircularProgress, { color: "inherit", size: "1rem" })),
64
+ label: "Publishing...",
65
+ handleClick: () => setIsPanelOpen(true),
66
+ };
67
+ case PublishStatus.Published:
68
+ return {
69
+ color: "success",
70
+ icon: _jsx(OpenInNewIcon, {}),
71
+ label: "View live",
72
+ handleClick: () => openInNewTab(publishState.url),
73
+ };
74
+ default:
75
+ return {
76
+ color: "primary",
77
+ icon: _jsx(PublicIcon, {}),
78
+ label: "Publish",
79
+ handleClick: () => setIsPublishConfirmOpen(true),
80
+ };
81
+ }
82
+ };
83
+ const mainAction = getMainAction();
84
+ const isPublishBlocked = !publishState && !target;
85
+ return (_jsxs(_Fragment, { children: [_jsxs(ButtonGroup, { color: mainAction.color, id: id, ref: setAnchorEl, size: "small",
86
+ // White text on green (the theme's contrast text is dark there), and icons that follow the text color
87
+ sx: {
88
+ "& .MuiButton-root:not(.Mui-disabled)": { color: "common.white" },
89
+ "& .MuiSvgIcon-root": { color: "inherit" },
90
+ }, variant: "contained", children: [_jsx(Tooltip, { title: isPublishBlocked ? PUBLISH_SETTINGS_REQUIRED_MESSAGE : "", children: _jsx("span", { children: _jsx(Button, { disabled: isPublishBlocked, id: `${id}-main`, onClick: mainAction.handleClick, startIcon: mainAction.icon, sx: { whiteSpace: "nowrap" }, children: mainAction.label }) }) }), publishState && (_jsx(Button, { "aria-expanded": isPanelOpen, "aria-label": SHOW_DETAILS_LABEL, id: `${id}-toggle`, onClick: () => setIsPanelOpen((isOpen) => !isOpen), children: _jsx(KeyboardArrowDownIcon, { sx: { fontSize: 18 } }) }))] }), publishState && (_jsx(Popover, { anchorEl: anchorEl, anchorOrigin: { vertical: "bottom", horizontal: "right" }, onClose: () => setIsPanelOpen(false), open: isPanelOpen, slotProps: { paper: { sx: { mt: 1 } } }, transformOrigin: { vertical: "top", horizontal: "right" }, children: _jsx(PublishPanel, { publishState: publishState, id: `${id}-panel`, isUnpublishing: isUnpublishing, onUnpublish: setNetworkToUnpublish }) })), isPublishConfirmOpen && target && (_jsx(PublishConfirmation, { displayName: displayName, id: `${id}-confirm`, onCancel: () => setIsPublishConfirmOpen(false), onConfirm: () => {
91
+ setIsPublishConfirmOpen(false);
92
+ void handlePublish(target);
93
+ }, target: target })), networkToUnpublish && (_jsx(ConfirmationModal, { content: `"${displayName}" will be taken offline at ${networkToUnpublish.url}. ` +
94
+ "Anyone using the link will lose access.", handleCancel: () => setNetworkToUnpublish(null), handleOk: () => {
95
+ setNetworkToUnpublish(null);
96
+ void handleUnpublish(networkToUnpublish);
97
+ }, id: `${id}-unpublish-confirm`, okBtnLabel: "Unpublish", title: "Unpublish this network?" }))] }));
98
+ };
@@ -0,0 +1,15 @@
1
+ import { FC } from "react";
2
+ import { PublishTarget } from "./Publish.js";
3
+ export declare const PUBLIC_ACCESS_WARNING = "Anyone with the link can see and use it. There's no sign-in or access control.";
4
+ interface PublishConfirmationProps {
5
+ readonly displayName: string;
6
+ readonly id: string;
7
+ readonly onCancel: () => void;
8
+ readonly onConfirm: () => void;
9
+ readonly target: PublishTarget;
10
+ }
11
+ /**
12
+ * Asks before publishing, naming where it goes and warning that it'll be public.
13
+ */
14
+ export declare const PublishConfirmation: FC<PublishConfirmationProps>;
15
+ export {};
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ConfirmationModal } from "../../Common/ConfirmationModal.js";
3
+ export const PUBLIC_ACCESS_WARNING = "Anyone with the link can see and use it. There's no sign-in or access control.";
4
+ /**
5
+ * Asks before publishing, naming where it goes and warning that it'll be public.
6
+ */
7
+ export const PublishConfirmation = ({ displayName, id, onCancel, onConfirm, target }) => (_jsx(ConfirmationModal, { content: `"${displayName}" will be published to ${target.serverUrl} ` +
8
+ `under the org "${target.orgName}". ${PUBLIC_ACCESS_WARNING}`, handleCancel: onCancel, handleOk: onConfirm, id: id, okBtnLabel: "Publish", title: "Publish this network?" }));
@@ -0,0 +1,17 @@
1
+ import { FC } from "react";
2
+ interface PublishIconButtonProps {
3
+ /** The network's name as people read it, for the confirmation */
4
+ readonly displayName: string;
5
+ readonly hocon: string;
6
+ readonly id: string;
7
+ /** An expired network can't be published, but its live site still opens */
8
+ readonly isExpired: boolean;
9
+ readonly networkId: string;
10
+ readonly networkName: string;
11
+ }
12
+ /**
13
+ * Small globe button for publishing a network from the sidebar. Publishes after asking, spins while publishing, and
14
+ * turns green once the network is live, when it opens the live site instead.
15
+ */
16
+ export declare const PublishIconButton: FC<PublishIconButtonProps>;
17
+ export {};
@@ -0,0 +1,72 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+ import PublicIcon from "@mui/icons-material/Public";
18
+ import Box from "@mui/material/Box";
19
+ import CircularProgress from "@mui/material/CircularProgress";
20
+ import IconButton from "@mui/material/IconButton";
21
+ import Tooltip from "@mui/material/Tooltip";
22
+ import { useState } from "react";
23
+ import { openInNewTab, publish, PUBLISH_SETTINGS_REQUIRED_MESSAGE } from "./Publish.js";
24
+ import { PublishConfirmation } from "./PublishConfirmation.js";
25
+ import { usePublishTarget } from "./usePublishTarget.js";
26
+ import { PublishStatus, usePublishStore } from "../../../state/Publish.js";
27
+ /**
28
+ * Small globe button for publishing a network from the sidebar. Publishes after asking, spins while publishing, and
29
+ * turns green once the network is live, when it opens the live site instead.
30
+ */
31
+ export const PublishIconButton = ({ displayName, hocon, id, isExpired, networkId, networkName, }) => {
32
+ const publishStatus = usePublishStore((state) => state.networks[networkId]?.status);
33
+ const publishedUrl = usePublishStore((state) => {
34
+ const publishState = state.networks[networkId];
35
+ return publishState?.status === PublishStatus.Published ? publishState.url : null;
36
+ });
37
+ const target = usePublishTarget(networkId, networkName);
38
+ const [isConfirmOpen, setIsConfirmOpen] = useState(false);
39
+ const getLabel = () => {
40
+ if (publishedUrl)
41
+ return "View live";
42
+ if (publishStatus === PublishStatus.Publishing)
43
+ return "Publishing...";
44
+ if (isExpired)
45
+ return "Expired";
46
+ return target ? "Publish" : PUBLISH_SETTINGS_REQUIRED_MESSAGE;
47
+ };
48
+ const label = getLabel();
49
+ const isPublishing = publishStatus === PublishStatus.Publishing;
50
+ return (_jsxs(_Fragment, { children: [_jsx(Tooltip, { title: label, children: _jsx("span", { children: _jsx(IconButton, { "aria-label": label, disabled: isPublishing || (!publishedUrl && (isExpired || !target)), id: id, onClick: (e) => {
51
+ e.stopPropagation();
52
+ if (publishedUrl) {
53
+ openInNewTab(publishedUrl);
54
+ }
55
+ else {
56
+ setIsConfirmOpen(true);
57
+ }
58
+ }, size: "small", sx: {
59
+ color: "var(--bs-secondary)",
60
+ p: 0,
61
+ "&:hover": { color: "var(--bs-secondary-dark)" },
62
+ "&.Mui-disabled": { opacity: isPublishing ? 1 : 0.3 },
63
+ }, children: isPublishing ? (_jsx(CircularProgress, { size: "0.75rem", sx: { color: "var(--bs-secondary)" } })) : (
64
+ // Colored on the icon itself, since the app's global CSS colors icons inside buttons
65
+ _jsx(PublicIcon, { sx: { fontSize: "0.75rem", ...(publishedUrl && { color: "success.main" }) } })) }) }) }), isConfirmOpen && target && (
66
+ // The dialog is a portal, but its clicks still bubble up the React tree to the sidebar item, which
67
+ // would select the network
68
+ _jsx(Box, { component: "span", onClick: (e) => e.stopPropagation(), children: _jsx(PublishConfirmation, { displayName: displayName, id: `${id}-confirm`, onCancel: () => setIsConfirmOpen(false), onConfirm: () => {
69
+ setIsConfirmOpen(false);
70
+ void publish({ id: networkId, name: networkName }, hocon, target);
71
+ }, target: target }) }))] }));
72
+ };
@@ -0,0 +1,13 @@
1
+ import { FC } from "react";
2
+ import { Published, PublishState } from "../../../state/Publish.js";
3
+ interface PublishPanelProps {
4
+ readonly publishState: PublishState;
5
+ readonly id: string;
6
+ readonly isUnpublishing: boolean;
7
+ readonly onUnpublish: (published: Published) => void;
8
+ }
9
+ /**
10
+ * Details of publishing a network: progress while publishing, or the live URL once published.
11
+ */
12
+ export declare const PublishPanel: FC<PublishPanelProps>;
13
+ export {};
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /*
3
+ Copyright 2026 Cognizant Technology Solutions Corp, www.cognizant.com.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ */
17
+ import Box from "@mui/material/Box";
18
+ import Button from "@mui/material/Button";
19
+ import Divider from "@mui/material/Divider";
20
+ import LinearProgress from "@mui/material/LinearProgress";
21
+ import Typography from "@mui/material/Typography";
22
+ import { PublishedNetworkUrl } from "./PublishedNetworkUrl.js";
23
+ import { PublishStatus } from "../../../state/Publish.js";
24
+ import { StatusLight } from "../../Common/StatusLight.js";
25
+ /**
26
+ * Details of publishing a network: progress while publishing, or the live URL once published.
27
+ */
28
+ export const PublishPanel = ({ id, isUnpublishing, onUnpublish, publishState }) => (_jsx(Box, { id: id, sx: { display: "flex", flexDirection: "column", gap: 1.5, p: 2, width: "22rem" }, children: publishState.status === PublishStatus.Published ? (_jsxs(_Fragment, { children: [_jsxs(Box, { sx: { alignItems: "center", display: "flex", gap: 1 }, children: [_jsx(StatusLight, { statusValue: "green" }), _jsx(Typography, { sx: { fontWeight: 600 }, children: "Live" })] }), _jsx(PublishedNetworkUrl, { url: publishState.url }), _jsx(Divider, {}), _jsx(Button, { disabled: isUnpublishing, onClick: () => onUnpublish(publishState), size: "small", sx: { alignSelf: "flex-start", color: "error.light", minWidth: 0, p: 0, textTransform: "none" }, children: isUnpublishing ? "Unpublishing..." : "Unpublish" })] })) : (_jsxs(_Fragment, { children: [_jsx(Typography, { sx: { fontWeight: 600 }, children: "Putting it online..." }), _jsx(LinearProgress, { "aria-label": "Publishing progress", sx: { "& .MuiLinearProgress-bar": { backgroundColor: "var(--bs-secondary)" } } }), _jsx(Typography, { color: "text.secondary", variant: "body2", children: "This can take a minute." })] })) }));
@@ -0,0 +1,11 @@
1
+ import { FC } from "react";
2
+ export declare const COPY_URL_LABEL = "Copy live URL";
3
+ export declare const OPEN_URL_LABEL = "Open live URL";
4
+ interface PublishedNetworkUrlProps {
5
+ readonly url: string;
6
+ }
7
+ /**
8
+ * Read-only display of a published network's URL, with icons to copy it or open it in a new tab.
9
+ */
10
+ export declare const PublishedNetworkUrl: FC<PublishedNetworkUrlProps>;
11
+ export {};