@e-llm-studio/instant-learning 1.3.6 → 1.3.8

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/ILMarketplaceWrapper.js +16 -11
  2. package/dist/ILMarketplaceWrapper.js.map +1 -1
  3. package/dist/cjs/ILMarketplaceWrapper.js +16 -11
  4. package/dist/cjs/ILMarketplaceWrapper.js.map +1 -1
  5. package/dist/cjs/features/IL-OTJ/ILOTJ.js +1 -1
  6. package/dist/cjs/features/IL-OTJ/ILOTJ.js.map +1 -1
  7. package/dist/cjs/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.js +220 -0
  8. package/dist/cjs/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.js.map +1 -0
  9. package/dist/cjs/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.module.css.js +12 -0
  10. package/dist/cjs/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.module.css.js.map +1 -0
  11. package/dist/cjs/features/IL-marketplace/PromoteFlow/PromoteFlow.js +188 -178
  12. package/dist/cjs/features/IL-marketplace/PromoteFlow/PromoteFlow.js.map +1 -1
  13. package/dist/cjs/features/IL-marketplace/PromoteFlow/PromoteFlow.module.css.js +2 -2
  14. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-constants.js +69 -0
  15. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-constants.js.map +1 -0
  16. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.api.js +62 -1
  17. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.api.js.map +1 -1
  18. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.utils.js +23 -7
  19. package/dist/cjs/features/IL-marketplace/PromoteFlow/promote-flow.utils.js.map +1 -1
  20. package/dist/cjs/features/IL-marketplace/components/ILMarketPlacePublish/PublishToMarketplaceCompnent.js +7 -4
  21. package/dist/cjs/features/IL-marketplace/components/ILMarketPlacePublish/PublishToMarketplaceCompnent.js.map +1 -1
  22. package/dist/cjs/features/LearningManagement/LearningManagement.js +1 -4
  23. package/dist/cjs/features/LearningManagement/LearningManagement.js.map +1 -1
  24. package/dist/features/IL-OTJ/ILOTJ.js +1 -1
  25. package/dist/features/IL-OTJ/ILOTJ.js.map +1 -1
  26. package/dist/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.js +216 -0
  27. package/dist/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.js.map +1 -0
  28. package/dist/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.module.css.js +8 -0
  29. package/dist/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.module.css.js.map +1 -0
  30. package/dist/features/IL-marketplace/PromoteFlow/PromoteFlow.js +186 -172
  31. package/dist/features/IL-marketplace/PromoteFlow/PromoteFlow.js.map +1 -1
  32. package/dist/features/IL-marketplace/PromoteFlow/PromoteFlow.module.css.js +2 -2
  33. package/dist/features/IL-marketplace/PromoteFlow/promote-constants.js +51 -0
  34. package/dist/features/IL-marketplace/PromoteFlow/promote-constants.js.map +1 -0
  35. package/dist/features/IL-marketplace/PromoteFlow/promote-flow.api.js +60 -2
  36. package/dist/features/IL-marketplace/PromoteFlow/promote-flow.api.js.map +1 -1
  37. package/dist/features/IL-marketplace/PromoteFlow/promote-flow.utils.js +23 -8
  38. package/dist/features/IL-marketplace/PromoteFlow/promote-flow.utils.js.map +1 -1
  39. package/dist/features/IL-marketplace/components/ILMarketPlacePublish/PublishToMarketplaceCompnent.js +7 -4
  40. package/dist/features/IL-marketplace/components/ILMarketPlacePublish/PublishToMarketplaceCompnent.js.map +1 -1
  41. package/dist/features/LearningManagement/LearningManagement.js +1 -4
  42. package/dist/features/LearningManagement/LearningManagement.js.map +1 -1
  43. package/dist/types/src/ILMarketplaceWrapper.d.ts +2 -2
  44. package/dist/types/src/ILMarketplaceWrapper.d.ts.map +1 -1
  45. package/dist/types/src/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.d.ts +9 -0
  46. package/dist/types/src/features/IL-marketplace/PromoteFlow/PreflightDetailsPage.d.ts.map +1 -0
  47. package/dist/types/src/features/IL-marketplace/PromoteFlow/PromoteFlow.d.ts.map +1 -1
  48. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-constants.d.ts +23 -0
  49. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-constants.d.ts.map +1 -0
  50. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.api.d.ts +4 -1
  51. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.api.d.ts.map +1 -1
  52. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.interfaces.d.ts +56 -2
  53. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.interfaces.d.ts.map +1 -1
  54. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.utils.d.ts +3 -2
  55. package/dist/types/src/features/IL-marketplace/PromoteFlow/promote-flow.utils.d.ts.map +1 -1
  56. package/dist/types/src/features/IL-marketplace/components/ILMarketPlacePublish/PublishToMarketplaceCompnent.d.ts.map +1 -1
  57. package/dist/types/src/features/LearningManagement/LearningManagement.d.ts.map +1 -1
  58. package/package.json +5 -5
@@ -1,60 +1,46 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useState, useMemo, useEffect } from 'react';
3
- import Tooltip, { tooltipClasses } from '@mui/material/Tooltip';
4
- import { styled } from '@mui/material/styles';
5
3
  import { ArrowLeft, CircleCheck, Info, ArrowUpRight, ArrowDownUp, Calendar, LoaderCircle, Bell, Copy, ExternalLink, ChevronDown, Settings2 } from 'lucide-react';
