@flightctl/ui-components 1.0.0-rc4 → 1.0.0-rc6
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/src/components/common/OrganizationGuard.d.ts +3 -0
- package/dist/src/components/common/OrganizationGuard.d.ts.map +1 -1
- package/dist/src/components/common/OrganizationGuard.js +70 -37
- package/dist/src/components/common/OrganizationGuard.js.map +1 -1
- package/dist/src/components/common/OrganizationSelector.d.ts.map +1 -1
- package/dist/src/components/common/OrganizationSelector.js +14 -4
- package/dist/src/components/common/OrganizationSelector.js.map +1 -1
- package/package.json +1 -1
- package/src/components/common/OrganizationGuard.tsx +76 -36
- package/src/components/common/OrganizationSelector.tsx +44 -10
|
@@ -6,6 +6,9 @@ interface OrganizationContextType {
|
|
|
6
6
|
mustShowOrganizationSelector: boolean;
|
|
7
7
|
selectOrganization: (org: Organization) => void;
|
|
8
8
|
selectionError?: string;
|
|
9
|
+
isReloading: boolean;
|
|
10
|
+
isEmptyOrganizations: boolean;
|
|
11
|
+
refetch: (extraDelay: number) => Promise<void>;
|
|
9
12
|
}
|
|
10
13
|
export declare const useOrganizationGuardContext: () => OrganizationContextType;
|
|
11
14
|
declare const OrganizationGuard: ({ children }: React.PropsWithChildren) => React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrganizationGuard.d.ts","sourceRoot":"","sources":["../../../../src/components/common/OrganizationGuard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAoB,MAAM,kBAAkB,CAAC;AAKlE,UAAU,uBAAuB;IAC/B,mBAAmB,CAAC,EAAE,YAAY,CAAC;IACnC,sBAAsB,EAAE,YAAY,EAAE,CAAC;IACvC,4BAA4B,EAAE,OAAO,CAAC;IACtC,kBAAkB,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"OrganizationGuard.d.ts","sourceRoot":"","sources":["../../../../src/components/common/OrganizationGuard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAoB,MAAM,kBAAkB,CAAC;AAKlE,UAAU,uBAAuB;IAC/B,mBAAmB,CAAC,EAAE,YAAY,CAAC;IACnC,sBAAsB,EAAE,YAAY,EAAE,CAAC;IACvC,4BAA4B,EAAE,OAAO,CAAC;IACtC,kBAAkB,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;IAChD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;IACrB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAID,eAAO,MAAM,2BAA2B,QAAO,uBAM9C,CAAC;AAEF,QAAA,MAAM,iBAAiB,iBAAkB,MAAM,iBAAiB,sBA8H/D,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -21,6 +21,8 @@ const OrganizationGuard = ({ children }) => {
|
|
|
21
21
|
const [availableOrganizations, setAvailableOrganizations] = React.useState([]);
|
|
22
22
|
const [organizationsLoaded, setOrganizationsLoaded] = React.useState(false);
|
|
23
23
|
const [selectionError, setSelectionError] = React.useState();
|
|
24
|
+
const [isEmptyOrganizations, setIsEmptyOrganizations] = React.useState(false);
|
|
25
|
+
const [isReloading, setIsReloading] = React.useState(false);
|
|
24
26
|
const initializationStartedRef = React.useRef(false);
|
|
25
27
|
const selectOrganization = React.useCallback((org) => {
|
|
26
28
|
var _a;
|
|
@@ -34,6 +36,60 @@ const OrganizationGuard = ({ children }) => {
|
|
|
34
36
|
setSelectionError((0, error_1.getErrorMessage)(error));
|
|
35
37
|
}
|
|
36
38
|
}, []);
|
|
39
|
+
const fetchOrganizations = React.useCallback(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
var _a;
|
|
41
|
+
try {
|
|
42
|
+
const organizations = yield fetch.get('organizations');
|
|
43
|
+
setAvailableOrganizations(organizations.items);
|
|
44
|
+
// Treat empty organizations list as an error
|
|
45
|
+
if (!organizations.items || organizations.items.length === 0) {
|
|
46
|
+
setSelectionError('No organizations available');
|
|
47
|
+
setIsEmptyOrganizations(true);
|
|
48
|
+
setOrganizationsLoaded(true);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const currentOrgId = (0, organizationStorage_1.getCurrentOrganizationId)();
|
|
52
|
+
// Validate current organization against available organizations
|
|
53
|
+
const currentOrg = currentOrgId
|
|
54
|
+
? organizations.items.find((org) => { var _a; return ((_a = org.metadata) === null || _a === void 0 ? void 0 : _a.name) === currentOrgId; })
|
|
55
|
+
: undefined;
|
|
56
|
+
if (currentOrg) {
|
|
57
|
+
// The previously selected organization exists - use it
|
|
58
|
+
selectOrganization(currentOrg);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (((_a = organizations.items) === null || _a === void 0 ? void 0 : _a.length) === 1) {
|
|
62
|
+
// Only one organization available - select it automatically
|
|
63
|
+
selectOrganization(organizations.items[0]);
|
|
64
|
+
}
|
|
65
|
+
else if (currentOrgId) {
|
|
66
|
+
// Previously set organization does not exist anymore - remove it from localStorage so the user can select a new organization
|
|
67
|
+
setCurrentOrganization(undefined);
|
|
68
|
+
(0, organizationStorage_1.storeCurrentOrganizationId)('');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
setSelectionError(undefined);
|
|
72
|
+
setIsEmptyOrganizations(false);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
setSelectionError((0, error_1.getErrorMessage)(error));
|
|
76
|
+
setAvailableOrganizations([]);
|
|
77
|
+
setIsEmptyOrganizations(false);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
setOrganizationsLoaded(true);
|
|
81
|
+
}
|
|
82
|
+
}), [fetch, selectOrganization]);
|
|
83
|
+
const refetch = React.useCallback((addDelay = 0) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
+
setIsReloading(true);
|
|
85
|
+
try {
|
|
86
|
+
yield new Promise((resolve) => setTimeout(resolve, addDelay));
|
|
87
|
+
yield fetchOrganizations();
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
setIsReloading(false);
|
|
91
|
+
}
|
|
92
|
+
}), [fetchOrganizations]);
|
|
37
93
|
// Determine if multi-orgs are enabled. If so, check if an organization is already selected
|
|
38
94
|
React.useEffect(() => {
|
|
39
95
|
// Prevent multiple initialization calls - only run once
|
|
@@ -41,42 +97,7 @@ const OrganizationGuard = ({ children }) => {
|
|
|
41
97
|
return;
|
|
42
98
|
}
|
|
43
99
|
initializationStartedRef.current = true;
|
|
44
|
-
|
|
45
|
-
var _a;
|
|
46
|
-
try {
|
|
47
|
-
const organizations = yield fetch.get('organizations');
|
|
48
|
-
setAvailableOrganizations(organizations.items);
|
|
49
|
-
const currentOrgId = (0, organizationStorage_1.getCurrentOrganizationId)();
|
|
50
|
-
// Validate current organization against available organizations
|
|
51
|
-
const currentOrg = currentOrgId
|
|
52
|
-
? organizations.items.find((org) => { var _a; return ((_a = org.metadata) === null || _a === void 0 ? void 0 : _a.name) === currentOrgId; })
|
|
53
|
-
: undefined;
|
|
54
|
-
if (currentOrg) {
|
|
55
|
-
// The previously selected organization exists - use it
|
|
56
|
-
selectOrganization(currentOrg);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
if (((_a = organizations.items) === null || _a === void 0 ? void 0 : _a.length) === 1) {
|
|
60
|
-
// Only one organization available - select it automatically
|
|
61
|
-
selectOrganization(organizations.items[0]);
|
|
62
|
-
}
|
|
63
|
-
else if (currentOrgId) {
|
|
64
|
-
// Previously set organization does not exist anymore - remove it from localStorage so the user can select a new organization
|
|
65
|
-
setCurrentOrganization(undefined);
|
|
66
|
-
(0, organizationStorage_1.storeCurrentOrganizationId)('');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
setSelectionError(undefined);
|
|
70
|
-
}
|
|
71
|
-
catch (error) {
|
|
72
|
-
setSelectionError((0, error_1.getErrorMessage)(error));
|
|
73
|
-
setAvailableOrganizations([]);
|
|
74
|
-
}
|
|
75
|
-
finally {
|
|
76
|
-
setOrganizationsLoaded(true);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
void initializeOrganizations();
|
|
100
|
+
void fetchOrganizations();
|
|
80
101
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
81
102
|
}, []);
|
|
82
103
|
const mustShowOrganizationSelector = React.useMemo(() => {
|
|
@@ -93,7 +114,19 @@ const OrganizationGuard = ({ children }) => {
|
|
|
93
114
|
mustShowOrganizationSelector,
|
|
94
115
|
selectOrganization,
|
|
95
116
|
selectionError,
|
|
96
|
-
|
|
117
|
+
isEmptyOrganizations,
|
|
118
|
+
isReloading,
|
|
119
|
+
refetch,
|
|
120
|
+
}), [
|
|
121
|
+
currentOrganization,
|
|
122
|
+
availableOrganizations,
|
|
123
|
+
mustShowOrganizationSelector,
|
|
124
|
+
selectOrganization,
|
|
125
|
+
selectionError,
|
|
126
|
+
isEmptyOrganizations,
|
|
127
|
+
isReloading,
|
|
128
|
+
refetch,
|
|
129
|
+
]);
|
|
97
130
|
return React.createElement(OrganizationContext.Provider, { value: contextValue }, children);
|
|
98
131
|
};
|
|
99
132
|
exports.default = OrganizationGuard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrganizationGuard.js","sourceRoot":"","sources":["../../../../src/components/common/OrganizationGuard.tsx"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAE/B,6DAA0D;AAC1D,6CAAoD;AACpD,yEAAuG;
|
|
1
|
+
{"version":3,"file":"OrganizationGuard.js","sourceRoot":"","sources":["../../../../src/components/common/OrganizationGuard.tsx"],"names":[],"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IAAI,wBAAwB,CAAC,OAAO,EAAE,CAAC;YACrC,OAAO;QACT,CAAC;QAED,wBAAwB,CAAC,OAAO,GAAG,IAAI,CAAC;QAExC,KAAK,kBAAkB,EAAE,CAAC;QAC1B,uDAAuD;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,4BAA4B,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACtD,0CAA0C;QAC1C,IAAI,CAAC,mBAAmB,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,0EAA0E;QAC1E,OAAO,CAAC,CAAC,cAAc,IAAI,CAAC,sBAAsB,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACzF,CAAC,EAAE,CAAC,mBAAmB,EAAE,cAAc,EAAE,sBAAsB,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAE9F,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAChC,GAAG,EAAE,CAAC,CAAC;QACL,mBAAmB;QACnB,sBAAsB;QACtB,4BAA4B;QAC5B,kBAAkB;QAClB,cAAc;QACd,oBAAoB;QACpB,WAAW;QACX,OAAO;KACR,CAAC,EACF;QACE,mBAAmB;QACnB,sBAAsB;QACtB,4BAA4B;QAC5B,kBAAkB;QAClB,cAAc;QACd,oBAAoB;QACpB,WAAW;QACX,OAAO;KACR,CACF,CAAC;IAEF,OAAO,oBAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAAG,QAAQ,CAAgC,CAAC;AACtG,CAAC,CAAC;AAEF,kBAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrganizationSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/common/OrganizationSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"OrganizationSelector.d.ts","sourceRoot":"","sources":["../../../../src/components/common/OrganizationSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA0I/B,UAAU,yBAAyB;IACjC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,QAAA,MAAM,oBAAoB,8BAAsC,yBAAyB,sBA2GxF,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -8,6 +8,7 @@ const useTranslation_1 = require("../../hooks/useTranslation");
|
|
|
8
8
|
const OrganizationGuard_1 = require("./OrganizationGuard");
|
|
9
9
|
const organizationStorage_1 = require("../../utils/organizationStorage");
|
|
10
10
|
const MAX_ORGANIZATIONS_FOR_SCROLL = 4;
|
|
11
|
+
const EXTRA_DELAY = 450;
|
|
11
12
|
const OrganizationSelectorContent = ({ defaultOrganizationId, organizations, onSelect, onCancel, allowCancel = false, isFirstLogin = false, }) => {
|
|
12
13
|
const { t } = (0, useTranslation_1.useTranslation)();
|
|
13
14
|
const [selectedOrg, setSelectedOrg] = React.useState(defaultOrganizationId);
|
|
@@ -47,7 +48,7 @@ const OrganizationSelectorCustomModal = (props) => {
|
|
|
47
48
|
React.createElement(OrganizationSelectorContent, Object.assign({}, props, { isFirstLogin: true })))))));
|
|
48
49
|
};
|
|
49
50
|
const OrganizationSelector = ({ onClose, isFirstLogin = true }) => {
|
|
50
|
-
const { availableOrganizations, selectOrganization, mustShowOrganizationSelector, selectionError } = (0, OrganizationGuard_1.useOrganizationGuardContext)();
|
|
51
|
+
const { availableOrganizations, selectOrganization, mustShowOrganizationSelector, selectionError, isEmptyOrganizations, refetch, isReloading, } = (0, OrganizationGuard_1.useOrganizationGuardContext)();
|
|
51
52
|
const { t } = (0, useTranslation_1.useTranslation)();
|
|
52
53
|
const getLastSelectedOrganization = React.useCallback(() => {
|
|
53
54
|
try {
|
|
@@ -73,19 +74,28 @@ const OrganizationSelector = ({ onClose, isFirstLogin = true }) => {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
}, [availableOrganizations, selectOrganization, onClose]);
|
|
77
|
+
const handleRefetch = React.useCallback(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
yield refetch(EXTRA_DELAY);
|
|
79
|
+
}), [refetch]);
|
|
76
80
|
if (selectionError) {
|
|
77
81
|
return (React.createElement(react_core_1.PageSection, { variant: "light" },
|
|
78
82
|
React.createElement(react_core_1.Bullseye, null,
|
|
79
83
|
React.createElement(react_core_1.Alert, { variant: "danger", title: t('Unable to log in to the application'), isInline: true },
|
|
80
|
-
React.createElement(react_core_1.TextContent, null,
|
|
84
|
+
React.createElement(react_core_1.TextContent, null, isEmptyOrganizations ? (React.createElement(React.Fragment, null,
|
|
85
|
+
React.createElement(react_core_1.Text, null, t('You do not have access to any organizations.')),
|
|
86
|
+
React.createElement(react_core_1.Text, null, t('Please contact your administrator to be granted access to an organization.')))) : (React.createElement(React.Fragment, null,
|
|
81
87
|
React.createElement(react_core_1.Text, null, t('We cannot log you in as we could not determine what organizations you have access to.')),
|
|
82
88
|
React.createElement(react_core_1.Text, null, t('Please try refreshing the page. If the problem persists, contact your administrator.')),
|
|
83
|
-
React.createElement(react_core_1.Text,
|
|
89
|
+
React.createElement(react_core_1.Text, { component: "pre" },
|
|
84
90
|
React.createElement("details", null,
|
|
85
91
|
React.createElement("summary", null,
|
|
86
92
|
t('Error details'),
|
|
87
93
|
":"),
|
|
88
|
-
selectionError)))))
|
|
94
|
+
selectionError))))),
|
|
95
|
+
React.createElement(react_core_1.ActionList, { className: "pf-v5-u-mt-md" },
|
|
96
|
+
React.createElement(react_core_1.ActionListGroup, null,
|
|
97
|
+
React.createElement(react_core_1.ActionListItem, null,
|
|
98
|
+
React.createElement(react_core_1.Button, { variant: "primary", onClick: handleRefetch, isDisabled: isReloading }, t('Reload organizations')))))))));
|
|
89
99
|
}
|
|
90
100
|
const commonProps = {
|
|
91
101
|
defaultOrganizationId: getLastSelectedOrganization(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrganizationSelector.js","sourceRoot":"","sources":["../../../../src/components/common/OrganizationSelector.tsx"],"names":[],"mappings":";;;AAAA,qDAA+B;AAC/B,uDAsBgC;AAChC,sDAA4E;AAG5E,+DAA4D;AAC5D,2DAAkE;AAClE,yEAA2E;AAW3E,MAAM,4BAA4B,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"OrganizationSelector.js","sourceRoot":"","sources":["../../../../src/components/common/OrganizationSelector.tsx"],"names":[],"mappings":";;;AAAA,qDAA+B;AAC/B,uDAsBgC;AAChC,sDAA4E;AAG5E,+DAA4D;AAC5D,2DAAkE;AAClE,yEAA2E;AAW3E,MAAM,4BAA4B,GAAG,CAAC,CAAC;AACvC,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,MAAM,2BAA2B,GAAG,CAAC,EACnC,qBAAqB,EACrB,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,WAAW,GAAG,KAAK,EACnB,YAAY,GAAG,KAAK,GACa,EAAE,EAAE;IACrC,MAAM,EAAE,CAAC,EAAE,GAAG,IAAA,+BAAc,GAAE,CAAC;IAC/B,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAqB,qBAAqB,CAAC,CAAC;IAChG,MAAM,WAAW,GAAG,aAAa,CAAC,MAAM,GAAG,4BAA4B,CAAC;IAExE,OAAO,CACL,oBAAC,kBAAK,IAAC,SAAS;QACd,oBAAC,sBAAS;YACR,oBAAC,wBAAW;gBACV,oBAAC,iBAAI,QACF,YAAY;oBACX,CAAC,CAAC,CAAC,CAAC,2EAA2E,CAAC;oBAChF,CAAC,CAAC,CAAC,CAAC,+EAA+E,CAAC,CACjF,CACK,CACJ;QACX,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,CAC3B,oBAAC,sBAAS;YACR,oBAAC,iBAAI,IACH,YAAY,EAAE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AC"}
|
package/package.json
CHANGED
|
@@ -10,6 +10,9 @@ interface OrganizationContextType {
|
|
|
10
10
|
mustShowOrganizationSelector: boolean;
|
|
11
11
|
selectOrganization: (org: Organization) => void;
|
|
12
12
|
selectionError?: string;
|
|
13
|
+
isReloading: boolean;
|
|
14
|
+
isEmptyOrganizations: boolean;
|
|
15
|
+
refetch: (extraDelay: number) => Promise<void>;
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
const OrganizationContext = React.createContext<OrganizationContextType | null>(null);
|
|
@@ -29,6 +32,8 @@ const OrganizationGuard = ({ children }: React.PropsWithChildren) => {
|
|
|
29
32
|
const [availableOrganizations, setAvailableOrganizations] = React.useState<Organization[]>([]);
|
|
30
33
|
const [organizationsLoaded, setOrganizationsLoaded] = React.useState(false);
|
|
31
34
|
const [selectionError, setSelectionError] = React.useState<string | undefined>();
|
|
35
|
+
const [isEmptyOrganizations, setIsEmptyOrganizations] = React.useState(false);
|
|
36
|
+
const [isReloading, setIsReloading] = React.useState(false);
|
|
32
37
|
const initializationStartedRef = React.useRef(false);
|
|
33
38
|
|
|
34
39
|
const selectOrganization = React.useCallback((org: Organization) => {
|
|
@@ -43,6 +48,63 @@ const OrganizationGuard = ({ children }: React.PropsWithChildren) => {
|
|
|
43
48
|
}
|
|
44
49
|
}, []);
|
|
45
50
|
|
|
51
|
+
const fetchOrganizations = React.useCallback(async () => {
|
|
52
|
+
try {
|
|
53
|
+
const organizations = await fetch.get<OrganizationList>('organizations');
|
|
54
|
+
setAvailableOrganizations(organizations.items);
|
|
55
|
+
|
|
56
|
+
// Treat empty organizations list as an error
|
|
57
|
+
if (!organizations.items || organizations.items.length === 0) {
|
|
58
|
+
setSelectionError('No organizations available');
|
|
59
|
+
setIsEmptyOrganizations(true);
|
|
60
|
+
setOrganizationsLoaded(true);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const currentOrgId = getCurrentOrganizationId();
|
|
65
|
+
|
|
66
|
+
// Validate current organization against available organizations
|
|
67
|
+
const currentOrg = currentOrgId
|
|
68
|
+
? organizations.items.find((org) => org.metadata?.name === currentOrgId)
|
|
69
|
+
: undefined;
|
|
70
|
+
|
|
71
|
+
if (currentOrg) {
|
|
72
|
+
// The previously selected organization exists - use it
|
|
73
|
+
selectOrganization(currentOrg);
|
|
74
|
+
} else {
|
|
75
|
+
if (organizations.items?.length === 1) {
|
|
76
|
+
// Only one organization available - select it automatically
|
|
77
|
+
selectOrganization(organizations.items[0]);
|
|
78
|
+
} else if (currentOrgId) {
|
|
79
|
+
// Previously set organization does not exist anymore - remove it from localStorage so the user can select a new organization
|
|
80
|
+
setCurrentOrganization(undefined);
|
|
81
|
+
storeCurrentOrganizationId('');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
setSelectionError(undefined);
|
|
85
|
+
setIsEmptyOrganizations(false);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
setSelectionError(getErrorMessage(error));
|
|
88
|
+
setAvailableOrganizations([]);
|
|
89
|
+
setIsEmptyOrganizations(false);
|
|
90
|
+
} finally {
|
|
91
|
+
setOrganizationsLoaded(true);
|
|
92
|
+
}
|
|
93
|
+
}, [fetch, selectOrganization]);
|
|
94
|
+
|
|
95
|
+
const refetch = React.useCallback(
|
|
96
|
+
async (addDelay: number = 0) => {
|
|
97
|
+
setIsReloading(true);
|
|
98
|
+
try {
|
|
99
|
+
await new Promise((resolve) => setTimeout(resolve, addDelay));
|
|
100
|
+
await fetchOrganizations();
|
|
101
|
+
} finally {
|
|
102
|
+
setIsReloading(false);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
[fetchOrganizations],
|
|
106
|
+
);
|
|
107
|
+
|
|
46
108
|
// Determine if multi-orgs are enabled. If so, check if an organization is already selected
|
|
47
109
|
React.useEffect(() => {
|
|
48
110
|
// Prevent multiple initialization calls - only run once
|
|
@@ -52,41 +114,7 @@ const OrganizationGuard = ({ children }: React.PropsWithChildren) => {
|
|
|
52
114
|
|
|
53
115
|
initializationStartedRef.current = true;
|
|
54
116
|
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
const organizations = await fetch.get<OrganizationList>('organizations');
|
|
58
|
-
setAvailableOrganizations(organizations.items);
|
|
59
|
-
|
|
60
|
-
const currentOrgId = getCurrentOrganizationId();
|
|
61
|
-
|
|
62
|
-
// Validate current organization against available organizations
|
|
63
|
-
const currentOrg = currentOrgId
|
|
64
|
-
? organizations.items.find((org) => org.metadata?.name === currentOrgId)
|
|
65
|
-
: undefined;
|
|
66
|
-
|
|
67
|
-
if (currentOrg) {
|
|
68
|
-
// The previously selected organization exists - use it
|
|
69
|
-
selectOrganization(currentOrg);
|
|
70
|
-
} else {
|
|
71
|
-
if (organizations.items?.length === 1) {
|
|
72
|
-
// Only one organization available - select it automatically
|
|
73
|
-
selectOrganization(organizations.items[0]);
|
|
74
|
-
} else if (currentOrgId) {
|
|
75
|
-
// Previously set organization does not exist anymore - remove it from localStorage so the user can select a new organization
|
|
76
|
-
setCurrentOrganization(undefined);
|
|
77
|
-
storeCurrentOrganizationId('');
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
setSelectionError(undefined);
|
|
81
|
-
} catch (error) {
|
|
82
|
-
setSelectionError(getErrorMessage(error));
|
|
83
|
-
setAvailableOrganizations([]);
|
|
84
|
-
} finally {
|
|
85
|
-
setOrganizationsLoaded(true);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
void initializeOrganizations();
|
|
117
|
+
void fetchOrganizations();
|
|
90
118
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
119
|
}, []);
|
|
92
120
|
|
|
@@ -106,8 +134,20 @@ const OrganizationGuard = ({ children }: React.PropsWithChildren) => {
|
|
|
106
134
|
mustShowOrganizationSelector,
|
|
107
135
|
selectOrganization,
|
|
108
136
|
selectionError,
|
|
137
|
+
isEmptyOrganizations,
|
|
138
|
+
isReloading,
|
|
139
|
+
refetch,
|
|
109
140
|
}),
|
|
110
|
-
[
|
|
141
|
+
[
|
|
142
|
+
currentOrganization,
|
|
143
|
+
availableOrganizations,
|
|
144
|
+
mustShowOrganizationSelector,
|
|
145
|
+
selectOrganization,
|
|
146
|
+
selectionError,
|
|
147
|
+
isEmptyOrganizations,
|
|
148
|
+
isReloading,
|
|
149
|
+
refetch,
|
|
150
|
+
],
|
|
111
151
|
);
|
|
112
152
|
|
|
113
153
|
return <OrganizationContext.Provider value={contextValue}>{children}</OrganizationContext.Provider>;
|
|
@@ -39,6 +39,7 @@ interface OrganizationSelectorContentProps {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
const MAX_ORGANIZATIONS_FOR_SCROLL = 4;
|
|
42
|
+
const EXTRA_DELAY = 450;
|
|
42
43
|
|
|
43
44
|
const OrganizationSelectorContent = ({
|
|
44
45
|
defaultOrganizationId,
|
|
@@ -141,8 +142,15 @@ interface OrganizationSelectorProps {
|
|
|
141
142
|
}
|
|
142
143
|
|
|
143
144
|
const OrganizationSelector = ({ onClose, isFirstLogin = true }: OrganizationSelectorProps) => {
|
|
144
|
-
const {
|
|
145
|
-
|
|
145
|
+
const {
|
|
146
|
+
availableOrganizations,
|
|
147
|
+
selectOrganization,
|
|
148
|
+
mustShowOrganizationSelector,
|
|
149
|
+
selectionError,
|
|
150
|
+
isEmptyOrganizations,
|
|
151
|
+
refetch,
|
|
152
|
+
isReloading,
|
|
153
|
+
} = useOrganizationGuardContext();
|
|
146
154
|
const { t } = useTranslation();
|
|
147
155
|
|
|
148
156
|
const getLastSelectedOrganization = React.useCallback(() => {
|
|
@@ -172,21 +180,47 @@ const OrganizationSelector = ({ onClose, isFirstLogin = true }: OrganizationSele
|
|
|
172
180
|
[availableOrganizations, selectOrganization, onClose],
|
|
173
181
|
);
|
|
174
182
|
|
|
183
|
+
const handleRefetch = React.useCallback(async () => {
|
|
184
|
+
await refetch(EXTRA_DELAY);
|
|
185
|
+
}, [refetch]);
|
|
186
|
+
|
|
175
187
|
if (selectionError) {
|
|
176
188
|
return (
|
|
177
189
|
<PageSection variant="light">
|
|
178
190
|
<Bullseye>
|
|
179
191
|
<Alert variant="danger" title={t('Unable to log in to the application')} isInline>
|
|
180
192
|
<TextContent>
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
193
|
+
{isEmptyOrganizations ? (
|
|
194
|
+
<>
|
|
195
|
+
<Text>{t('You do not have access to any organizations.')}</Text>
|
|
196
|
+
<Text>{t('Please contact your administrator to be granted access to an organization.')}</Text>
|
|
197
|
+
</>
|
|
198
|
+
) : (
|
|
199
|
+
<>
|
|
200
|
+
<Text>
|
|
201
|
+
{t('We cannot log you in as we could not determine what organizations you have access to.')}
|
|
202
|
+
</Text>
|
|
203
|
+
<Text>
|
|
204
|
+
{t('Please try refreshing the page. If the problem persists, contact your administrator.')}
|
|
205
|
+
</Text>
|
|
206
|
+
<Text component="pre">
|
|
207
|
+
<details>
|
|
208
|
+
<summary>{t('Error details')}:</summary>
|
|
209
|
+
{selectionError}
|
|
210
|
+
</details>
|
|
211
|
+
</Text>
|
|
212
|
+
</>
|
|
213
|
+
)}
|
|
189
214
|
</TextContent>
|
|
215
|
+
<ActionList className="pf-v5-u-mt-md">
|
|
216
|
+
<ActionListGroup>
|
|
217
|
+
<ActionListItem>
|
|
218
|
+
<Button variant="primary" onClick={handleRefetch} isDisabled={isReloading}>
|
|
219
|
+
{t('Reload organizations')}
|
|
220
|
+
</Button>
|
|
221
|
+
</ActionListItem>
|
|
222
|
+
</ActionListGroup>
|
|
223
|
+
</ActionList>
|
|
190
224
|
</Alert>
|
|
191
225
|
</Bullseye>
|
|
192
226
|
</PageSection>
|