@trackunit/react-core-hooks 0.2.188 → 0.2.190
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/index.cjs.js +39 -0
- package/index.esm.js +39 -1
- package/package.json +1 -1
- package/src/runtimes/useParamsRuntime.d.ts +22 -0
package/index.cjs.js
CHANGED
|
@@ -389,6 +389,44 @@ const useIrisAppName = () => {
|
|
|
389
389
|
}, []);
|
|
390
390
|
return { appName, loading, error };
|
|
391
391
|
};
|
|
392
|
+
/**
|
|
393
|
+
* A hook to expose irisAppId using ParamsRuntime's getAppName and getOrgName for React components
|
|
394
|
+
*
|
|
395
|
+
* @requires ParamsRuntime
|
|
396
|
+
* @returns {UseIrisAppId} irisAppId, loading, error
|
|
397
|
+
* @example
|
|
398
|
+
* import { useIrisAppName } from "@trackunit/react-core-hooks";
|
|
399
|
+
* const { irisAppId } = useIrisAppName();
|
|
400
|
+
* useEffect(() => {
|
|
401
|
+
* (async () => {
|
|
402
|
+
* if (irisAppId) {
|
|
403
|
+
* // do something with irisAppId
|
|
404
|
+
* }
|
|
405
|
+
* })();
|
|
406
|
+
* }, [irisAppId]);
|
|
407
|
+
*/
|
|
408
|
+
const useIrisAppId = () => {
|
|
409
|
+
const [irisAppId, setIrisAppId] = React.useState();
|
|
410
|
+
const [loading, setLoading] = React.useState(true);
|
|
411
|
+
const [error, setError] = React.useState();
|
|
412
|
+
React.useEffect(() => {
|
|
413
|
+
const getAppName = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
414
|
+
setLoading(true);
|
|
415
|
+
try {
|
|
416
|
+
const updatedAppName = yield irisAppRuntimeCore.ParamsRuntime.getAppName();
|
|
417
|
+
const updatedOrgName = yield irisAppRuntimeCore.ParamsRuntime.getOrgName();
|
|
418
|
+
setLoading(false);
|
|
419
|
+
setIrisAppId(`${updatedOrgName}/${updatedAppName}`);
|
|
420
|
+
}
|
|
421
|
+
catch (e) {
|
|
422
|
+
setLoading(false);
|
|
423
|
+
setError(new Error("Failed to get iris app name"));
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
getAppName();
|
|
427
|
+
}, []);
|
|
428
|
+
return { irisAppId, loading, error };
|
|
429
|
+
};
|
|
392
430
|
|
|
393
431
|
/**
|
|
394
432
|
* A hook to expose site runtime for React components
|
|
@@ -665,6 +703,7 @@ exports.useEnvironment = useEnvironment;
|
|
|
665
703
|
exports.useEventRuntime = useEventRuntime;
|
|
666
704
|
exports.useFilterBarContext = useFilterBarContext;
|
|
667
705
|
exports.useHasAccessTo = useHasAccessTo;
|
|
706
|
+
exports.useIrisAppId = useIrisAppId;
|
|
668
707
|
exports.useIrisAppName = useIrisAppName;
|
|
669
708
|
exports.useNavigateInHost = useNavigateInHost;
|
|
670
709
|
exports.useOemBrandingContext = useOemBrandingContext;
|
package/index.esm.js
CHANGED
|
@@ -366,6 +366,44 @@ const useIrisAppName = () => {
|
|
|
366
366
|
}, []);
|
|
367
367
|
return { appName, loading, error };
|
|
368
368
|
};
|
|
369
|
+
/**
|
|
370
|
+
* A hook to expose irisAppId using ParamsRuntime's getAppName and getOrgName for React components
|
|
371
|
+
*
|
|
372
|
+
* @requires ParamsRuntime
|
|
373
|
+
* @returns {UseIrisAppId} irisAppId, loading, error
|
|
374
|
+
* @example
|
|
375
|
+
* import { useIrisAppName } from "@trackunit/react-core-hooks";
|
|
376
|
+
* const { irisAppId } = useIrisAppName();
|
|
377
|
+
* useEffect(() => {
|
|
378
|
+
* (async () => {
|
|
379
|
+
* if (irisAppId) {
|
|
380
|
+
* // do something with irisAppId
|
|
381
|
+
* }
|
|
382
|
+
* })();
|
|
383
|
+
* }, [irisAppId]);
|
|
384
|
+
*/
|
|
385
|
+
const useIrisAppId = () => {
|
|
386
|
+
const [irisAppId, setIrisAppId] = useState();
|
|
387
|
+
const [loading, setLoading] = useState(true);
|
|
388
|
+
const [error, setError] = useState();
|
|
389
|
+
useEffect(() => {
|
|
390
|
+
const getAppName = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
391
|
+
setLoading(true);
|
|
392
|
+
try {
|
|
393
|
+
const updatedAppName = yield ParamsRuntime.getAppName();
|
|
394
|
+
const updatedOrgName = yield ParamsRuntime.getOrgName();
|
|
395
|
+
setLoading(false);
|
|
396
|
+
setIrisAppId(`${updatedOrgName}/${updatedAppName}`);
|
|
397
|
+
}
|
|
398
|
+
catch (e) {
|
|
399
|
+
setLoading(false);
|
|
400
|
+
setError(new Error("Failed to get iris app name"));
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
getAppName();
|
|
404
|
+
}, []);
|
|
405
|
+
return { irisAppId, loading, error };
|
|
406
|
+
};
|
|
369
407
|
|
|
370
408
|
/**
|
|
371
409
|
* A hook to expose site runtime for React components
|
|
@@ -617,4 +655,4 @@ const useCurrentUser = () => {
|
|
|
617
655
|
return context;
|
|
618
656
|
};
|
|
619
657
|
|
|
620
|
-
export { AnalyticsContext, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, CurrentUserPreferenceProvider, CurrentUserProvider, EnvironmentContextProvider, FilterBarProvider, NavigationContextProvider, OemBrandingContextProvider, ToastProvider, TokenProvider, UserSubscriptionProvider, useAnalytics, useAssetRuntime, useAssetSorting, useConfirmationDialog, useCurrentUser, useCurrentUserLanguage, useCurrentUserSystemOfMeasurement, useCurrentUserTimeZonePreference, useEnvironment, useEventRuntime, useFilterBarContext, useHasAccessTo, useIrisAppName, useNavigateInHost, useOemBrandingContext, useSiteRuntime, useTextSearch, useToast, useToken, useUserSubscription };
|
|
658
|
+
export { AnalyticsContext, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, CurrentUserPreferenceProvider, CurrentUserProvider, EnvironmentContextProvider, FilterBarProvider, NavigationContextProvider, OemBrandingContextProvider, ToastProvider, TokenProvider, UserSubscriptionProvider, useAnalytics, useAssetRuntime, useAssetSorting, useConfirmationDialog, useCurrentUser, useCurrentUserLanguage, useCurrentUserSystemOfMeasurement, useCurrentUserTimeZonePreference, useEnvironment, useEventRuntime, useFilterBarContext, useHasAccessTo, useIrisAppId, useIrisAppName, useNavigateInHost, useOemBrandingContext, useSiteRuntime, useTextSearch, useToast, useToken, useUserSubscription };
|
package/package.json
CHANGED
|
@@ -20,3 +20,25 @@ export interface UseIrisAppName {
|
|
|
20
20
|
* }, [appName]);
|
|
21
21
|
*/
|
|
22
22
|
export declare const useIrisAppName: () => UseIrisAppName;
|
|
23
|
+
export interface UseIrisAppId {
|
|
24
|
+
irisAppId: string | undefined;
|
|
25
|
+
loading: boolean;
|
|
26
|
+
error: Error | undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A hook to expose irisAppId using ParamsRuntime's getAppName and getOrgName for React components
|
|
30
|
+
*
|
|
31
|
+
* @requires ParamsRuntime
|
|
32
|
+
* @returns {UseIrisAppId} irisAppId, loading, error
|
|
33
|
+
* @example
|
|
34
|
+
* import { useIrisAppName } from "@trackunit/react-core-hooks";
|
|
35
|
+
* const { irisAppId } = useIrisAppName();
|
|
36
|
+
* useEffect(() => {
|
|
37
|
+
* (async () => {
|
|
38
|
+
* if (irisAppId) {
|
|
39
|
+
* // do something with irisAppId
|
|
40
|
+
* }
|
|
41
|
+
* })();
|
|
42
|
+
* }, [irisAppId]);
|
|
43
|
+
*/
|
|
44
|
+
export declare const useIrisAppId: () => UseIrisAppId;
|