6
4
  import { getGuidelineTitle, cx } from '../utils.js';
7
5
  import { EnvironmentConfigurationModal } from './EnvironmentConfigurationModal.js';
8
- import { getSchemaPreview, searchEnvironmentConfigs, getCWUser, getPromotionStatus, getPromotionHistory, startPromotion, checkPromotionPreflight, createEnvironmentConfig, schedulePromotion, triggerScheduledPromotion, rollbackPromotion } from './promote-flow.api.js';
6
+ import { PreflightDetailsPage } from './PreflightDetailsPage.js';
7
+ import { DEFAULT_GUIDELINE_STATUS, DEFAULT_SOURCE_ENVIRONMENT_TIER, PERMITTED_SOURCE_TIERS, PROMOTION_IN_PROGRESS_STATUSES, ENVIRONMENT_CONFIGURATION_TOOLTIP, PROMOTION_POLL_INTERVAL_MS, StyledPromoteTooltip, PREFLIGHT_TOOLTIP, ACCORDIONS, PROMOTION_IN_PROGRESS_TOOLTIP, SCHEDULED_PROMOTION_TOOLTIP } from './promote-constants.js';
8
+ import { getSchemaPreview, searchEnvironmentConfigs, getCWUser, getPromotionStatus, getPromotionHistory, startPromotion, checkPromotionPreflight, addAlloyDbCredential, createEnvironmentConfig, schedulePromotion, triggerScheduledPromotion, getPromotionTaskDetails, rollbackPromotion } from './promote-flow.api.js';
9
9
  import { usePromoteFlowStore } from './promote-flow.store.js';
10
- import { getPromotionResourceId, getEnvironmentDisplayName, getPermittedDestinationTiers, getLatestPromotionForEnvironmentPair, formatPromotionDate, EMPTY_ENVIRONMENT_CONFIGURATION, toCreateEnvironmentConfigRequest, toRegistryRecord } from './promote-flow.utils.js';
10
+ import { getPromotionResourceId, getEnvironmentDisplayName, getPermittedDestinationTiers, EMPTY_ENVIRONMENT_CONFIGURATION, getLatestPromotionForEnvironmentPair, formatPromotionDate, toAddAlloyDbCredentialRequest, toCreateEnvironmentConfigRequest, toRegistryRecord } from './promote-flow.utils.js';
11
11
  import cssStyles from './PromoteFlow.module.css.js';
12
12
 
13
- const StyledPromoteTooltip = styled(({ className, ...props }) => /* @__PURE__ */ jsx(Tooltip, { ...props, classes: { popper: className } }))(() => ({
14
- [`& .${tooltipClasses.tooltip}`]: {
15
- backgroundColor: "#161616cf",
16
- color: "#ffffff",
17
- fontSize: "12px",
18
- padding: "7px 11px",
19
- borderRadius: 6,
20
- maxWidth: 250,
21
- textAlign: "center",
22
- whiteSpace: "normal",
23
- wordBreak: "break-word",
24
- lineHeight: 1.5
25
- },
26
- [`& .${tooltipClasses.arrow}`]: {
27
- color: "#000000"
28
- }
29
- }));
30
- const ACCORDIONS = [
31
- {
32
- id: "overview",
33
- title: "Overview"
34
- },
35
- {
36
- id: "history",
37
- title: "Promotion History",
38
- comingSoon: false
39
- },
40
- {
41
- id: "database",
42
- title: "Database Details",
43
- comingSoon: false
44
- }
45
- // {
46
- // id: 'knowledgebase',
47
- // title: 'Knowledgebase Details',
48
- // comingSoon: true,
49
- // },
50
- ];
13
+ const isTenantEnvironment = (environment) => environment === "tenantSource" || environment === "tenantDestination";
14
+ const isSourceEnvironment = (environment) => environment === "source" || environment === "tenantSource";
15
+ const getLatestPromotion = (history) => history.reduce((latest, entry) => {
16
+ if (!latest) return entry;
17
+ return Date.parse(entry.updated_at) > Date.parse(latest.updated_at) ? entry : latest;
18
+ }, null);
19
+ const getDefaultEnvironmentTier = (environment, selectedEnvironment, permittedDestinationTiers) => {
20
+ var _a;
21
+ return (_a = selectedEnvironment == null ? void 0 : selectedEnvironment.env_tier) != null ? _a : isSourceEnvironment(environment) ? DEFAULT_SOURCE_ENVIRONMENT_TIER : permittedDestinationTiers[0];
22
+ };
23
+ const getPromotionActionRestriction = (isPromotionInProgress, hasScheduledPromotion) => {
24
+ if (isPromotionInProgress) return PROMOTION_IN_PROGRESS_TOOLTIP;
25
+ if (hasScheduledPromotion) return SCHEDULED_PROMOTION_TOOLTIP;
26
+ return null;
27
+ };
28
+ const getHistoryActionLabel = (isPending, canRollback) => {
29
+ if (!isPending) return canRollback ? "Rollback" : "View details";
30
+ return canRollback ? "Rolling back\u2026" : "Loading\u2026";
31
+ };
32
+ const getPreflightResultMessage = ({
33
+ ready,
34
+ items_ready,
35
+ items_checked
36
+ }) => ready ? `Migration is ready (${items_ready}/${items_checked} checks passed).` : `Migration readiness requires attention (${items_ready}/${items_checked} checks passed).`;
51
37
  const isMissingPromotionStatus = (error) => {
52
38
  var _a;
53
39
  if (error instanceof Error && error.message.includes("404")) return true;
54
40
  return typeof error === "object" && error !== null && "response" in error && ((_a = error.response) == null ? void 0 : _a.status) === 404;
55
41
  };
