@seliseblocks/genesis-os 4.3.9 → 4.4.1
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/dist/{chunk-BQLKADRZ.js → chunk-5WYC4OLV.js} +241 -63
- package/dist/chunk-5WYC4OLV.js.map +1 -0
- package/dist/{chunk-GACXFCNQ.cjs → chunk-GFGUKRBD.cjs} +324 -146
- package/dist/chunk-GFGUKRBD.cjs.map +1 -0
- package/dist/{chunk-QN6HLQ67.cjs → chunk-HBVSAOTQ.cjs} +53 -38
- package/dist/chunk-HBVSAOTQ.cjs.map +1 -0
- package/dist/{chunk-LNQUCEQU.js → chunk-SAY5K2GJ.js} +25 -11
- package/dist/chunk-SAY5K2GJ.js.map +1 -0
- package/dist/{chunk-46ZGVJEX.js → chunk-SG6FH72W.js} +69 -5
- package/dist/chunk-SG6FH72W.js.map +1 -0
- package/dist/{chunk-4QKE3WAW.cjs → chunk-VAWEXEJZ.cjs} +73 -4
- package/dist/chunk-VAWEXEJZ.cjs.map +1 -0
- package/dist/components/index.cjs +342 -342
- package/dist/components/index.js +3 -3
- package/dist/guards/index.cjs +9 -9
- package/dist/guards/index.js +3 -3
- package/dist/hooks/index.cjs +58 -54
- package/dist/hooks/index.d.cts +12 -1
- package/dist/hooks/index.d.ts +12 -1
- package/dist/hooks/index.js +2 -2
- package/dist/index.cjs +452 -428
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/layouts/index.cjs +10 -10
- package/dist/layouts/index.js +3 -3
- package/dist/lib/index.cjs +37 -17
- package/dist/lib/index.d.cts +44 -3
- package/dist/lib/index.d.ts +44 -3
- package/dist/lib/index.js +1 -1
- package/dist/pages/index.cjs +8 -8
- package/dist/pages/index.js +3 -3
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-46ZGVJEX.js.map +0 -1
- package/dist/chunk-4QKE3WAW.cjs.map +0 -1
- package/dist/chunk-BQLKADRZ.js.map +0 -1
- package/dist/chunk-GACXFCNQ.cjs.map +0 -1
- package/dist/chunk-LNQUCEQU.js.map +0 -1
- package/dist/chunk-QN6HLQ67.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { refractor } from './chunk-FGY7QM3Y.js';
|
|
2
|
-
import { useKeyboardShortcut, usePopoverWidth, useBlocksAppConfigStore, useTheme, useLogout, useGetMyOrganizations, useLanguageSwitcher, useGetBlocksNotificationConfig,
|
|
2
|
+
import { notificationService, useKeyboardShortcut, usePopoverWidth, useBlocksAppConfigStore, useTheme, useLogout, useGetMyOrganizations, useLanguageSwitcher, useGetBlocksNotificationConfig, useLogo, useStartImpersonation, useGetProjects, useGetProject, useImpersonationStatusChecker, useStopImpersonation, useRecordClaimedTenant, useLogin, useSignUpAffordance, useSignUpRedirect, useInitiateRedirect, useGetEnvRepositories, useUpdateTenantGroup, useIcon, useDisableProject, projectService, initiateService, useGetNotifications, useMarkAsRead, useMarkAllAsRead, useDebouncedFuseFilter, useUpdateRepositories, usePrefetchRedirect } from './chunk-SAY5K2GJ.js';
|
|
3
3
|
import { showErrorToast, createStorage, getForwardedToPath, debounce, formatFullDate, formatDate, deepEqual, showSuccessToast, isErrorWithErrors, getServiceBaseUrl, getServiceSwaggerUrl } from './chunk-JSXAKNHQ.js';
|
|
4
|
-
import { fadeTransition, fadeInUp, staggerContainer, staggerItem, fadeInScale,
|
|
4
|
+
import { fadeTransition, fadeInUp, staggerContainer, staggerItem, fadeInScale, subscribeToTenantClaims, holdTenant, iamClient, AUTH_ENDPOINTS, claimTenant, readCurrentOwner, TAB_ID, isTenantHeldElsewhere, isSameClaim, PROFILE_ENDPOINTS } from './chunk-SG6FH72W.js';
|
|
5
5
|
import { getRuntimeEnv, HttpError } from './chunk-JUVLHPQI.js';
|
|
6
6
|
import { defaultRightSidePanelContextValue, RightSidePanelContext, SidebarContext, DashboardLayoutProvider } from './chunk-XRAO7JBH.js';
|
|
7
7
|
import { useIsMobile, useIsActiveMenu, useFilteredMenus } from './chunk-AHCHUUXM.js';
|
|
@@ -58,7 +58,7 @@ import * as ResizablePrimitive from 'react-resizable-panels';
|
|
|
58
58
|
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
59
59
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
60
60
|
import { useNavigate, Link, useLocation, useParams, Navigate, Outlet, useSearchParams } from 'react-router';
|
|
61
|
-
import { useQueryClient, useQuery } from '@tanstack/react-query';
|
|
61
|
+
import { useQueryClient, useQueries, useQuery } from '@tanstack/react-query';
|
|
62
62
|
import { HubConnectionBuilder, HttpTransportType } from '@microsoft/signalr';
|
|
63
63
|
import { createColumnHelper, flexRender, useReactTable, getCoreRowModel } from '@tanstack/react-table';
|
|
64
64
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
@@ -6430,7 +6430,12 @@ var AppTile = ({
|
|
|
6430
6430
|
{
|
|
6431
6431
|
href: isLoading ? void 0 : app.initiateUrl,
|
|
6432
6432
|
"aria-disabled": isLoading,
|
|
6433
|
-
onClick: isLoading ? (e) => e.preventDefault() :
|
|
6433
|
+
onClick: isLoading ? (e) => e.preventDefault() : app.markUsed,
|
|
6434
|
+
onAuxClick: (e) => {
|
|
6435
|
+
if (!isLoading && e.button === 1) app.markUsed();
|
|
6436
|
+
},
|
|
6437
|
+
onContextMenu: isLoading ? void 0 : app.markUsed,
|
|
6438
|
+
onDragStart: isLoading ? void 0 : app.markUsed,
|
|
6434
6439
|
className: cn(
|
|
6435
6440
|
"hover:bg-accent focus-visible:ring-ring group flex flex-col items-center gap-2 rounded-xl p-3 text-center transition-colors focus-visible:outline-none focus-visible:ring-2",
|
|
6436
6441
|
isLoading && "pointer-events-none opacity-50 cursor-default"
|
|
@@ -6621,45 +6626,66 @@ var filteredAppSwitcherData = APP_SWITCHER_DATA.filter((app) => {
|
|
|
6621
6626
|
if (!isAppAllowed(app)) return false;
|
|
6622
6627
|
return typeof app.isDisabled === "function" ? !app.isDisabled() : !app.isDisabled;
|
|
6623
6628
|
});
|
|
6629
|
+
var INITIATE_URL_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
6630
|
+
var initiateQueryKey = (clientId, redirectUri, forwardedTo) => ["idp-initiate", clientId, redirectUri, forwardedTo];
|
|
6624
6631
|
function useAppRedirectUrls({
|
|
6625
6632
|
open,
|
|
6626
6633
|
apps,
|
|
6627
6634
|
resolveForwardedTo
|
|
6628
6635
|
}) {
|
|
6629
|
-
const
|
|
6630
|
-
const
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
})
|
|
6645
|
-
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6636
|
+
const queryClient = useQueryClient();
|
|
6637
|
+
const requests = apps.map((app) => {
|
|
6638
|
+
const clientId = getRuntimeEnv(app.clientId);
|
|
6639
|
+
const redirectUri = getRuntimeEnv(app.redirectUri);
|
|
6640
|
+
const forwardedTo = resolveForwardedTo(app);
|
|
6641
|
+
return {
|
|
6642
|
+
app,
|
|
6643
|
+
clientId,
|
|
6644
|
+
redirectUri,
|
|
6645
|
+
forwardedTo,
|
|
6646
|
+
queryKey: initiateQueryKey(clientId, redirectUri, forwardedTo)
|
|
6647
|
+
};
|
|
6648
|
+
});
|
|
6649
|
+
const results = useQueries({
|
|
6650
|
+
queries: requests.map(
|
|
6651
|
+
({ clientId, redirectUri, forwardedTo, queryKey }) => ({
|
|
6652
|
+
queryKey,
|
|
6653
|
+
queryFn: ({ signal }) => initiateService.fetchRedirectUrl(
|
|
6654
|
+
{ clientId, redirectUri, forwardedTo },
|
|
6655
|
+
signal
|
|
6656
|
+
),
|
|
6657
|
+
enabled: open,
|
|
6658
|
+
staleTime: INITIATE_URL_MAX_AGE_MS,
|
|
6659
|
+
gcTime: INITIATE_URL_MAX_AGE_MS,
|
|
6660
|
+
// Replace a URL as it ages out while the popover stays open, rather than leaving the tile on
|
|
6661
|
+
// "Loading…" until it is reopened.
|
|
6662
|
+
refetchInterval: INITIATE_URL_MAX_AGE_MS,
|
|
6663
|
+
refetchOnWindowFocus: false,
|
|
6664
|
+
refetchOnReconnect: false,
|
|
6665
|
+
retry: false
|
|
6666
|
+
})
|
|
6667
|
+
)
|
|
6668
|
+
});
|
|
6669
|
+
const markUsed = useCallback(
|
|
6670
|
+
(queryKey) => {
|
|
6671
|
+
setTimeout(() => {
|
|
6672
|
+
void queryClient.resetQueries({ queryKey, exact: true });
|
|
6673
|
+
}, 0);
|
|
6674
|
+
},
|
|
6675
|
+
[queryClient]
|
|
6676
|
+
);
|
|
6677
|
+
if (!open || apps.length === 0) return [];
|
|
6678
|
+
const now = Date.now();
|
|
6679
|
+
return requests.map(({ app, queryKey }, index) => {
|
|
6680
|
+
const result = results[index];
|
|
6681
|
+
const url = result?.data && now - result.dataUpdatedAt < INITIATE_URL_MAX_AGE_MS ? result.data : void 0;
|
|
6682
|
+
return {
|
|
6683
|
+
...app,
|
|
6684
|
+
initiateUrl: url ?? app.initiateUrl,
|
|
6685
|
+
isLoading: !url,
|
|
6686
|
+
markUsed: () => markUsed(queryKey)
|
|
6687
|
+
};
|
|
6688
|
+
});
|
|
6663
6689
|
}
|
|
6664
6690
|
var AppSwitcher = ({ forwardedTo }) => {
|
|
6665
6691
|
const [open, setOpen] = useState(false);
|
|
@@ -7014,8 +7040,24 @@ function Logo({
|
|
|
7014
7040
|
] });
|
|
7015
7041
|
}
|
|
7016
7042
|
var logicOrigin = () => getRuntimeEnv("BLOCKS_LOGIC_BASE_URL").trim().replace(/\/$/, "");
|
|
7043
|
+
var RETRY_DELAYS_MS = [2e3, 5e3, 15e3, 3e4];
|
|
7044
|
+
var STEADY_RETRY_MS = 6e4;
|
|
7045
|
+
var isLoggedOut = (error) => error?.status === 401;
|
|
7046
|
+
var hasHttpStatus = (error) => typeof error?.status === "number";
|
|
7047
|
+
var refreshLoginCall = async (probe) => {
|
|
7048
|
+
try {
|
|
7049
|
+
await probe;
|
|
7050
|
+
} catch (error) {
|
|
7051
|
+
if (isLoggedOut(error) || !hasHttpStatus(error)) throw error;
|
|
7052
|
+
}
|
|
7053
|
+
};
|
|
7017
7054
|
var NotificationListenerService = class {
|
|
7018
7055
|
connection;
|
|
7056
|
+
// True from connect() until disconnect(): the app wants the hub up.
|
|
7057
|
+
wanted = false;
|
|
7058
|
+
attempt = 0;
|
|
7059
|
+
timer;
|
|
7060
|
+
inFlight;
|
|
7019
7061
|
constructor() {
|
|
7020
7062
|
this.connection = new HubConnectionBuilder().withUrl(
|
|
7021
7063
|
`${logicOrigin()}/api/NotificationHub?x-blocks-key=${getRuntimeEnv("BLOCKS_X_BLOCKS_KEY")}`,
|
|
@@ -7023,17 +7065,72 @@ var NotificationListenerService = class {
|
|
|
7023
7065
|
transport: HttpTransportType.WebSockets
|
|
7024
7066
|
}
|
|
7025
7067
|
).withAutomaticReconnect().build();
|
|
7068
|
+
this.connection.onclose(() => {
|
|
7069
|
+
if (this.wanted) this.recover(true);
|
|
7070
|
+
});
|
|
7026
7071
|
}
|
|
7027
7072
|
async connect() {
|
|
7028
|
-
if (this.
|
|
7029
|
-
|
|
7073
|
+
if (!this.wanted) {
|
|
7074
|
+
this.wanted = true;
|
|
7075
|
+
this.attempt = 0;
|
|
7076
|
+
globalThis.addEventListener("online", this.onWake);
|
|
7077
|
+
document.addEventListener("visibilitychange", this.onVisibility);
|
|
7030
7078
|
}
|
|
7079
|
+
if (this.timer === void 0) await this.recover(false);
|
|
7031
7080
|
}
|
|
7032
7081
|
async disconnect() {
|
|
7082
|
+
this.wanted = false;
|
|
7083
|
+
this.stopWatching();
|
|
7033
7084
|
if (this.connection.state !== "Disconnected") {
|
|
7034
7085
|
await this.connection.stop();
|
|
7035
7086
|
}
|
|
7036
7087
|
}
|
|
7088
|
+
onWake = () => {
|
|
7089
|
+
if (this.wanted) this.recover(true);
|
|
7090
|
+
};
|
|
7091
|
+
onVisibility = () => {
|
|
7092
|
+
if (document.visibilityState === "visible") this.onWake();
|
|
7093
|
+
};
|
|
7094
|
+
stopWatching() {
|
|
7095
|
+
clearTimeout(this.timer);
|
|
7096
|
+
this.timer = void 0;
|
|
7097
|
+
globalThis.removeEventListener("online", this.onWake);
|
|
7098
|
+
document.removeEventListener("visibilitychange", this.onVisibility);
|
|
7099
|
+
}
|
|
7100
|
+
// Never two starts at once: callers share the run that is already going.
|
|
7101
|
+
recover(refreshLogin) {
|
|
7102
|
+
this.inFlight ??= this.tryStart(refreshLogin).finally(() => {
|
|
7103
|
+
this.inFlight = void 0;
|
|
7104
|
+
});
|
|
7105
|
+
return this.inFlight;
|
|
7106
|
+
}
|
|
7107
|
+
async tryStart(refreshLogin) {
|
|
7108
|
+
clearTimeout(this.timer);
|
|
7109
|
+
this.timer = void 0;
|
|
7110
|
+
if (!this.wanted || this.connection.state !== "Disconnected") return;
|
|
7111
|
+
if (refreshLogin && navigator.onLine === false) return;
|
|
7112
|
+
try {
|
|
7113
|
+
if (refreshLogin)
|
|
7114
|
+
await refreshLoginCall(notificationService.getNotifications(1, 1));
|
|
7115
|
+
if (!this.wanted) return;
|
|
7116
|
+
await this.connection.start();
|
|
7117
|
+
this.attempt = 0;
|
|
7118
|
+
if (!this.wanted) await this.connection.stop();
|
|
7119
|
+
} catch (error) {
|
|
7120
|
+
if (!this.wanted) return;
|
|
7121
|
+
if (isLoggedOut(error)) {
|
|
7122
|
+
this.wanted = false;
|
|
7123
|
+
this.stopWatching();
|
|
7124
|
+
return;
|
|
7125
|
+
}
|
|
7126
|
+
this.scheduleRetry();
|
|
7127
|
+
}
|
|
7128
|
+
}
|
|
7129
|
+
scheduleRetry() {
|
|
7130
|
+
const delay = RETRY_DELAYS_MS[this.attempt] ?? STEADY_RETRY_MS;
|
|
7131
|
+
this.attempt += 1;
|
|
7132
|
+
this.timer = setTimeout(() => this.recover(true), delay);
|
|
7133
|
+
}
|
|
7037
7134
|
};
|
|
7038
7135
|
var notificationListenerService = new NotificationListenerService();
|
|
7039
7136
|
|
|
@@ -7798,6 +7895,42 @@ var AppLoadingSpinner = ({ size = 64 }) => /* @__PURE__ */ jsxs(Fragment, { chil
|
|
|
7798
7895
|
/* @__PURE__ */ jsx("div", { className: "bg-background fixed inset-0 z-50 flex items-center justify-center", children: /* @__PURE__ */ jsx("div", { className: "animate-breathe", children: /* @__PURE__ */ jsx(BlocksIcon, { size }) }) })
|
|
7799
7896
|
] });
|
|
7800
7897
|
var projectNameFor = (projects, tenantId) => tenantId && projects.find((p) => p.tenantId === tenantId)?.name || null;
|
|
7898
|
+
var claimKeyOf = (claim) => claim ? `${claim.tabId}|${claim.tenantId}|${claim.ts}` : null;
|
|
7899
|
+
var useLiveOwnerProbe = ({
|
|
7900
|
+
cookieTenantId,
|
|
7901
|
+
ownTenantId,
|
|
7902
|
+
onHeldElsewhere
|
|
7903
|
+
}) => {
|
|
7904
|
+
const foreignClaim = useMemo(() => {
|
|
7905
|
+
if (!cookieTenantId || !ownTenantId || cookieTenantId === ownTenantId) {
|
|
7906
|
+
return null;
|
|
7907
|
+
}
|
|
7908
|
+
const owner = readCurrentOwner();
|
|
7909
|
+
return owner && owner.tabId !== TAB_ID && owner.tenantId === cookieTenantId ? owner : null;
|
|
7910
|
+
}, [cookieTenantId, ownTenantId]);
|
|
7911
|
+
const claimKey = claimKeyOf(foreignClaim);
|
|
7912
|
+
const [probedKey, setProbedKey] = useState(null);
|
|
7913
|
+
const foreignClaimRef = useRef(foreignClaim);
|
|
7914
|
+
const onHeldElsewhereRef = useRef(onHeldElsewhere);
|
|
7915
|
+
foreignClaimRef.current = foreignClaim;
|
|
7916
|
+
onHeldElsewhereRef.current = onHeldElsewhere;
|
|
7917
|
+
useEffect(() => {
|
|
7918
|
+
const claim = foreignClaimRef.current;
|
|
7919
|
+
if (!claim || !claimKey) return;
|
|
7920
|
+
let cancelled = false;
|
|
7921
|
+
void isTenantHeldElsewhere(claim.tenantId).then((held) => {
|
|
7922
|
+
if (cancelled) return;
|
|
7923
|
+
if (held && isSameClaim(readCurrentOwner(), claim)) {
|
|
7924
|
+
onHeldElsewhereRef.current(claim.tenantId);
|
|
7925
|
+
}
|
|
7926
|
+
setProbedKey(claimKey);
|
|
7927
|
+
});
|
|
7928
|
+
return () => {
|
|
7929
|
+
cancelled = true;
|
|
7930
|
+
};
|
|
7931
|
+
}, [claimKey]);
|
|
7932
|
+
return !!claimKey && probedKey !== claimKey;
|
|
7933
|
+
};
|
|
7801
7934
|
var ImpersonationChecker = ({
|
|
7802
7935
|
children
|
|
7803
7936
|
}) => {
|
|
@@ -7853,32 +7986,41 @@ function ImpersonationTerminator({
|
|
|
7853
7986
|
const {
|
|
7854
7987
|
terminate,
|
|
7855
7988
|
isImpersonated,
|
|
7989
|
+
impersonatedTenantId,
|
|
7856
7990
|
detachedReason,
|
|
7857
7991
|
detachedTenantId,
|
|
7858
7992
|
setDetached
|
|
7859
7993
|
} = useImpersonateStore();
|
|
7860
7994
|
const { mutateAsync } = useStopImpersonation();
|
|
7995
|
+
const recordClaimedTenant = useRecordClaimedTenant();
|
|
7861
7996
|
const { projects } = useProjectStore();
|
|
7862
7997
|
const isTriggering = useRef(false);
|
|
7863
7998
|
const [isTerminating, setIsTerminating] = useState(false);
|
|
7864
7999
|
const rootTenantId = window.process?.env.BLOCKS_X_BLOCKS_KEY || "";
|
|
8000
|
+
const isProbingOwner = useLiveOwnerProbe({
|
|
8001
|
+
cookieTenantId: isImpersonated ? impersonatedTenantId : null,
|
|
8002
|
+
ownTenantId: rootTenantId || null,
|
|
8003
|
+
onHeldElsewhere: (tenantId) => setDetached("another-project", tenantId)
|
|
8004
|
+
});
|
|
7865
8005
|
useEffect(() => {
|
|
7866
8006
|
if (!rootTenantId) return;
|
|
7867
|
-
const owner = readCurrentOwner();
|
|
7868
|
-
if (owner && owner.tabId !== TAB_ID && owner.tenantId !== rootTenantId) {
|
|
7869
|
-
setDetached("another-project", owner.tenantId);
|
|
7870
|
-
}
|
|
7871
8007
|
return subscribeToTenantClaims((claim) => {
|
|
8008
|
+
recordClaimedTenant(claim.tenantId, rootTenantId);
|
|
7872
8009
|
if (claim.tenantId === rootTenantId) {
|
|
7873
8010
|
setDetached(null);
|
|
7874
8011
|
return;
|
|
7875
8012
|
}
|
|
7876
8013
|
setDetached("another-project", claim.tenantId);
|
|
7877
8014
|
});
|
|
7878
|
-
}, [rootTenantId, setDetached]);
|
|
8015
|
+
}, [rootTenantId, setDetached, recordClaimedTenant]);
|
|
8016
|
+
const isDetached = detachedReason === "another-project";
|
|
8017
|
+
useEffect(() => {
|
|
8018
|
+
if (detachedReason === "console") setDetached(null);
|
|
8019
|
+
}, [detachedReason, setDetached]);
|
|
7879
8020
|
useEffect(() => {
|
|
7880
8021
|
if (isTriggering.current || !isImpersonated) return;
|
|
7881
|
-
if (
|
|
8022
|
+
if (isDetached) return;
|
|
8023
|
+
if (isProbingOwner) return;
|
|
7882
8024
|
isTriggering.current = true;
|
|
7883
8025
|
setIsTerminating(true);
|
|
7884
8026
|
const stopImpersonation = async () => {
|
|
@@ -7899,8 +8041,15 @@ function ImpersonationTerminator({
|
|
|
7899
8041
|
}
|
|
7900
8042
|
};
|
|
7901
8043
|
void stopImpersonation();
|
|
7902
|
-
}, [
|
|
7903
|
-
|
|
8044
|
+
}, [
|
|
8045
|
+
mutateAsync,
|
|
8046
|
+
terminate,
|
|
8047
|
+
isImpersonated,
|
|
8048
|
+
isDetached,
|
|
8049
|
+
isProbingOwner,
|
|
8050
|
+
rootTenantId
|
|
8051
|
+
]);
|
|
8052
|
+
if (isDetached) {
|
|
7904
8053
|
const name = projectNameFor(projects, detachedTenantId);
|
|
7905
8054
|
return /* @__PURE__ */ jsx(
|
|
7906
8055
|
ImpersonationBlocked,
|
|
@@ -7932,6 +8081,7 @@ function ImpersonationSynchronizer({
|
|
|
7932
8081
|
setDetached
|
|
7933
8082
|
} = useImpersonateStore();
|
|
7934
8083
|
const { mutateAsync } = useStartImpersonation();
|
|
8084
|
+
const recordClaimedTenant = useRecordClaimedTenant();
|
|
7935
8085
|
const { data: _data } = useGetProjects({ enabled: true });
|
|
7936
8086
|
const { selectedProject, setSelectedProject, projects, setTenantGroup } = useProjectStore();
|
|
7937
8087
|
const isTriggering = useRef(false);
|
|
@@ -8016,15 +8166,23 @@ function ImpersonationSynchronizer({
|
|
|
8016
8166
|
setDetached(null);
|
|
8017
8167
|
void runImpersonation();
|
|
8018
8168
|
}, [runImpersonation, setImpersonationError, setDetached]);
|
|
8169
|
+
const detachedHere = detachedReason === "another-project" && detachedTenantId === routeTenantId ? null : detachedReason;
|
|
8170
|
+
useEffect(() => {
|
|
8171
|
+
if (detachedReason && detachedReason !== detachedHere) setDetached(null);
|
|
8172
|
+
}, [detachedReason, detachedHere, setDetached]);
|
|
8173
|
+
const isProbingOwner = useLiveOwnerProbe({
|
|
8174
|
+
cookieTenantId: impersonatedTenantId,
|
|
8175
|
+
ownTenantId: routeTenantId,
|
|
8176
|
+
onHeldElsewhere: (tenantId) => setDetached("another-project", tenantId)
|
|
8177
|
+
});
|
|
8178
|
+
const isAttached = !!routeTenantId && routeTenantId === impersonatedTenantId && !detachedHere && !impersonationError && !isProbingOwner;
|
|
8179
|
+
useEffect(() => {
|
|
8180
|
+
if (!isAttached || !routeTenantId) return;
|
|
8181
|
+
return holdTenant(routeTenantId);
|
|
8182
|
+
}, [isAttached, routeTenantId]);
|
|
8019
8183
|
useEffect(() => {
|
|
8020
|
-
const owner = readCurrentOwner();
|
|
8021
|
-
if (owner && owner.tabId !== TAB_ID && routeTenantId && owner.tenantId !== routeTenantId) {
|
|
8022
|
-
setDetached(
|
|
8023
|
-
owner.tenantId === rootTenantId ? "console" : "another-project",
|
|
8024
|
-
owner.tenantId
|
|
8025
|
-
);
|
|
8026
|
-
}
|
|
8027
8184
|
return subscribeToTenantClaims((claim) => {
|
|
8185
|
+
recordClaimedTenant(claim.tenantId, rootTenantId);
|
|
8028
8186
|
const mine = routeTenantIdRef.current;
|
|
8029
8187
|
if (!mine) return;
|
|
8030
8188
|
if (claim.tenantId === mine) {
|
|
@@ -8036,11 +8194,12 @@ function ImpersonationSynchronizer({
|
|
|
8036
8194
|
claim.tenantId
|
|
8037
8195
|
);
|
|
8038
8196
|
});
|
|
8039
|
-
}, [routeTenantId, rootTenantId, setDetached]);
|
|
8197
|
+
}, [routeTenantId, rootTenantId, setDetached, recordClaimedTenant]);
|
|
8040
8198
|
useEffect(() => {
|
|
8041
8199
|
if (!itemId) return;
|
|
8042
8200
|
if (isTriggering.current) return;
|
|
8043
|
-
if (impersonationError ||
|
|
8201
|
+
if (impersonationError || detachedHere) return;
|
|
8202
|
+
if (isProbingOwner) return;
|
|
8044
8203
|
const needsColdStart = !routeTenantId && !!impersonatedTenantId && !selectedProject;
|
|
8045
8204
|
const needsRetarget = !!routeTenantId && routeTenantId !== impersonatedTenantId;
|
|
8046
8205
|
if (!needsColdStart && !needsRetarget) return;
|
|
@@ -8051,7 +8210,8 @@ function ImpersonationSynchronizer({
|
|
|
8051
8210
|
impersonatedTenantId,
|
|
8052
8211
|
selectedProject,
|
|
8053
8212
|
impersonationError,
|
|
8054
|
-
|
|
8213
|
+
detachedHere,
|
|
8214
|
+
isProbingOwner,
|
|
8055
8215
|
runImpersonation
|
|
8056
8216
|
]);
|
|
8057
8217
|
const thisProjectName = projectNameFor(projects, routeTenantId);
|
|
@@ -8067,6 +8227,14 @@ function ImpersonationSynchronizer({
|
|
|
8067
8227
|
if (!isImpersonated || isTriggering.current) return null;
|
|
8068
8228
|
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
8069
8229
|
}
|
|
8230
|
+
if (isProbingOwner && !detachedHere) {
|
|
8231
|
+
return /* @__PURE__ */ jsx(
|
|
8232
|
+
ImpersonationWaiting,
|
|
8233
|
+
{
|
|
8234
|
+
label: thisProjectName ? `Opening ${thisProjectName}\u2026` : "Opening project\u2026"
|
|
8235
|
+
}
|
|
8236
|
+
);
|
|
8237
|
+
}
|
|
8070
8238
|
if (impersonationError) {
|
|
8071
8239
|
const accessDenied = impersonationError instanceof HttpError && impersonationError.status === 403;
|
|
8072
8240
|
return accessDenied ? /* @__PURE__ */ jsx(
|
|
@@ -8087,7 +8255,7 @@ function ImpersonationSynchronizer({
|
|
|
8087
8255
|
}
|
|
8088
8256
|
);
|
|
8089
8257
|
}
|
|
8090
|
-
if (
|
|
8258
|
+
if (detachedHere === "console") {
|
|
8091
8259
|
return /* @__PURE__ */ jsx(
|
|
8092
8260
|
ImpersonationBlocked,
|
|
8093
8261
|
{
|
|
@@ -8099,7 +8267,7 @@ function ImpersonationSynchronizer({
|
|
|
8099
8267
|
}
|
|
8100
8268
|
);
|
|
8101
8269
|
}
|
|
8102
|
-
if (
|
|
8270
|
+
if (detachedHere === "another-project") {
|
|
8103
8271
|
const otherName = projectNameFor(projects, detachedTenantId);
|
|
8104
8272
|
return /* @__PURE__ */ jsx(
|
|
8105
8273
|
ImpersonationBlocked,
|
|
@@ -10543,6 +10711,16 @@ var ConsolePage = ({ canCreateProject = false }) => {
|
|
|
10543
10711
|
] })
|
|
10544
10712
|
] });
|
|
10545
10713
|
};
|
|
10714
|
+
var toSafeAppPath = (value) => {
|
|
10715
|
+
if (!value || !value.startsWith("/")) return null;
|
|
10716
|
+
try {
|
|
10717
|
+
const target = new URL(value, window.location.origin);
|
|
10718
|
+
if (target.origin !== window.location.origin) return null;
|
|
10719
|
+
return target.href;
|
|
10720
|
+
} catch {
|
|
10721
|
+
return null;
|
|
10722
|
+
}
|
|
10723
|
+
};
|
|
10546
10724
|
var CallbackPage = ({ defaultRedirectUrl }) => {
|
|
10547
10725
|
const [searchParams] = useSearchParams();
|
|
10548
10726
|
const hasProcessed = useRef(false);
|
|
@@ -10558,7 +10736,7 @@ var CallbackPage = ({ defaultRedirectUrl }) => {
|
|
|
10558
10736
|
const idpBaseUrl = window.process?.env.userBaseUrl;
|
|
10559
10737
|
const callbackUrl = new URL(`${idpBaseUrl}/api/idp/callback`);
|
|
10560
10738
|
const tenantId = window.process?.env.BLOCKS_X_BLOCKS_KEY;
|
|
10561
|
-
const appRedirectUrl = forwardTo || defaultRedirectUrl || "/";
|
|
10739
|
+
const appRedirectUrl = toSafeAppPath(forwardTo) || defaultRedirectUrl || "/";
|
|
10562
10740
|
if (code) callbackUrl.searchParams.set("code", code);
|
|
10563
10741
|
if (state) callbackUrl.searchParams.set("state", state);
|
|
10564
10742
|
if (error) callbackUrl.searchParams.set("error", error);
|
|
@@ -13330,5 +13508,5 @@ var TablePagination2 = React8.forwardRef(
|
|
|
13330
13508
|
TablePagination2.displayName = "TablePagination";
|
|
13331
13509
|
|
|
13332
13510
|
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppLoadingSpinner, AppSwitcher, ArchiveProject, AspectRatio, AuthLayout, AuthResolver, Avatar, AvatarFallback, AvatarImage, BackToConsoleNavigator, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, CallbackPage, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ConfirmationModal, ConsoleHeader, ConsoleLayout, ConsolePage, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, CopyToClipboardButton, CopyableSnippet, DEFAULT_KANBAN_COLUMNS, DashboardHeader, DashboardLayout, DashboardOverview, DashboardRoute, DashboardSectionCard, DataTable, DataTableHeaderCell, DateRangePicker, DesktopMenuItem, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditProject, EditProjectDialog, EditProjectForm, EnvironmentCard, EnvironmentList, ErrorBoundary, ErrorDisplay, ErrorDisplayWithCard, FileInput, FileUploader, FileUploaderContent, FileUploaderItem, FilterControls, FilterToolBarMobileView, FilterToolbar, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, HoverCard, HoverCardContent, HoverCardTrigger, ImpersonationChecker, ImpersonationSynchronizer, ImpersonationTerminator, ImportFileModalContent, InfiniteScroll, InfiniteScroller, InfoTooltip, Input, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, KanbanBoard, KanbanBoardColumn, KanbanBoardContainer, KanbanTaskCard, Label, LanguageSelector, LoadingButton, LoginPage, Logo, MaskedText, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, MobileMenuItem, MultiSelect, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Notification, OidcLayout, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, PasswordInput, Popover, PopoverContent, PopoverTrigger, ProfilePage, Progress, ProjectActions, ProjectCardLoadingSkeleton, ProjectDetail, ProjectList2 as ProjectList, ProjectListRowLoadingSkeleton, ProjectOverview, ProjectRepoList, ProtectedGuard, PublicGuard, PublicLayout, RadioGroup4 as RadioGroup, RadioGroupItem, RenderAlternatively, RenderConditionally, ResizableHandle, ResizablePanel, ResizablePanelGroup, RightSidePanel, RightSidePanelBody, RightSidePanelClose, RightSidePanelDescription, RightSidePanelFooter, RightSidePanelHeader, RightSidePanelProvider, RightSidePanelTitle, RightSidePanelTrigger, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SelectedEnvironment, SelectedProject, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Sidebar, SidebarCollapsedTooltip, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuDesktop, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarMobileView, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Spinner, Stepper, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableLoadingSkeleton, TablePagination2 as TablePagination, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeSwitcher, Timeline, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, UserDropdownMenu, WizardHorizontalTrackBar, WizardStepContent, WizardStepIndicator, WizardStepViewport, WizardStepperProvider, WizardVerticalTrackBar, badgeVariants, buttonVariants, editProjectFormDefaultValues, editProjectFormSchema, filteredAppSwitcherData, hasDraggableData, kanbanKeyboardCoordinateGetter, navigationMenuTriggerStyle, paginationQueryParsers, sidebarCollapsedTooltipClass, sortQueryParsers, spinnerVariants, toggleVariants, useFileUpload, useFormField, useNotificationSocket, useOidcContext, usePaginationQueryParams, useRightSidePanel, useSortQueryParams, useWizardStepper };
|
|
13333
|
-
//# sourceMappingURL=chunk-
|
|
13334
|
-
//# sourceMappingURL=chunk-
|
|
13511
|
+
//# sourceMappingURL=chunk-5WYC4OLV.js.map
|
|
13512
|
+
//# sourceMappingURL=chunk-5WYC4OLV.js.map
|