@gen3/workspaces 0.12.77 → 0.12.79

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 (42) hide show
  1. package/dist/dts/components/CodingAssistantPanel/CodingAssistantPanel.stories.d.ts +1 -1
  2. package/dist/dts/components/CodingAssistantPanel/CodingAssistantPanel.stories.d.ts.map +1 -1
  3. package/dist/dts/components/CodingAssistantPanel/CodingAssistantPanel.stories.js +2 -2
  4. package/dist/dts/components/CodingAssistantPanel/MessageBubble.stories.d.ts +1 -1
  5. package/dist/dts/components/CodingAssistantPanel/MessageBubble.stories.d.ts.map +1 -1
  6. package/dist/dts/components/CodingAssistantPanel/MessageBubble.stories.js +7 -7
  7. package/dist/dts/components/CompactDictionaryPanel/CompactDictionaryPanel.stories.d.ts +1 -1
  8. package/dist/dts/components/CompactDictionaryPanel/CompactDictionaryPanel.stories.d.ts.map +1 -1
  9. package/dist/dts/components/CostTracker.d.ts.map +1 -1
  10. package/dist/dts/components/CostTracker.js +62 -36
  11. package/dist/dts/components/CostTracker.js.map +1 -1
  12. package/dist/dts/components/DataToolsPanel.stories.d.ts +1 -1
  13. package/dist/dts/components/DataToolsPanel.stories.d.ts.map +1 -1
  14. package/dist/dts/components/DataToolsPanel.stories.js +2 -2
  15. package/dist/dts/components/DataToolsRail.stories.d.ts +1 -1
  16. package/dist/dts/components/DataToolsRail.stories.d.ts.map +1 -1
  17. package/dist/dts/components/InfrastructureRightPanel.stories.d.ts +1 -1
  18. package/dist/dts/components/InfrastructureRightPanel.stories.d.ts.map +1 -1
  19. package/dist/dts/components/KernelLifecyclePanel/ConnectionStatusBadge.stories.d.ts +1 -1
  20. package/dist/dts/components/KernelLifecyclePanel/ConnectionStatusBadge.stories.d.ts.map +1 -1
  21. package/dist/dts/components/KernelLifecyclePanel/KernelLifecyclePanel.stories.d.ts +1 -1
  22. package/dist/dts/components/KernelLifecyclePanel/KernelLifecyclePanel.stories.d.ts.map +1 -1
  23. package/dist/dts/components/MicroContainerPanel.stories.d.ts +1 -1
  24. package/dist/dts/components/MicroContainerPanel.stories.d.ts.map +1 -1
  25. package/dist/dts/components/TierSelectorLanding.stories.d.ts +1 -1
  26. package/dist/dts/components/TierSelectorLanding.stories.d.ts.map +1 -1
  27. package/dist/dts/components/UpgradeActionsPanel.stories.d.ts +1 -1
  28. package/dist/dts/components/UpgradeActionsPanel.stories.d.ts.map +1 -1
  29. package/dist/dts/components/UpgradeActionsPanel.stories.js +3 -3
  30. package/dist/dts/components/WorkspaceTierCard.stories.d.ts +1 -1
  31. package/dist/dts/components/WorkspaceTierCard.stories.d.ts.map +1 -1
  32. package/dist/dts/components/WorkspaceTierCard.stories.js +1 -1
  33. package/dist/dts/index.d.ts +2 -1
  34. package/dist/dts/index.d.ts.map +1 -1
  35. package/dist/dts/index.js +2 -1
  36. package/dist/dts/index.js.map +1 -1
  37. package/dist/index/cjs/index.js +68 -56
  38. package/dist/index/cjs/index.js.map +1 -1
  39. package/dist/index/esm/index.js +69 -58
  40. package/dist/index/esm/index.js.map +1 -1
  41. package/dist/index.d.ts +6 -2
  42. package/package.json +4 -4