56
42
  function PromoteFlow({ guideline, onBack, onPromote, className }) {
57
- var _a, _b, _c, _d, _e, _f, _g, _h;
43
+ var _a, _b, _c, _d;
58
44
  const [openSections, setOpenSections] = useState({
59
45
  overview: true
60
46
  });
@@ -72,9 +58,11 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
72
58
  const [configSearchTier, setConfigSearchTier] = useState(null);
73
59
  const [submittingAction, setSubmittingAction] = useState(null);
74
60
  const [historyActionTaskId, setHistoryActionTaskId] = useState(null);
61
+ const [viewedHistoryTaskId, setViewedHistoryTaskId] = useState(null);
75
62
  const [isStatusPollingStopped, setIsStatusPollingStopped] = useState(false);
76
63
  const [isInitialStatusLoading, setIsInitialStatusLoading] = useState(true);
77
64
  const [isCheckingPreflight, setIsCheckingPreflight] = useState(false);
65
+ const [isViewingPreflightDetails, setIsViewingPreflightDetails] = useState(false);
78
66
  const [promotionStatusForActions, setPromotionStatusForActions] = useState(null);
79
67
  const [preflightResult, setPreflightResult] = useState(null);
80
68
  const sourceEnvironment = usePromoteFlowStore((state) => state.sourceEnvironment);
@@ -95,7 +83,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
95
83
  const resetPromotionSession = usePromoteFlowStore((state) => state.resetPromotionSession);
96
84
  const title = getGuidelineTitle(guideline);
97
85
  const versionLabel = guideline.version ? `v${guideline.version}` : "v1";
98
- const statusLabel = (_a = guideline.status) != null ? _a : "Published";
86
+ const statusLabel = (_a = guideline.status) != null ? _a : DEFAULT_GUIDELINE_STATUS;
99
87
  const guidelineResourceId = getPromotionResourceId(guideline);
100
88
  const promotionTaskForGuideline = promotionResourceId === guidelineResourceId ? promotionTask : null;
101
89
  const errorForGuideline = errorResourceId === guidelineResourceId ? error : null;
@@ -111,13 +99,43 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
111
99
  );
112
100
  const isPromoting = Boolean(promotionTaskForGuideline);
113
101
  const canRetryPromotion = (promotionTaskForGuideline == null ? void 0 : promotionTaskForGuideline.status) === "FAILED";
114
- const sourceTier = (_b = sourceEnvironment == null ? void 0 : sourceEnvironment.env_tier) != null ? _b : "dev";
102
+ const sourceTier = (_b = sourceEnvironment == null ? void 0 : sourceEnvironment.env_tier) != null ? _b : DEFAULT_SOURCE_ENVIRONMENT_TIER;
115
103
  const permittedDestinationTiers = useMemo(
116
104
  () => getPermittedDestinationTiers(sourceTier),
117
105
  [sourceTier]
118
106
  );
119
- const permittedSourceTiers = ["dev", "qa", "prod", "external"];
120
- const selectedEnvironment = configuredEnvironment === "source" ? sourceEnvironment : configuredEnvironment === "destination" ? destinationEnvironment : configuredEnvironment === "tenantSource" ? tenantSourceEnvironment : tenantDestinationEnvironment;
107
+ const environments = {
108
+ source: sourceEnvironment,
109
+ destination: destinationEnvironment,
110
+ tenantSource: tenantSourceEnvironment,
111
+ tenantDestination: tenantDestinationEnvironment
112
+ };
113
+ const selectedEnvironment = configuredEnvironment ? environments[configuredEnvironment] : void 0;
114
+ const configuredEnvironmentDefaultTier = configuredEnvironment ? getDefaultEnvironmentTier(
115
+ configuredEnvironment,
116
+ selectedEnvironment,
117
+ permittedDestinationTiers
118
+ ) : DEFAULT_SOURCE_ENVIRONMENT_TIER;
119
+ const configuredEnvironmentIsSource = configuredEnvironment ? isSourceEnvironment(configuredEnvironment) : true;
120
+ const configuredEnvironmentIsTenant = configuredEnvironment ? isTenantEnvironment(configuredEnvironment) : false;
121
+ const modalInitialConfiguration = selectedEnvironment ? {
122
+ env_name: selectedEnvironment.env_name,
123
+ env_tier: selectedEnvironment.env_tier,
124
+ db_type: selectedEnvironment.db_type,
125
+ host: selectedEnvironment.host,
126
+ port: String(selectedEnvironment.port),
127
+ username: selectedEnvironment.username,
128
+ password: "",
129
+ database_name: selectedEnvironment.database_name,
130
+ is_tenant_db: selectedEnvironment.is_tenant_db
131
+ } : {
132
+ ...EMPTY_ENVIRONMENT_CONFIGURATION,
133
+ env_tier: configuredEnvironmentDefaultTier,
134
+ db_type: !configuredEnvironmentIsSource && configuredEnvironmentDefaultTier === "external" ? "EXTERNAL" : "INTERNAL",
135
+ is_tenant_db: configuredEnvironmentIsTenant
136
+ };
137
+ const modalPermittedTiers = configuredEnvironmentIsSource ? PERMITTED_SOURCE_TIERS : permittedDestinationTiers;
138
+ const modalPresetTier = configSearchTier != null ? configSearchTier : configuredEnvironmentDefaultTier;
121
139
  const latestPromotionForPair = useMemo(
122
140
  () => getLatestPromotionForEnvironmentPair(
123
141
  promotionHistory,
@@ -126,36 +144,36 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
126
144
  ),
127
145
  [destinationEnvironment, promotionHistory, sourceEnvironment]
128
146
  );
