@growth-operations/ui-shared 1.6.7 → 1.6.9
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/package.json
CHANGED
package/src/alerts/AlertsTab.jsx
CHANGED
|
@@ -64,6 +64,7 @@ function DefaultAlertRow({
|
|
|
64
64
|
context,
|
|
65
65
|
alert,
|
|
66
66
|
refresh,
|
|
67
|
+
onDismissed,
|
|
67
68
|
fetchOptions,
|
|
68
69
|
renderRowActions,
|
|
69
70
|
}) {
|
|
@@ -73,7 +74,9 @@ function DefaultAlertRow({
|
|
|
73
74
|
setDismissing(true);
|
|
74
75
|
try {
|
|
75
76
|
await dismissAlert(context, alert.id, fetchOptions);
|
|
76
|
-
|
|
77
|
+
// Optimistically drop just this row from local state — no full re-fetch
|
|
78
|
+
// of the whole alert list on every dismiss.
|
|
79
|
+
onDismissed(alert.id);
|
|
77
80
|
} finally {
|
|
78
81
|
setDismissing(false);
|
|
79
82
|
}
|
|
@@ -161,6 +164,14 @@ export function AlertsTab({
|
|
|
161
164
|
}
|
|
162
165
|
};
|
|
163
166
|
|
|
167
|
+
// Optimistically remove a dismissed alert from local state instead of
|
|
168
|
+
// re-fetching the whole list. Keeps the dismiss interaction to a single API
|
|
169
|
+
// call (the dismiss itself).
|
|
170
|
+
const removeAlertLocally = (id) => {
|
|
171
|
+
setAlerts((prev) => prev.filter((a) => a.id !== id));
|
|
172
|
+
setTotal((t) => Math.max(0, t - 1));
|
|
173
|
+
};
|
|
174
|
+
|
|
164
175
|
useEffect(() => {
|
|
165
176
|
load(1, level);
|
|
166
177
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -212,8 +223,12 @@ export function AlertsTab({
|
|
|
212
223
|
const refresh = () => load(page, level);
|
|
213
224
|
// Full-row override escape hatch: the app owns the cells.
|
|
214
225
|
if (renderRow) {
|
|
226
|
+
// Optimistic dismiss (drop the row locally); refresh stays
|
|
227
|
+
// available for apps that want a full reload.
|
|
215
228
|
const dismiss = () =>
|
|
216
|
-
dismissAlert(context, alert.id, fetchOptions).then(
|
|
229
|
+
dismissAlert(context, alert.id, fetchOptions).then(() =>
|
|
230
|
+
removeAlertLocally(alert.id)
|
|
231
|
+
);
|
|
217
232
|
return (
|
|
218
233
|
<React.Fragment key={alert.id}>
|
|
219
234
|
{renderRow(alert, {
|
|
@@ -232,6 +247,7 @@ export function AlertsTab({
|
|
|
232
247
|
alert={alert}
|
|
233
248
|
fetchOptions={fetchOptions}
|
|
234
249
|
refresh={refresh}
|
|
250
|
+
onDismissed={removeAlertLocally}
|
|
235
251
|
renderRowActions={renderRowActions}
|
|
236
252
|
/>
|
|
237
253
|
);
|
|
@@ -362,11 +362,16 @@ function CompedBilling() {
|
|
|
362
362
|
|
|
363
363
|
export function BillingTab({ context, state, appKey, openIframe = null }) {
|
|
364
364
|
const mode = state?.entitlement?.mode;
|
|
365
|
+
const isSuperAdmin = state?.user?.is_super_admin === true;
|
|
365
366
|
|
|
366
367
|
return (
|
|
367
368
|
<Flex direction="column" gap="medium">
|
|
368
369
|
<Heading>Billing</Heading>
|
|
369
|
-
{
|
|
370
|
+
{!isSuperAdmin ? (
|
|
371
|
+
<Alert variant="warning" title="Access restricted">
|
|
372
|
+
<Text>Billing settings are only available to super admins.</Text>
|
|
373
|
+
</Alert>
|
|
374
|
+
) : mode === "legacy" ? (
|
|
370
375
|
<LegacyBilling state={state} />
|
|
371
376
|
) : mode === "credits" ? (
|
|
372
377
|
<CreditsBilling context={context} state={state} appKey={appKey} openIframe={openIframe} />
|