@@ -2428,52 +2428,74 @@ const SettingsPanel = ({ showKernels, expanded, setExpanded, width = 380 })=>{
2428
2428
  });
2429
2429
  };
2430
2430
 
2431
- const PaymentNumberToString = (x, undefinedValue = 'N/A', precision = 2)=>{
2431
+ // TODO rework once requirements are made
2432
+ const usdFormatter = new Intl.NumberFormat('en-US', {
2433
+ style: 'currency',
2434
+ currency: 'USD'
2435
+ });
2436
+ const paymentNumberToString = (x, undefinedValue = 'N/A', precision = 2)=>{
2432
2437
  if (typeof x !== 'number' || Number.isNaN(x)) return undefinedValue;
2433
- return x.toFixed(precision);
2438
+ return usdFormatter.format(x);
2434
2439
  };
2435
2440
  const isNoPayModelError = (error)=>{
2436
2441
  return 'status' in error && error.status === 'PARSING_ERROR' && error.originalStatus === 404;
2437
2442
  };
2438
2443
  const CostTracker = ({ workspaceAccountManagerTarget = '' })=>{
2439
- const { data, isLoading, isFetching, isError, error } = core$1.useGetWorkspacePayModelsQuery(undefined, {
2444
+ const { data, isLoading, isFetching, isError, error, isSuccess } = core$1.useGetWorkspacePayModelsQuery(undefined, {
2440
2445
  pollingInterval: 120000,
2441
2446
  refetchOnMountOrArgChange: true
2442
2447
  });
2443
- const [setWorkspacePayModel] = core$1.useSetCurrentPayModelMutation();
2448
+ const { data: currentPaymodelData, isFetching: isCurrentPayModelFetching } = core$1.useGetActivePayModelQuery();
2449
+ const [setWorkspacePayModel, result] = core$1.useSetCurrentPayModelMutation();
2444
2450
  const [selectedPayModel, setSelectedPayModel] = React.useState(null);
2445
2451
  const [opened, setOpened] = React.useState(false);
2446
- useDeepCompare.useDeepCompareCallback((id)=>{
2447
- void setWorkspacePayModel(id); // triggers the call to the service to select the pay model
2452
+ const setPayModel = useDeepCompare.useDeepCompareCallback((id)=>{
2453
+ void setWorkspacePayModel(id).unwrap(); // triggers the call to the service to select the pay model
2448
2454
  setSelectedPayModel(id); // set the paymodel value for the select component
2449
2455
  }, [
2450
2456
  setWorkspacePayModel,
2451
2457
  selectedPayModel
2452
2458
  ]);
2453
2459
  const { usersPayModels, workspaceName, hardLimit, totalUsage } = useDeepCompare.useDeepCompareMemo(()=>{
2454
- if (!data) return {
2455
- usersPayModels: [],
2456
- selectedPayModel: [],
2457
- workspaceName: 'Not Set',
2458
- totalUsage: undefined,
2459
- hardLimit: undefined
2460
- };
2461
- const usersPayModels = data.allPayModels.map((payModel)=>{
2460
+ if (isSuccess && data) {
2461
+ const usersPayModels = data?.allPayModels.map((payModel)=>{
2462
+ return {
2463
+ value: payModel.bmh_workspace_id ?? payModel.workspace_type,
2464
+ label: payModel.workspace_type,
2465
+ totalUsage: payModel['total-usage'],
2466
+ currentPayModel: payModel.current_pay_model ?? null,
2467
+ icon: payModel.request_status === 'active' ? /*#__PURE__*/ jsxRuntime.jsx(fa.FaUser, {}) : /*#__PURE__*/ jsxRuntime.jsx(fa.FaExclamationCircle, {})
2468
+ };
2469
+ });
2470
+ let currentPayModel = null;
2471
+ if (data?.currentPayModel) {
2472
+ currentPayModel = data?.currentPayModel.bmh_workspace_id ?? data?.currentPayModel.workspace_type;
2473
+ }
2474
+ setSelectedPayModel(currentPayModel);
2475
+ let workspaceName = 'Not Set';
2476
+ let totalUsage = undefined;
2477
+ let hardLimit = undefined;
2478
+ if (data.currentPayModel !== null) {
2479
+ workspaceName = data.currentPayModel.bmh_workspace_id.length > 0 ? data.currentPayModel.bmh_workspace_id : data.currentPayModel.workspace_type;
2480
+ totalUsage = data.currentPayModel?.['total-usage'];
2481
+ hardLimit = data.currentPayModel?.['hard-limit'];
2482
+ }
2462
2483
  return {
2463
- value: payModel.bmh_workspace_id ?? payModel.workspace_type,
2464
- label: payModel.workspace_type,
2465
- totalUsage: payModel['total-usage'],
2466
- currentPayModel: payModel['current_pay_model'],
2467
- icon: payModel.request_status === 'active' ? /*#__PURE__*/ jsxRuntime.jsx(fa.FaUser, {}) : /*#__PURE__*/ jsxRuntime.jsx(fa.FaExclamationCircle, {})
2484
+ usersPayModels,
2485
+ workspaceName,
2486
+ selectedPayModel,
2487
+ totalUsage,
2488
+ hardLimit
2468
2489
  };
2469
- });
2470
- setSelectedPayModel(data.currentPayModel.bmh_workspace_id ?? data.currentPayModel.workspace_type);
2471
- return {
2472
- usersPayModels,
2473
- workspaceName: data.currentPayModel.bmh_workspace_id.length > 0 ? data.currentPayModel.bmh_workspace_id : data.currentPayModel.workspace_type,
2474
- totalUsage: data.currentPayModel['total-usage'],
2475
- hardLimit: data.currentPayModel['hard-limit']
2476
- };
2490
+ } else {
2491
+ return {
2492
+ usersPayModels: [],
2493
+ selectedPayModel: [],
2494
+ workspaceName: 'Not Set',
2495
+ totalUsage: undefined,
2496
+ hardLimit: undefined
2497
+ };
2498
+ }
2477
2499
  }, [
2478
2500
  data
2479
2501
  ]);
@@ -2553,8 +2575,8 @@ const CostTracker = ({ workspaceAccountManagerTarget = '' })=>{
2553
2575
  size: "sm",
2554
2576
  radius: "xl",
2555
2577
  "aria-label": "Monthly Workflow Limit",
2556
- value: !hardLimit ? 100 : hardLimit / totalUsage * 100,
2557
- color: !hardLimit || totalUsage >= hardLimit ? 'red.5' : 'green.1',
2578
+ value: !hardLimit || !totalUsage ? 100 : hardLimit / totalUsage * 100,
2579
+ color: !hardLimit || totalUsage && totalUsage >= hardLimit ? 'red.5' : 'green.1',
2558
2580
  className: className
2559
2581
  });
2560
2582
  return /*#__PURE__*/ jsxRuntime.jsxs(core.Popover, {
@@ -2583,18 +2605,15 @@ const CostTracker = ({ workspaceAccountManagerTarget = '' })=>{
2583
2605
  }),
2584
2606
  children: [
2585
2607
  ProgressBar('w-[110px]'),
2586
- /*#__PURE__*/ jsxRuntime.jsxs("span", {
2587
- className: "font-black pl-3 pr-2",
2588
- children: [
2589
- "$",
2590
- PaymentNumberToString(totalUsage)
2591
- ]
2608
+ /*#__PURE__*/ jsxRuntime.jsx("span", {
2609
+ className: "font-black pl-3 pr-1",
2610
+ children: paymentNumberToString(totalUsage)
2592
2611
  }),
2593
2612
  /*#__PURE__*/ jsxRuntime.jsxs("span", {
2594
2613
  className: "font-normal",
2595
2614
  children: [
2596
- "/$",
2597
- PaymentNumberToString(hardLimit)
2615
+ "/",
2616
+ paymentNumberToString(hardLimit)
2598
2617
  ]
2599
2618
  })
2600
2619
  ]
@@ -2620,13 +2639,11 @@ const CostTracker = ({ workspaceAccountManagerTarget = '' })=>{
2620
2639
  size: "sm",
2621
2640
  className: "uppercase pb-2 px-2",
2622
2641
  children: [
2623
- "Limit ",
2624
- /*#__PURE__*/ jsxRuntime.jsxs("span", {
2642
+ "Limit",
2643
+ ' ',
2644
+ /*#__PURE__*/ jsxRuntime.jsx("span", {
2625
2645
  className: "font-black pl-1",
2626
- children: [
2627
- "$",
2628
- PaymentNumberToString(hardLimit)
2629
- ]
2646
+ children: paymentNumberToString(hardLimit)
2630
2647
  })
2631
2648
  ]
2632
2649
  }),
@@ -2653,22 +2670,19 @@ const CostTracker = ({ workspaceAccountManagerTarget = '' })=>{
2653
2670
  value: "accountInformation",
2654
2671
  children: [
2655
2672
  /*#__PURE__*/ jsxRuntime.jsx(core.Accordion.Control, {
2656
- children: /*#__PURE__*/ jsxRuntime.jsxs(core.Text, {
2673
+ children: /*#__PURE__*/ jsxRuntime.jsx(core.Text, {
2657
2674
  size: "sm",
2658
2675
  className: "font-black",
2659
- children: [
2660
- workspaceName,
2661
- " - $",
2662
- PaymentNumberToString(totalUsage)
2663
- ]
2676
+ children: `${workspaceName} - ${paymentNumberToString(totalUsage)}`
2664
2677
  })
2665
2678
  }),
2666
2679
  /*#__PURE__*/ jsxRuntime.jsx(core.Accordion.Panel, {
2667
2680
  children: /*#__PURE__*/ jsxRuntime.jsx(core.Radio.Group, {
2668
2681
  className: "pt-2",
2682
+ onChange: setPayModel,
2683
+ value: selectedPayModel,
2669
2684
  children: usersPayModels.map((obj)=>/*#__PURE__*/ jsxRuntime.jsx(core.Radio.Card, {
2670
- checked: obj.currentPayModel,
2671
- disabled: true,
2685
+ value: obj.value,
2672
2686
  className: "p-2 border-none data-checked:bg-primary-lightest data-checked:border-primary-darker data-checked:font-black hover:bg-primary-max ",
2673
2687
  children: /*#__PURE__*/ jsxRuntime.jsxs(core.Group, {
2674
2688
  wrap: "nowrap",
@@ -2679,12 +2693,9 @@ const CostTracker = ({ workspaceAccountManagerTarget = '' })=>{
2679
2693
  className: "grow",
2680
2694
  children: obj.label
2681
2695
  }),
2682
- /*#__PURE__*/ jsxRuntime.jsxs(core.Text, {
2696
+ /*#__PURE__*/ jsxRuntime.jsx(core.Text, {
2683
2697
  size: "sm",
2684
- children: [
2685
- "$",
2686
- PaymentNumberToString(obj.totalUsage)
2687
- ]
2698
+ children: `${paymentNumberToString(obj.totalUsage)}`
2688
2699
  }),
2689
2700
  /*#__PURE__*/ jsxRuntime.jsx(core.Radio.Indicator, {
2690
2701
  color: "accent"
@@ -4487,6 +4498,7 @@ const WorkspacesCenterPageGetServerSideProps = async ()=>{
4487
4498
  }
4488
4499
  };
4489
4500
 
4501
+ exports.CostTracker = CostTracker;
4490
4502
  exports.WorkspacesCenterPage = WorkspacesCenterPage;
4491
4503
  exports.WorkspacesCenterPageGetServerSideProps = WorkspacesCenterPageGetServerSideProps;
4492
4504
  //# sourceMappingURL=index.js.map