@gen3/workspaces 0.12.66 → 0.12.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/dts/components/CostTracker.d.ts +6 -0
- package/dist/dts/components/CostTracker.d.ts.map +1 -0
- package/dist/dts/components/CostTracker.js +162 -0
- package/dist/dts/components/CostTracker.js.map +1 -0
- package/dist/dts/workspace/WorkspaceLayout/WorkspaceToolbar.d.ts.map +1 -1
- package/dist/dts/workspace/WorkspaceLayout/WorkspaceToolbar.js +3 -2
- package/dist/dts/workspace/WorkspaceLayout/WorkspaceToolbar.js.map +1 -1
- package/dist/dts/workspace/tiers/types.d.ts +2 -0
- package/dist/dts/workspace/tiers/types.d.ts.map +1 -1
- package/dist/index/cjs/index.js +280 -1
- package/dist/index/cjs/index.js.map +1 -1
- package/dist/index/esm/index.js +284 -5
- package/dist/index/esm/index.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/package.json +5 -4
package/dist/index/cjs/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var core$1 = require('@gen3/core');
|
|
|
10
10
|
var useDeepCompare = require('use-deep-compare');
|
|
11
11
|
var notifications = require('@mantine/notifications');
|
|
12
12
|
var md = require('react-icons/md');
|
|
13
|
+
var fa = require('react-icons/fa');
|
|
13
14
|
var io5 = require('react-icons/io5');
|
|
14
15
|
var bs = require('react-icons/bs');
|
|
15
16
|
var lodash = require('lodash');
|
|
@@ -2427,11 +2428,286 @@ const SettingsPanel = ({ showKernels, expanded, setExpanded, width = 380 })=>{
|
|
|
2427
2428
|
});
|
|
2428
2429
|
};
|
|
2429
2430
|
|
|
2431
|
+
const PaymentNumberToString = (x, undefinedValue = 'N/A', precision = 2)=>{
|
|
2432
|
+
if (typeof x !== 'number' || Number.isNaN(x)) return undefinedValue;
|
|
2433
|
+
return x.toFixed(precision);
|
|
2434
|
+
};
|
|
2435
|
+
const isNoPayModelError = (error)=>{
|
|
2436
|
+
return 'status' in error && error.status === 'PARSING_ERROR' && error.originalStatus === 404;
|
|
2437
|
+
};
|
|
2438
|
+
const CostTracker = ({ workspaceAccountManagerTarget = '' })=>{
|
|
2439
|
+
const { data, isLoading, isFetching, isError, error } = core$1.useGetWorkspacePayModelsQuery(undefined, {
|
|
2440
|
+
pollingInterval: 120000,
|
|
2441
|
+
refetchOnMountOrArgChange: true
|
|
2442
|
+
});
|
|
2443
|
+
const [setWorkspacePayModel] = core$1.useSetCurrentPayModelMutation();
|
|
2444
|
+
const [selectedPayModel, setSelectedPayModel] = React.useState(null);
|
|
2445
|
+
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
|
|
2448
|
+
setSelectedPayModel(id); // set the paymodel value for the select component
|
|
2449
|
+
}, [
|
|
2450
|
+
setWorkspacePayModel,
|
|
2451
|
+
selectedPayModel
|
|
2452
|
+
]);
|
|
2453
|
+
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)=>{
|
|
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'],
|
|
2467
|
+
icon: payModel.request_status === 'active' ? /*#__PURE__*/ jsxRuntime.jsx(fa.FaUser, {}) : /*#__PURE__*/ jsxRuntime.jsx(fa.FaExclamationCircle, {})
|
|
2468
|
+
};
|
|
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
|
+
};
|
|
2477
|
+
}, [
|
|
2478
|
+
data
|
|
2479
|
+
]);
|
|
2480
|
+
if (isLoading && isFetching) return /*#__PURE__*/ jsxRuntime.jsx(core.Badge, {
|
|
2481
|
+
leftSection: /*#__PURE__*/ jsxRuntime.jsx(core.Loader, {
|
|
2482
|
+
size: "xs",
|
|
2483
|
+
type: "dots",
|
|
2484
|
+
className: "m-1"
|
|
2485
|
+
}),
|
|
2486
|
+
variant: "default",
|
|
2487
|
+
children: "Loading..."
|
|
2488
|
+
});
|
|
2489
|
+
const PayModelError = (message)=>{
|
|
2490
|
+
// dropdown error state to provide user access to Account Manager if available
|
|
2491
|
+
if (workspaceAccountManagerTarget) {
|
|
2492
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(core.Popover, {
|
|
2493
|
+
width: "target",
|
|
2494
|
+
position: "bottom",
|
|
2495
|
+
shadow: "lg",
|
|
2496
|
+
trapFocus: true,
|
|
2497
|
+
opened: opened,
|
|
2498
|
+
onChange: setOpened,
|
|
2499
|
+
children: [
|
|
2500
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.Popover.Target, {
|
|
2501
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(core.Button, {
|
|
2502
|
+
onClick: ()=>setOpened((o)=>!o),
|
|
2503
|
+
size: "xs",
|
|
2504
|
+
radius: "xl",
|
|
2505
|
+
className: "h-[--badge-height] uppercase",
|
|
2506
|
+
color: "utility.3",
|
|
2507
|
+
rightSection: /*#__PURE__*/ jsxRuntime.jsx(md.MdExpandMore, {
|
|
2508
|
+
size: "1.5em",
|
|
2509
|
+
"aria-label": opened ? 'close' : 'open',
|
|
2510
|
+
style: {
|
|
2511
|
+
transform: opened ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
2512
|
+
transition: 'transform 200ms ease'
|
|
2513
|
+
}
|
|
2514
|
+
}),
|
|
2515
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
2516
|
+
className: "font-black",
|
|
2517
|
+
children: message
|
|
2518
|
+
})
|
|
2519
|
+
})
|
|
2520
|
+
}),
|
|
2521
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.Popover.Dropdown, {
|
|
2522
|
+
className: "px-2",
|
|
2523
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(core.Button, {
|
|
2524
|
+
component: "a",
|
|
2525
|
+
href: workspaceAccountManagerTarget,
|
|
2526
|
+
target: "_blank",
|
|
2527
|
+
variant: "outline",
|
|
2528
|
+
leftSection: /*#__PURE__*/ jsxRuntime.jsx(md.MdOpenInNew, {
|
|
2529
|
+
size: "1.1em",
|
|
2530
|
+
"aria-label": "external"
|
|
2531
|
+
}),
|
|
2532
|
+
size: "xs",
|
|
2533
|
+
className: "w-full",
|
|
2534
|
+
children: "Workspace Account Manager"
|
|
2535
|
+
})
|
|
2536
|
+
})
|
|
2537
|
+
]
|
|
2538
|
+
});
|
|
2539
|
+
}
|
|
2540
|
+
return /*#__PURE__*/ jsxRuntime.jsx(core.Badge, {
|
|
2541
|
+
color: "utility.3",
|
|
2542
|
+
children: message
|
|
2543
|
+
});
|
|
2544
|
+
};
|
|
2545
|
+
if (isError) {
|
|
2546
|
+
if (isNoPayModelError(error)) {
|
|
2547
|
+
return PayModelError('No pay model defined');
|
|
2548
|
+
} else {
|
|
2549
|
+
return PayModelError('Unable to get Payment information');
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
const ProgressBar = (className = '')=>/*#__PURE__*/ jsxRuntime.jsx(core.Progress, {
|
|
2553
|
+
size: "sm",
|
|
2554
|
+
radius: "xl",
|
|
2555
|
+
"aria-label": "Monthly Workflow Limit",
|
|
2556
|
+
value: !hardLimit ? 100 : hardLimit / totalUsage * 100,
|
|
2557
|
+
color: !hardLimit || totalUsage >= hardLimit ? 'red.5' : 'green.1',
|
|
2558
|
+
className: className
|
|
2559
|
+
});
|
|
2560
|
+
return /*#__PURE__*/ jsxRuntime.jsxs(core.Popover, {
|
|
2561
|
+
width: "target",
|
|
2562
|
+
position: "bottom",
|
|
2563
|
+
shadow: "lg",
|
|
2564
|
+
trapFocus: true,
|
|
2565
|
+
opened: opened,
|
|
2566
|
+
onChange: setOpened,
|
|
2567
|
+
children: [
|
|
2568
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.Popover.Target, {
|
|
2569
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(core.Button, {
|
|
2570
|
+
onClick: ()=>setOpened((o)=>!o),
|
|
2571
|
+
size: "xs",
|
|
2572
|
+
radius: "xl",
|
|
2573
|
+
variant: "default",
|
|
2574
|
+
className: "h-[--badge-height]",
|
|
2575
|
+
rightSection: /*#__PURE__*/ jsxRuntime.jsx(md.MdExpandMore, {
|
|
2576
|
+
className: "text-accent",
|
|
2577
|
+
size: "1.5em",
|
|
2578
|
+
"aria-label": opened ? 'close' : 'open',
|
|
2579
|
+
style: {
|
|
2580
|
+
transform: opened ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
2581
|
+
transition: 'transform 200ms ease'
|
|
2582
|
+
}
|
|
2583
|
+
}),
|
|
2584
|
+
children: [
|
|
2585
|
+
ProgressBar('w-[110px]'),
|
|
2586
|
+
/*#__PURE__*/ jsxRuntime.jsxs("span", {
|
|
2587
|
+
className: "font-black pl-3 pr-2",
|
|
2588
|
+
children: [
|
|
2589
|
+
"$",
|
|
2590
|
+
PaymentNumberToString(totalUsage)
|
|
2591
|
+
]
|
|
2592
|
+
}),
|
|
2593
|
+
/*#__PURE__*/ jsxRuntime.jsxs("span", {
|
|
2594
|
+
className: "font-normal",
|
|
2595
|
+
children: [
|
|
2596
|
+
"/$",
|
|
2597
|
+
PaymentNumberToString(hardLimit)
|
|
2598
|
+
]
|
|
2599
|
+
})
|
|
2600
|
+
]
|
|
2601
|
+
})
|
|
2602
|
+
}),
|
|
2603
|
+
/*#__PURE__*/ jsxRuntime.jsxs(core.Popover.Dropdown, {
|
|
2604
|
+
className: "px-2",
|
|
2605
|
+
children: [
|
|
2606
|
+
workspaceAccountManagerTarget && /*#__PURE__*/ jsxRuntime.jsx(core.Button, {
|
|
2607
|
+
component: "a",
|
|
2608
|
+
href: workspaceAccountManagerTarget,
|
|
2609
|
+
target: "_blank",
|
|
2610
|
+
variant: "outline",
|
|
2611
|
+
leftSection: /*#__PURE__*/ jsxRuntime.jsx(md.MdOpenInNew, {
|
|
2612
|
+
size: "1.1em",
|
|
2613
|
+
"aria-label": "external"
|
|
2614
|
+
}),
|
|
2615
|
+
size: "xs",
|
|
2616
|
+
className: "w-full mb-4",
|
|
2617
|
+
children: "Workspace Account Manager"
|
|
2618
|
+
}),
|
|
2619
|
+
/*#__PURE__*/ jsxRuntime.jsxs(core.Text, {
|
|
2620
|
+
size: "sm",
|
|
2621
|
+
className: "uppercase pb-2 px-2",
|
|
2622
|
+
children: [
|
|
2623
|
+
"Limit ",
|
|
2624
|
+
/*#__PURE__*/ jsxRuntime.jsxs("span", {
|
|
2625
|
+
className: "font-black pl-1",
|
|
2626
|
+
children: [
|
|
2627
|
+
"$",
|
|
2628
|
+
PaymentNumberToString(hardLimit)
|
|
2629
|
+
]
|
|
2630
|
+
})
|
|
2631
|
+
]
|
|
2632
|
+
}),
|
|
2633
|
+
ProgressBar('mx-2'),
|
|
2634
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.Divider, {
|
|
2635
|
+
my: "sm"
|
|
2636
|
+
}),
|
|
2637
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.Text, {
|
|
2638
|
+
size: "sm",
|
|
2639
|
+
className: "uppercase pb-2 px-2",
|
|
2640
|
+
children: "Account & Charges"
|
|
2641
|
+
}),
|
|
2642
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.Accordion, {
|
|
2643
|
+
variant: "unstyled",
|
|
2644
|
+
classNames: {
|
|
2645
|
+
root: '',
|
|
2646
|
+
control: 'p-0 px-2',
|
|
2647
|
+
label: 'p-0',
|
|
2648
|
+
chevron: 'text-accent',
|
|
2649
|
+
panel: 'p-0',
|
|
2650
|
+
content: 'p-0'
|
|
2651
|
+
},
|
|
2652
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(core.Accordion.Item, {
|
|
2653
|
+
value: "accountInformation",
|
|
2654
|
+
children: [
|
|
2655
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.Accordion.Control, {
|
|
2656
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(core.Text, {
|
|
2657
|
+
size: "sm",
|
|
2658
|
+
className: "font-black",
|
|
2659
|
+
children: [
|
|
2660
|
+
workspaceName,
|
|
2661
|
+
" - $",
|
|
2662
|
+
PaymentNumberToString(totalUsage)
|
|
2663
|
+
]
|
|
2664
|
+
})
|
|
2665
|
+
}),
|
|
2666
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.Accordion.Panel, {
|
|
2667
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(core.Radio.Group, {
|
|
2668
|
+
className: "pt-2",
|
|
2669
|
+
children: usersPayModels.map((obj)=>/*#__PURE__*/ jsxRuntime.jsx(core.Radio.Card, {
|
|
2670
|
+
checked: obj.currentPayModel,
|
|
2671
|
+
disabled: true,
|
|
2672
|
+
className: "p-2 border-none data-checked:bg-primary-lightest data-checked:border-primary-darker data-checked:font-black hover:bg-primary-max ",
|
|
2673
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs(core.Group, {
|
|
2674
|
+
wrap: "nowrap",
|
|
2675
|
+
align: "flex-start",
|
|
2676
|
+
children: [
|
|
2677
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.Text, {
|
|
2678
|
+
size: "sm",
|
|
2679
|
+
className: "grow",
|
|
2680
|
+
children: obj.label
|
|
2681
|
+
}),
|
|
2682
|
+
/*#__PURE__*/ jsxRuntime.jsxs(core.Text, {
|
|
2683
|
+
size: "sm",
|
|
2684
|
+
children: [
|
|
2685
|
+
"$",
|
|
2686
|
+
PaymentNumberToString(obj.totalUsage)
|
|
2687
|
+
]
|
|
2688
|
+
}),
|
|
2689
|
+
/*#__PURE__*/ jsxRuntime.jsx(core.Radio.Indicator, {
|
|
2690
|
+
color: "accent"
|
|
2691
|
+
})
|
|
2692
|
+
]
|
|
2693
|
+
})
|
|
2694
|
+
}, obj.value))
|
|
2695
|
+
})
|
|
2696
|
+
})
|
|
2697
|
+
]
|
|
2698
|
+
})
|
|
2699
|
+
})
|
|
2700
|
+
]
|
|
2701
|
+
})
|
|
2702
|
+
]
|
|
2703
|
+
});
|
|
2704
|
+
};
|
|
2705
|
+
|
|
2430
2706
|
const WorkspaceToolbar = /*#__PURE__*/ React.forwardRef(({ toolbarConfiguration }, ref)=>{
|
|
2431
2707
|
const workspaceTier = core$1.useCoreSelector((state)=>core$1.selectWorkspaceTier(state));
|
|
2432
2708
|
const workspaceStatus = core$1.useCoreSelector((state)=>core$1.selectJEGActiveWorkspaceStatus(state));
|
|
2433
2709
|
const isFullscreen = core$1.useCoreSelector((state)=>core$1.selectWorkspaceFullscreen(state));
|
|
2434
|
-
const { showStatus, showStop, tierLabel } = toolbarConfiguration || {};
|
|
2710
|
+
const { showStatus, showStop, tierLabel, requirePayModel, workspaceAccountManagerTarget } = toolbarConfiguration || {};
|
|
2435
2711
|
const coreDispatch = core$1.useCoreDispatch();
|
|
2436
2712
|
const toggleFullscreen = React.useCallback(()=>{
|
|
2437
2713
|
coreDispatch(core$1.setWorkspaceFullscreen(!isFullscreen));
|
|
@@ -2486,6 +2762,9 @@ const WorkspaceToolbar = /*#__PURE__*/ React.forwardRef(({ toolbarConfiguration
|
|
|
2486
2762
|
/*#__PURE__*/ jsxRuntime.jsx(core.Badge, {
|
|
2487
2763
|
"aria-label": `Workspace tier: ${tierLabel ?? workspaceTier}`,
|
|
2488
2764
|
children: tierLabel ?? workspaceTier
|
|
2765
|
+
}),
|
|
2766
|
+
requirePayModel && /*#__PURE__*/ jsxRuntime.jsx(CostTracker, {
|
|
2767
|
+
workspaceAccountManagerTarget: workspaceAccountManagerTarget
|
|
2489
2768
|
})
|
|
2490
2769
|
]
|
|
2491
2770
|
})
|