129
- const latestPromotionTaskId = useMemo(() => {
130
- var _a2;
131
- const latestPromotion2 = promotionHistory.reduce(
132
- (latest, entry) => {
133
- if (!latest) return entry;
134
- return Date.parse(entry.updated_at) > Date.parse(latest.updated_at) ? entry : latest;
135
- },
136
- null
137
- );
138
- return (_a2 = latestPromotion2 == null ? void 0 : latestPromotion2.promotion_task_id) != null ? _a2 : null;
139
- }, [promotionHistory]);
140
- const latestPromotion = useMemo(
141
- () => promotionHistory.reduce((latest, entry) => {
142
- if (!latest) return entry;
143
- return Date.parse(entry.updated_at) > Date.parse(latest.updated_at) ? entry : latest;
144
- }, null),
145
- [promotionHistory]
147
+ const latestPromotion = useMemo(() => getLatestPromotion(promotionHistory), [promotionHistory]);
148
+ const latestPromotionTaskId = (_c = latestPromotion == null ? void 0 : latestPromotion.promotion_task_id) != null ? _c : null;
149
+ const isPromotionInProgress = PROMOTION_IN_PROGRESS_STATUSES.some(
150
+ (status) => status === (promotionStatusForActions == null ? void 0 : promotionStatusForActions.status)
146
151
  );
147
- const isPromotionInProgress = ["MIGRATING", "ROLLBACK_IN_PROGRESS"].includes(
148
- (_c = promotionStatusForActions == null ? void 0 : promotionStatusForActions.status) != null ? _c : ""
152
+ const hasScheduledPromotion = (latestPromotion == null ? void 0 : latestPromotion.status) === "SCHEDULED" || (promotionStatusForActions == null ? void 0 : promotionStatusForActions.status) === "SCHEDULED";
153
+ const promotionActionRestriction = getPromotionActionRestriction(
154
+ isPromotionInProgress,
155
+ hasScheduledPromotion
149
156
  );
150
- const latestHistoryIsScheduled = (latestPromotion == null ? void 0 : latestPromotion.status) === "SCHEDULED" || (promotionStatusForActions == null ? void 0 : promotionStatusForActions.status) === "SCHEDULED";
151
- const promotionActionRestriction = isPromotionInProgress ? "A promotion is currently in progress. Wait for it to complete before taking another promotion action." : latestHistoryIsScheduled ? "The latest promotion is scheduled. You may schedule another promotion, but cannot check readiness or promote now." : null;
152
157
  const canCheckPromotionReadiness = canPromote && !promotionActionRestriction;
153
158
  const canPromoteNow = canPromote && !promotionActionRestriction;
154
159
  const canPromoteLater = canPromote && !isPromotionInProgress;
155
- const environmentConfigurationTooltip = "Configure both source and destination environments first.";
156
- const readinessAndNowTooltip = promotionActionRestriction != null ? promotionActionRestriction : environmentConfigurationTooltip;
157
- const promoteLaterTooltip = isPromotionInProgress ? promotionActionRestriction : environmentConfigurationTooltip;
160
+ const readinessAndNowTooltip = promotionActionRestriction != null ? promotionActionRestriction : ENVIRONMENT_CONFIGURATION_TOOLTIP;
161
+ const promoteLaterTooltip = isPromotionInProgress ? promotionActionRestriction : ENVIRONMENT_CONFIGURATION_TOOLTIP;
158
162
  const promoteActionLabel = (latestPromotionForPair == null ? void 0 : latestPromotionForPair.status) === "SUCCESS" ? "Sync" : "Promote Now";
163
+ const createPromotionRequest = () => {
164
+ if (!sourceEnvironment || !destinationEnvironment) return null;
165
+ return {
166
+ resource_id: guidelineResourceId,
167
+ resource_type: "PACKAGE",
168
+ target_version: "latest",
169
+ global_source_env_id: sourceEnvironment.env_id,
170
+ global_target_env_id: destinationEnvironment.env_id,
171
+ ...tenantSourceEnvironment && tenantDestinationEnvironment ? {
172
+ tenant_source_env_id: tenantSourceEnvironment.env_id,
173
+ tenant_target_env_id: tenantDestinationEnvironment.env_id
174
+ } : {}
175
+ };
176
+ };
159
177
  const toggleSection = (id) => {
160
178
  setOpenSections((current) => ({ ...current, [id]: !current[id] }));
161
179
  };
@@ -166,6 +184,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
166
184
  setError(null);
167
185
  setPromotionTask(null);
168
186
  setPromotionStatusForActions(null);
187
+ setViewedHistoryTaskId(null);
169
188
  const refreshInitialPromotionState = async () => {
170
189
  try {
171
190
  const status = await getPromotionStatus(guidelineResourceId);
@@ -205,14 +224,20 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
205
224
  getSchemaPreview(guidelineResourceId).then((preview) => {
206
225
  if (!isCurrent) return;
207
226
  setSchemaPreview(
208
- Object.entries(preview != null ? preview : {}).reduce((groups, [key, value]) => {
209
- if (value && Array.isArray(value.tables)) groups[key] = value;
210
- return groups;
211
- }, {})
227
+ Object.entries(preview != null ? preview : {}).reduce(
228
+ (groups, [key, value]) => {
229
+ if (value && Array.isArray(value.tables)) groups[key] = value;
230
+ return groups;
231
+ },
232
+ {}
233
+ )
212
234
  );
213
235
  }).catch((schemaError) => {
214
236
  if (isCurrent) {
215
- console.error("Failed to load schema preview", { resourceId: guidelineResourceId, schemaError });
237
+ console.error("Failed to load schema preview", {
238
+ resourceId: guidelineResourceId,
239
+ schemaError
240
+ });
216
241
  setSchemaPreview({});
217
242
  }
218
243
  }).finally(() => {
@@ -223,18 +248,20 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
223
248
  };
224
249
  }, [guidelineResourceId]);
225
250
  useEffect(() => {
226
- var _a2, _b2, _c2, _d2;
227
251
  if (!configuredEnvironment) return;
228
- const selectedEnvironment2 = configuredEnvironment === "source" ? (_a2 = sourceEnvironment == null ? void 0 : sourceEnvironment.env_tier) != null ? _a2 : "dev" : configuredEnvironment === "destination" ? (_b2 = destinationEnvironment == null ? void 0 : destinationEnvironment.env_tier) != null ? _b2 : permittedDestinationTiers[0] : configuredEnvironment === "tenantSource" ? (_c2 = tenantSourceEnvironment == null ? void 0 : tenantSourceEnvironment.env_tier) != null ? _c2 : "dev" : (_d2 = tenantDestinationEnvironment == null ? void 0 : tenantDestinationEnvironment.env_tier) != null ? _d2 : permittedDestinationTiers[0];
229
- const defaultTier = selectedEnvironment2;
230
- const envTier = configSearchTier != null ? configSearchTier : defaultTier;
252
+ const defaultTier = getDefaultEnvironmentTier(
253
+ configuredEnvironment,
254
+ environments[configuredEnvironment],
255
+ permittedDestinationTiers
256
+ );
257
+ const environmentTier = configSearchTier != null ? configSearchTier : defaultTier;
231
258
  let isCurrent = true;
232
259
  setIsLoadingConfigs(true);
233
260
  setPromotionConfigs([]);
234
261
  searchEnvironmentConfigs({
235
- env_tier: envTier,
236
- db_type: envTier === "external" ? "EXTERNAL" : "INTERNAL",
237
- is_tenant: configuredEnvironment === "tenantSource" || configuredEnvironment === "tenantDestination"
262
+ env_tier: environmentTier,
263
+ db_type: environmentTier === "external" ? "EXTERNAL" : "INTERNAL",
264
+ is_tenant: isTenantEnvironment(configuredEnvironment)
238
265
  }).then((configs) => {
239
266
  if (isCurrent) setPromotionConfigs(configs);
240
267
  }).catch(() => {
@@ -277,7 +304,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
277
304
  }, [promotionTaskForGuideline == null ? void 0 : promotionTaskForGuideline.created_by, promotionTaskForGuideline == null ? void 0 : promotionTaskForGuideline.promotion_task_id]);
278
305
  useEffect(() => {
279
306
  const promotionStatusToPoll = promotionTaskForGuideline != null ? promotionTaskForGuideline : promotionStatusForActions;
280
- if (!promotionStatusToPoll || isStatusPollingStopped || !["MIGRATING", "ROLLBACK_IN_PROGRESS"].includes(promotionStatusToPoll.status)) {
307
+ if (viewedHistoryTaskId || !promotionStatusToPoll || isStatusPollingStopped || !PROMOTION_IN_PROGRESS_STATUSES.some((status) => status === promotionStatusToPoll.status)) {
281
308
  return;
282
309
  }
283
310
  const pollStatus = async () => {
@@ -293,7 +320,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
293
320
  );
294
321
  }
295
322
  };
296
- const intervalId = window.setInterval(pollStatus, 3e4);
323
+ const intervalId = window.setInterval(pollStatus, PROMOTION_POLL_INTERVAL_MS);
297
324
  return () => window.clearInterval(intervalId);
298
325
  }, [
299
326
  guidelineResourceId,
@@ -301,25 +328,18 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
301
328
  promotionStatusForActions,
302
329
  promotionTaskForGuideline,
303
330
  setError,
304
- setPromotionTask
331
+ setPromotionTask,
332
+ viewedHistoryTaskId
305
333
  ]);
306
334
  const handlePromoteNow = async () => {
307
- if (!canPromoteNow || !sourceEnvironment || !destinationEnvironment) return;
335
+ const promotionRequest = createPromotionRequest();
336
+ if (!canPromoteNow || !promotionRequest) return;
308
337
  setSubmitting(true);
309
338
  setSubmittingAction("now");
310
339
  setError(null);
340
+ setViewedHistoryTaskId(null);
311
341
  try {
312
- const task = await startPromotion({
313
- resource_id: getPromotionResourceId(guideline),
314
- resource_type: "PACKAGE",
315
- target_version: "latest",
316
- global_source_env_id: sourceEnvironment.env_id,
317
- global_target_env_id: destinationEnvironment.env_id,
318
- ...tenantSourceEnvironment && tenantDestinationEnvironment ? {
319
- tenant_source_env_id: tenantSourceEnvironment.env_id,
320
- tenant_target_env_id: tenantDestinationEnvironment.env_id
321
- } : {}
322
- });
342
+ const task = await startPromotion(promotionRequest);
323
343
  setIsStatusPollingStopped(false);
324
344
  setPromotionTask(task, guidelineResourceId);
325
345
  setPromotionStatusForActions(task);
@@ -341,28 +361,15 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
341
361
  }
342
362
  };
343
363
  const handlePreflightCheck = async () => {
344
- if (!canCheckPromotionReadiness || !sourceEnvironment || !destinationEnvironment || isCheckingPreflight)
345
- return;
364
+ const promotionRequest = createPromotionRequest();
365
+ if (!canCheckPromotionReadiness || !promotionRequest || isCheckingPreflight) return;
346
366
  setIsCheckingPreflight(true);
347
367
  setPreflightResult(null);
368
+ setIsViewingPreflightDetails(false);
348
369
  setError(null);
349
370
  try {
350
- const result = await checkPromotionPreflight({
351
- resource_id: guidelineResourceId,
352
- resource_type: "PACKAGE",
353
- target_version: "latest",
354
- global_source_env_id: sourceEnvironment.env_id,
355
- global_target_env_id: destinationEnvironment.env_id,
356
- ...tenantSourceEnvironment && tenantDestinationEnvironment ? {
357
- tenant_source_env_id: tenantSourceEnvironment.env_id,
358
- tenant_target_env_id: tenantDestinationEnvironment.env_id
359
- } : {}
360
- });
361
- setPreflightResult({
362
- ready: result.ready,
363
- itemsChecked: result.items_checked,
364
- itemsReady: result.items_ready
365
- });
371
+ const result = await checkPromotionPreflight(promotionRequest);
372
+ setPreflightResult(result);
366
373
  } catch (preflightError) {
367
374
  setError(
368
375
  preflightError instanceof Error ? preflightError.message : "Unable to complete pre-flight check.",
@@ -373,42 +380,44 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
373
380
  }
374
381
  };
375
382
  const handleSaveEnvironment = async (environment, configuration) => {
376
- const isTenantEnvironment = environment === "tenantSource" || environment === "tenantDestination";
377
383
  const configurationToSave = {
378
384
  ...configuration,
379
- is_tenant_db: isTenantEnvironment
385
+ is_tenant_db: isTenantEnvironment(environment)
380
386
  };
381
- const response = await createEnvironmentConfig(
382
- toCreateEnvironmentConfigRequest(configurationToSave)
387
+ const credential = await addAlloyDbCredential(
388
+ toAddAlloyDbCredentialRequest(configurationToSave)
389
+ );
390
+ await createEnvironmentConfig(
391
+ toCreateEnvironmentConfigRequest(
392
+ configurationToSave,
393
+ credential.credId,
394
+ credential.credName
395
+ )
396
+ );
397
+ setEnvironment(
398
+ environment,
399
+ toRegistryRecord(credential.credId, {
400
+ ...configurationToSave,
401
+ env_name: credential.credName
402
+ })
383
403
  );
384
- setEnvironment(environment, toRegistryRecord(response.env_id, configurationToSave));
385
404
  };
386
405
  const openEnvironmentConfiguration = (environment) => {
387
- var _a2;
388
- const selected = environment === "source" ? sourceEnvironment : environment === "destination" ? destinationEnvironment : environment === "tenantSource" ? tenantSourceEnvironment : tenantDestinationEnvironment;
389
406
  setConfigSearchTier(
390
- (_a2 = selected == null ? void 0 : selected.env_tier) != null ? _a2 : environment === "source" || environment === "tenantSource" ? "dev" : permittedDestinationTiers[0]
407
+ getDefaultEnvironmentTier(environment, environments[environment], permittedDestinationTiers)
391
408
  );
392
409
  setConfiguredEnvironment(environment);
393
410
  };
394
411
  const handlePromoteLater = async () => {
395
412
  var _a2, _b2;
396
- if (!canPromoteLater || !sourceEnvironment || !destinationEnvironment) return;
413
+ const promotionRequest = createPromotionRequest();
414
+ if (!canPromoteLater || !promotionRequest) return;
397
415
  setSubmitting(true);
398
416
  setSubmittingAction("later");
399
417
  setError(null);
418
+ setViewedHistoryTaskId(null);
400
419
  try {
401
- const scheduledPromotion = await schedulePromotion({
402
- resource_id: guidelineResourceId,
403
- resource_type: "PACKAGE",
404
- target_version: "latest",
405
- global_source_env_id: sourceEnvironment.env_id,
406
- global_target_env_id: destinationEnvironment.env_id,
407
- ...tenantSourceEnvironment && tenantDestinationEnvironment ? {
408
- tenant_source_env_id: tenantSourceEnvironment.env_id,
409
- tenant_target_env_id: tenantDestinationEnvironment.env_id
410
- } : {}
411
- });
420
+ const scheduledPromotion = await schedulePromotion(promotionRequest);
412
421
  const now = (/* @__PURE__ */ new Date()).toISOString();
413
422
  setPromotionTask(
414
423
  {
@@ -441,6 +450,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
441
450
  setSubmitting(true);
442
451
  setSubmittingAction("trigger");
443
452
  setError(null);
453
+ setViewedHistoryTaskId(null);
444
454
  try {
445
455
  const task = await triggerScheduledPromotion(triggerUrl);
446
456
  setIsStatusPollingStopped(false);
@@ -467,8 +477,9 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
467
477
  setHistoryActionTaskId(promotionTaskId);
468
478
  setError(null);
469
479
  try {
470
- setIsStatusPollingStopped(false);
471
- setPromotionTask(await getPromotionStatus(guidelineResourceId), guidelineResourceId);
480
+ const task = await getPromotionTaskDetails(promotionTaskId);
481
+ setViewedHistoryTaskId(promotionTaskId);
482
+ setPromotionTask(task, guidelineResourceId);
472
483
  } catch (statusError) {
473
484
  setError(
474
485
  statusError instanceof Error ? statusError.message : "Unable to load promotion details.",
@@ -481,6 +492,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
481
492
  const handleRollbackPromotion = async (promotionTaskId) => {
482
493
  setHistoryActionTaskId(promotionTaskId);
483
494
  setError(null);
495
+ setViewedHistoryTaskId(null);
484
496
  try {
485
497
  const task = await rollbackPromotion(promotionTaskId);
486
498
  setIsStatusPollingStopped(false);
@@ -497,6 +509,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
497
509
  const handleBack = async () => {
498
510
  if (promotionTaskForGuideline) {
499
511
  setPromotionTask(null);
512
+ setViewedHistoryTaskId(null);
500
513
  setIsInitialStatusLoading(true);
501
514
  setIsLoadingHistory(true);
502
515
  try {
@@ -656,7 +669,10 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
656
669
  ),
657
670
  onClick: () => canRollback ? handleRollbackPromotion(row.promotion_task_id) : handleViewPromotionDetails(row.promotion_task_id),
658
671
  disabled: isInitialStatusLoading || historyActionTaskId !== null,
659
- children: historyActionTaskId === row.promotion_task_id ? canRollback ? "Rolling back\u2026" : "Loading\u2026" : canRollback ? "Rollback" : "View details"
672
+ children: getHistoryActionLabel(
673
+ historyActionTaskId === row.promotion_task_id,
674
+ canRollback
675
+ )
660
676
  }
661
677
  )
662
678
  ] })
@@ -665,9 +681,11 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
665
681
  ] }) }) });
666
682
  }
667
683
  if (id === "database") {
668
- if (isLoadingSchemaPreview) return /* @__PURE__ */ jsx("div", { className: cssStyles.emptyBody, children: "Loading database details\u2026" });
684
+ if (isLoadingSchemaPreview)
685
+ return /* @__PURE__ */ jsx("div", { className: cssStyles.emptyBody, children: "Loading database details\u2026" });
669
686
  const groups = Object.entries(schemaPreview);
670
- if (groups.length === 0) return /* @__PURE__ */ jsx("div", { className: cssStyles.emptyBody, children: "No database details available." });
687
+ if (groups.length === 0)
688
+ return /* @__PURE__ */ jsx("div", { className: cssStyles.emptyBody, children: "No database details available." });
671
689
  return /* @__PURE__ */ jsx("div", { className: cssStyles.databaseGrid, children: groups.flatMap(
672
690
  ([groupName, group]) => ["Source", "Destination"].map((environment) => /* @__PURE__ */ jsxs("div", { className: cssStyles.databaseCard, children: [
673
691
  /* @__PURE__ */ jsxs("h3", { children: [
@@ -690,6 +708,15 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
690
708
  }
691
709
  return /* @__PURE__ */ jsx("div", { className: cssStyles.emptyBody, children: "No details available yet." });
692
710
  };
711
+ if (isViewingPreflightDetails && preflightResult) {
712
+ return /* @__PURE__ */ jsx("div", { className: cx(cssStyles.root, className), children: /* @__PURE__ */ jsx(
713
+ PreflightDetailsPage,
714
+ {
715
+ result: preflightResult,
716
+ onBack: () => setIsViewingPreflightDetails(false)
717
+ }
718
+ ) });
719
+ }
693
720
  return /* @__PURE__ */ jsxs("div", { className: cx(cssStyles.root, className), children: [
694
721
  /* @__PURE__ */ jsxs("main", { className: cssStyles.body, children: [
695
722
  /* @__PURE__ */ jsxs("div", { className: cssStyles.topRow, children: [
@@ -724,15 +751,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
724
751
  ) })
725
752
  }
726
753
  ),
727
- /* @__PURE__ */ jsx(
728
- StyledPromoteTooltip,
729
- {
730
- title: "Runs a safe validation of the selected source and destination environments. It does not start a migration.",
731
- placement: "top",
732
- arrow: true,
733
- children: /* @__PURE__ */ jsx("span", { className: cssStyles.preflightInfo, "aria-label": "About the pre-flight check", children: /* @__PURE__ */ jsx(Info, { className: cssStyles.helpIcon, strokeWidth: 2.2, "aria-hidden": "true" }) })
734
- }
735
- )
754
+ /* @__PURE__ */ jsx(StyledPromoteTooltip, { title: PREFLIGHT_TOOLTIP, placement: "top", arrow: true, children: /* @__PURE__ */ jsx("span", { className: cssStyles.preflightInfo, "aria-label": "About the pre-flight check", children: /* @__PURE__ */ jsx(Info, { className: cssStyles.helpIcon, strokeWidth: 2.2, "aria-hidden": "true" }) }) })
736
755
  ] }),
737
756
  isPromoting ? /* @__PURE__ */ jsxs(Fragment, { children: [
738
757
  canRetryPromotion && /* @__PURE__ */ jsxs(
@@ -809,9 +828,19 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
809
828
  ] })
810
829
  ] }),
811
830
  preflightResult && /* @__PURE__ */ jsxs("div", { className: cssStyles.preflightSuccess, role: "status", children: [
812
- "Pre-flight check completed successfully.",
813
- " ",
814
- preflightResult.ready ? `Migration is ready (${preflightResult.itemsReady}/${preflightResult.itemsChecked} checks passed).` : `Migration readiness requires attention (${preflightResult.itemsReady}/${preflightResult.itemsChecked} checks passed).`
831
+ /* @__PURE__ */ jsxs("span", { children: [
832
+ "Pre-flight check completed successfully. ",
833
+ getPreflightResultMessage(preflightResult)
834
+ ] }),
835
+ preflightResult.ready && /* @__PURE__ */ jsx(
836
+ "button",
837
+ {
838
+ type: "button",
839
+ className: cssStyles.preflightDetailsButton,
840
+ onClick: () => setIsViewingPreflightDetails(true),
841
+ children: "View preflight details"
842
+ }
843
+ )
815
844
  ] }),
816
845
  isPromoting ? /* @__PURE__ */ jsxs("div", { className: cssStyles.promotionStatusBox, children: [
817
846
  /* @__PURE__ */ jsx("div", { className: cssStyles.promotionStatusRow, children: /* @__PURE__ */ jsxs("div", { className: cssStyles.promotionStatusRowHeader, children: [
@@ -836,7 +865,7 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
836
865
  /* @__PURE__ */ jsx("div", { className: cssStyles.metaValue, children: formatPromotionDate(promotionTaskForGuideline == null ? void 0 : promotionTaskForGuideline.created_at) })
837
866
  ] }),
838
867
  /* @__PURE__ */ jsxs("div", { children: [
839
- /* @__PURE__ */ jsx("div", { className: cssStyles.metaLabel, children: "Promoted by" }),
868
+ /* @__PURE__ */ jsx("div", { className: cssStyles.metaLabel, children: (promotionTaskForGuideline == null ? void 0 : promotionTaskForGuideline.status) === "SCHEDULED" ? "Scheduled by" : "Promoted by" }),
840
869
  /* @__PURE__ */ jsx("div", { className: cssStyles.metaValue, children: promotedByName != null ? promotedByName : "\u2014" })
841
870
  ] }),
842
871
  /* @__PURE__ */ jsxs("div", { children: [
@@ -955,27 +984,12 @@ function PromoteFlow({ guideline, onBack, onPromote, className }) {
955
984
  EnvironmentConfigurationModal,
956
985
  {
957
986
  environment: configuredEnvironment,
958
- initialConfiguration: selectedEnvironment ? {
959
- env_name: selectedEnvironment.env_name,
960
- env_tier: selectedEnvironment.env_tier,
961
- db_type: selectedEnvironment.db_type,
962
- host: selectedEnvironment.host,
963
- port: String(selectedEnvironment.port),
964
- username: selectedEnvironment.username,
965
- password: "",
966
- database_name: selectedEnvironment.database_name,
967
- is_tenant_db: selectedEnvironment.is_tenant_db
968
- } : {
969
- ...EMPTY_ENVIRONMENT_CONFIGURATION,
970
- env_tier: configuredEnvironment === "source" || configuredEnvironment === "tenantSource" ? "dev" : permittedDestinationTiers[0],
971
- db_type: (configuredEnvironment === "destination" || configuredEnvironment === "tenantDestination") && permittedDestinationTiers[0] === "external" ? "EXTERNAL" : "INTERNAL",
972
- is_tenant_db: configuredEnvironment === "tenantSource" || configuredEnvironment === "tenantDestination"
973
- },
974
- permittedTiers: configuredEnvironment === "source" || configuredEnvironment === "tenantSource" ? permittedSourceTiers : permittedDestinationTiers,
987
+ initialConfiguration: modalInitialConfiguration,
988
+ permittedTiers: modalPermittedTiers,
975
989
  onSave: handleSaveEnvironment,
976
990
  onSelectPreset: setEnvironment,
977
991
  onPresetTierChange: setConfigSearchTier,
978
- presetTier: configSearchTier != null ? configSearchTier : configuredEnvironment === "source" ? (_e = sourceEnvironment == null ? void 0 : sourceEnvironment.env_tier) != null ? _e : "dev" : configuredEnvironment === "destination" ? (_f = destinationEnvironment == null ? void 0 : destinationEnvironment.env_tier) != null ? _f : permittedDestinationTiers[0] : configuredEnvironment === "tenantSource" ? (_g = tenantSourceEnvironment == null ? void 0 : tenantSourceEnvironment.env_tier) != null ? _g : "dev" : (_h = tenantDestinationEnvironment == null ? void 0 : tenantDestinationEnvironment.env_tier) != null ? _h : permittedDestinationTiers[0],
992
+ presetTier: modalPresetTier,
979
993
  onClose: () => {
980
994
  setConfiguredEnvironment(null);
981
995
  setConfigSearchTier(null);