@redhat-cloud-services/hcc-storybook-hub 0.1.1 → 0.2.0
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-6YA5JGU2.mjs +193 -0
- package/dist/{chunk-UCQY2VRL.mjs → chunk-AYALJZIB.mjs} +20 -11
- package/dist/{chunk-KVKMLDB5.js → chunk-KINXT2EJ.js} +19 -10
- package/dist/{chunk-YTIDUO5E.js → chunk-OQMLXRLX.js} +113 -21
- package/dist/{main-config.js → config.js} +10 -9
- package/dist/{main-config.mjs → config.mjs} +5 -4
- package/dist/index.d.mts +41 -67
- package/dist/index.d.ts +41 -67
- package/dist/index.js +45 -68
- package/dist/index.mjs +48 -71
- package/dist/mocks/RBACHook.js +2 -2
- package/dist/mocks/RBACHook.mjs +1 -1
- package/dist/mocks/kesselAccessCheck.d.mts +1 -2
- package/dist/mocks/kesselAccessCheck.d.ts +1 -2
- package/dist/mocks/kesselAccessCheck.js +34 -22
- package/dist/mocks/kesselAccessCheck.mjs +32 -20
- package/dist/mocks/useChrome.d.mts +2 -9
- package/dist/mocks/useChrome.d.ts +2 -9
- package/dist/mocks/useChrome.js +3 -5
- package/dist/mocks/useChrome.mjs +4 -6
- package/package.json +16 -11
- package/dist/chunk-EPJ4YIIZ.mjs +0 -101
- /package/dist/{main-config.d.mts → config.d.mts} +0 -0
- /package/dist/{main-config.d.ts → config.d.ts} +0 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useMockState
|
|
3
|
+
} from "./chunk-AYALJZIB.mjs";
|
|
4
|
+
|
|
5
|
+
// lib/mocks/useChrome.tsx
|
|
6
|
+
import { useRef } from "react";
|
|
7
|
+
import { fn } from "storybook/test";
|
|
8
|
+
|
|
9
|
+
// lib/mocks/DefaultCatalog.tsx
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
var defaultTutorials = [
|
|
12
|
+
{ id: "getting-started", title: "Getting Started", description: "Learn the basics.", time: "10 min", level: "Beginner" },
|
|
13
|
+
{ id: "custom-roles", title: "Creating Custom Roles", description: "Configure custom roles.", time: "15 min", level: "Intermediate" },
|
|
14
|
+
{ id: "user-groups", title: "Managing User Groups", description: "Organize users into groups.", time: "12 min", level: "Beginner" },
|
|
15
|
+
{ id: "workspaces", title: "Workspace Administration", description: "Master workspace management.", time: "20 min", level: "Advanced" }
|
|
16
|
+
];
|
|
17
|
+
var DefaultCatalog = () => /* @__PURE__ */ jsxs("div", { style: { padding: "24px" }, children: [
|
|
18
|
+
/* @__PURE__ */ jsx("h2", { style: { margin: "0 0 8px 0", fontSize: "28px", fontWeight: 300 }, children: "Quick starts" }),
|
|
19
|
+
/* @__PURE__ */ jsx("p", { style: { color: "#6a6e73", margin: "0 0 24px", fontSize: "14px" }, children: "Step-by-step instructions and guided tours." }),
|
|
20
|
+
/* @__PURE__ */ jsx("div", { style: { display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(300px, 1fr))", gap: "16px" }, children: defaultTutorials.map((t) => /* @__PURE__ */ jsxs("div", { style: { border: "1px solid #d2d2d2", borderRadius: "8px", padding: "16px" }, children: [
|
|
21
|
+
/* @__PURE__ */ jsx("h3", { style: { margin: "0 0 8px", fontSize: "16px", fontWeight: 600 }, children: t.title }),
|
|
22
|
+
/* @__PURE__ */ jsx("p", { style: { margin: "0", fontSize: "14px", color: "#6a6e73" }, children: t.description })
|
|
23
|
+
] }, t.id)) })
|
|
24
|
+
] });
|
|
25
|
+
|
|
26
|
+
// lib/mocks/useChrome.tsx
|
|
27
|
+
var chromeSpies = /* @__PURE__ */ new Map();
|
|
28
|
+
function getSpy(path) {
|
|
29
|
+
if (!chromeSpies.has(path)) {
|
|
30
|
+
chromeSpies.set(path, fn().mockName(path));
|
|
31
|
+
}
|
|
32
|
+
return chromeSpies.get(path);
|
|
33
|
+
}
|
|
34
|
+
function useChrome() {
|
|
35
|
+
const mock = useMockState();
|
|
36
|
+
const mockRef = useRef(mock);
|
|
37
|
+
mockRef.current = mock;
|
|
38
|
+
const chromeRef = useRef(null);
|
|
39
|
+
if (!chromeRef.current) {
|
|
40
|
+
chromeRef.current = {
|
|
41
|
+
getEnvironment: () => mockRef.current.environment === "production" ? "prod" : "stage",
|
|
42
|
+
getEnvironmentDetails: () => ({
|
|
43
|
+
environment: mockRef.current.environment === "production" ? "prod" : "stage",
|
|
44
|
+
sso: mockRef.current.environment === "production" ? "https://sso.redhat.com" : "https://sso.stage.redhat.com",
|
|
45
|
+
portal: "https://console.redhat.com"
|
|
46
|
+
}),
|
|
47
|
+
get isProd() {
|
|
48
|
+
return mockRef.current.environment === "production";
|
|
49
|
+
},
|
|
50
|
+
isBeta: () => false,
|
|
51
|
+
getBundle: () => mockRef.current.bundle,
|
|
52
|
+
getApp: () => mockRef.current.app,
|
|
53
|
+
auth: {
|
|
54
|
+
getToken: () => Promise.resolve("mock-token-12345"),
|
|
55
|
+
getUser: () => {
|
|
56
|
+
const id = mockRef.current.userIdentity;
|
|
57
|
+
return Promise.resolve({
|
|
58
|
+
identity: {
|
|
59
|
+
account_number: id?.account_number,
|
|
60
|
+
org_id: id?.org_id ?? "mock-org-id",
|
|
61
|
+
organization: id?.organization,
|
|
62
|
+
internal: id?.internal,
|
|
63
|
+
user: {
|
|
64
|
+
is_org_admin: id?.user?.is_org_admin ?? mockRef.current.isOrgAdmin,
|
|
65
|
+
username: id?.user?.username ?? "test-user",
|
|
66
|
+
email: id?.user?.email ?? "test@redhat.com",
|
|
67
|
+
is_internal: id?.user?.is_internal ?? false,
|
|
68
|
+
first_name: id?.user?.first_name,
|
|
69
|
+
last_name: id?.user?.last_name,
|
|
70
|
+
is_active: id?.user?.is_active ?? true,
|
|
71
|
+
locale: id?.user?.locale ?? "en_US"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
entitlements: id?.entitlements ?? {}
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
getOfflineToken: () => Promise.resolve("mock-offline-token"),
|
|
78
|
+
getRefreshToken: () => Promise.resolve("mock-refresh-token"),
|
|
79
|
+
login: () => Promise.resolve(),
|
|
80
|
+
logout: getSpy("auth.logout"),
|
|
81
|
+
reAuthWithScopes: () => Promise.resolve()
|
|
82
|
+
},
|
|
83
|
+
getUserPermissions: (app) => Promise.resolve(
|
|
84
|
+
mockRef.current.permissions.filter((p) => p.startsWith(`${app}:`)).map((permission) => ({ permission, resourceDefinitions: [] }))
|
|
85
|
+
),
|
|
86
|
+
appNavClick: getSpy("appNavClick"),
|
|
87
|
+
appObjectId: getSpy("appObjectId"),
|
|
88
|
+
appAction: getSpy("appAction"),
|
|
89
|
+
addWsEventListener: (_eventType, _callback) => {
|
|
90
|
+
return () => {
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
drawerActions: {
|
|
94
|
+
toggleDrawerContent: getSpy("drawerActions.toggleDrawerContent"),
|
|
95
|
+
setDrawerPanelContent: getSpy("drawerActions.setDrawerPanelContent"),
|
|
96
|
+
toggleDrawerPanel: getSpy("drawerActions.toggleDrawerPanel")
|
|
97
|
+
},
|
|
98
|
+
updateDocumentTitle: (title) => {
|
|
99
|
+
if (typeof document !== "undefined") {
|
|
100
|
+
document.title = title;
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
get quickStarts() {
|
|
104
|
+
return {
|
|
105
|
+
Catalog: DefaultCatalog,
|
|
106
|
+
set: getSpy("quickStarts.set"),
|
|
107
|
+
toggle: getSpy("quickStarts.toggle"),
|
|
108
|
+
version: 1,
|
|
109
|
+
activateQuickstart: () => Promise.resolve()
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
// Commonly accessed properties that should return safe defaults
|
|
113
|
+
initialized: true,
|
|
114
|
+
isChrome2: true,
|
|
115
|
+
experimentalApi: false,
|
|
116
|
+
isFedramp: false,
|
|
117
|
+
chromeHistory: { push: getSpy("chromeHistory.push"), replace: getSpy("chromeHistory.replace"), listen: () => () => {
|
|
118
|
+
} },
|
|
119
|
+
identifyApp: getSpy("identifyApp"),
|
|
120
|
+
on: (_event, _callback) => () => {
|
|
121
|
+
},
|
|
122
|
+
init: getSpy("init"),
|
|
123
|
+
isPenTest: () => false,
|
|
124
|
+
isDemo: () => false,
|
|
125
|
+
forceDemo: getSpy("forceDemo"),
|
|
126
|
+
getAvailableBundles: () => [],
|
|
127
|
+
getBundleData: () => ({ bundleId: mockRef.current.bundle, bundleTitle: "Insights" }),
|
|
128
|
+
globalFilterScope: getSpy("globalFilterScope"),
|
|
129
|
+
hideGlobalFilter: getSpy("hideGlobalFilter"),
|
|
130
|
+
removeGlobalFilter: getSpy("removeGlobalFilter"),
|
|
131
|
+
mapGlobalFilter: getSpy("mapGlobalFilter"),
|
|
132
|
+
navigation: getSpy("navigation"),
|
|
133
|
+
registerModule: getSpy("registerModule"),
|
|
134
|
+
createCase: getSpy("createCase"),
|
|
135
|
+
toggleFeedbackModal: getSpy("toggleFeedbackModal"),
|
|
136
|
+
toggleDebuggerModal: getSpy("toggleDebuggerModal"),
|
|
137
|
+
enableDebugging: getSpy("enableDebugging"),
|
|
138
|
+
usePendoFeedback: getSpy("usePendoFeedback"),
|
|
139
|
+
enablePackagesDebug: getSpy("enablePackagesDebug"),
|
|
140
|
+
requestPdf: () => Promise.resolve(),
|
|
141
|
+
isAnsibleTrialFlagActive: () => false,
|
|
142
|
+
setAnsibleTrialFlag: getSpy("setAnsibleTrialFlag"),
|
|
143
|
+
clearAnsibleTrialFlag: getSpy("clearAnsibleTrialFlag"),
|
|
144
|
+
segment: { setPageMetadata: getSpy("segment.setPageMetadata") },
|
|
145
|
+
useGlobalFilter: () => void 0,
|
|
146
|
+
visibilityFunctions: {
|
|
147
|
+
isOrgAdmin: () => Promise.resolve(mockRef.current.isOrgAdmin),
|
|
148
|
+
isActive: () => Promise.resolve(true),
|
|
149
|
+
isInternal: () => Promise.resolve(false),
|
|
150
|
+
isEntitled: () => Promise.resolve({}),
|
|
151
|
+
isProd: () => mockRef.current.environment === "production",
|
|
152
|
+
isBeta: () => false,
|
|
153
|
+
isHidden: () => true,
|
|
154
|
+
withEmail: () => Promise.resolve(true),
|
|
155
|
+
loosePermissions: () => Promise.resolve(true),
|
|
156
|
+
loosePermissionsKessel: () => Promise.resolve(true),
|
|
157
|
+
hasPermissions: () => Promise.resolve(true),
|
|
158
|
+
hasLocalStorage: () => false,
|
|
159
|
+
hasCookie: () => false,
|
|
160
|
+
apiRequest: () => Promise.resolve(true),
|
|
161
|
+
featureFlag: () => false
|
|
162
|
+
},
|
|
163
|
+
helpTopics: {
|
|
164
|
+
addHelpTopics: getSpy("helpTopics.addHelpTopics"),
|
|
165
|
+
enableTopics: () => Promise.resolve([]),
|
|
166
|
+
disableTopics: getSpy("helpTopics.disableTopics"),
|
|
167
|
+
setActiveTopic: () => Promise.resolve(),
|
|
168
|
+
closeHelpTopic: getSpy("helpTopics.closeHelpTopic")
|
|
169
|
+
},
|
|
170
|
+
enable: {
|
|
171
|
+
iqe: getSpy("enable.iqe"),
|
|
172
|
+
remediationsDebug: getSpy("enable.remediationsDebug"),
|
|
173
|
+
invTags: getSpy("enable.invTags"),
|
|
174
|
+
shortSession: getSpy("enable.shortSession"),
|
|
175
|
+
jwtDebug: getSpy("enable.jwtDebug"),
|
|
176
|
+
reduxDebug: getSpy("enable.reduxDebug"),
|
|
177
|
+
forcePendo: getSpy("enable.forcePendo"),
|
|
178
|
+
allDetails: getSpy("enable.allDetails"),
|
|
179
|
+
inventoryDrawer: getSpy("enable.inventoryDrawer"),
|
|
180
|
+
globalFilter: getSpy("enable.globalFilter"),
|
|
181
|
+
appFilter: getSpy("enable.appFilter"),
|
|
182
|
+
contextSwitcher: getSpy("enable.contextSwitcher"),
|
|
183
|
+
quickstartsDebug: getSpy("enable.quickstartsDebug")
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return chromeRef.current;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export {
|
|
191
|
+
chromeSpies,
|
|
192
|
+
useChrome
|
|
193
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// lib/contexts/StorybookMockContext.tsx
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
2
|
+
import { createContext, useContext, useMemo } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
var EMPTY_WORKSPACE_PERMISSIONS = {
|
|
5
5
|
view: [],
|
|
@@ -21,7 +21,9 @@ var EMPTY_TENANT_PERMISSIONS = {
|
|
|
21
21
|
rbac_workspace_move: false
|
|
22
22
|
};
|
|
23
23
|
var defaultState = {
|
|
24
|
-
|
|
24
|
+
bundle: "insights",
|
|
25
|
+
app: "unknown",
|
|
26
|
+
environment: "stage",
|
|
25
27
|
isOrgAdmin: false,
|
|
26
28
|
permissions: [],
|
|
27
29
|
workspacePermissions: EMPTY_WORKSPACE_PERMISSIONS,
|
|
@@ -30,21 +32,28 @@ var defaultState = {
|
|
|
30
32
|
var StorybookMockContext = createContext(defaultState);
|
|
31
33
|
var StorybookMockProvider = ({
|
|
32
34
|
children,
|
|
33
|
-
|
|
35
|
+
bundle = "insights",
|
|
36
|
+
app = "unknown",
|
|
37
|
+
environment = "stage",
|
|
34
38
|
isOrgAdmin = false,
|
|
35
39
|
permissions = [],
|
|
36
40
|
workspacePermissions = EMPTY_WORKSPACE_PERMISSIONS,
|
|
37
41
|
tenantPermissions = EMPTY_TENANT_PERMISSIONS,
|
|
38
42
|
userIdentity
|
|
39
43
|
}) => {
|
|
40
|
-
const value =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const value = useMemo(
|
|
45
|
+
() => ({
|
|
46
|
+
bundle,
|
|
47
|
+
app,
|
|
48
|
+
environment,
|
|
49
|
+
isOrgAdmin,
|
|
50
|
+
permissions,
|
|
51
|
+
workspacePermissions: { ...EMPTY_WORKSPACE_PERMISSIONS, ...workspacePermissions },
|
|
52
|
+
tenantPermissions: { ...EMPTY_TENANT_PERMISSIONS, ...tenantPermissions },
|
|
53
|
+
userIdentity
|
|
54
|
+
}),
|
|
55
|
+
[bundle, app, environment, isOrgAdmin, permissions, workspacePermissions, tenantPermissions, userIdentity]
|
|
56
|
+
);
|
|
48
57
|
return /* @__PURE__ */ jsx(StorybookMockContext.Provider, { value, children });
|
|
49
58
|
};
|
|
50
59
|
var useMockState = () => useContext(StorybookMockContext);
|
|
@@ -21,7 +21,9 @@ var EMPTY_TENANT_PERMISSIONS = {
|
|
|
21
21
|
rbac_workspace_move: false
|
|
22
22
|
};
|
|
23
23
|
var defaultState = {
|
|
24
|
-
|
|
24
|
+
bundle: "insights",
|
|
25
|
+
app: "unknown",
|
|
26
|
+
environment: "stage",
|
|
25
27
|
isOrgAdmin: false,
|
|
26
28
|
permissions: [],
|
|
27
29
|
workspacePermissions: EMPTY_WORKSPACE_PERMISSIONS,
|
|
@@ -30,21 +32,28 @@ var defaultState = {
|
|
|
30
32
|
var StorybookMockContext = _react.createContext.call(void 0, defaultState);
|
|
31
33
|
var StorybookMockProvider = ({
|
|
32
34
|
children,
|
|
33
|
-
|
|
35
|
+
bundle = "insights",
|
|
36
|
+
app = "unknown",
|
|
37
|
+
environment = "stage",
|
|
34
38
|
isOrgAdmin = false,
|
|
35
39
|
permissions = [],
|
|
36
40
|
workspacePermissions = EMPTY_WORKSPACE_PERMISSIONS,
|
|
37
41
|
tenantPermissions = EMPTY_TENANT_PERMISSIONS,
|
|
38
42
|
userIdentity
|
|
39
43
|
}) => {
|
|
40
|
-
const value =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const value = _react.useMemo.call(void 0,
|
|
45
|
+
() => ({
|
|
46
|
+
bundle,
|
|
47
|
+
app,
|
|
48
|
+
environment,
|
|
49
|
+
isOrgAdmin,
|
|
50
|
+
permissions,
|
|
51
|
+
workspacePermissions: { ...EMPTY_WORKSPACE_PERMISSIONS, ...workspacePermissions },
|
|
52
|
+
tenantPermissions: { ...EMPTY_TENANT_PERMISSIONS, ...tenantPermissions },
|
|
53
|
+
userIdentity
|
|
54
|
+
}),
|
|
55
|
+
[bundle, app, environment, isOrgAdmin, permissions, workspacePermissions, tenantPermissions, userIdentity]
|
|
56
|
+
);
|
|
48
57
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StorybookMockContext.Provider, { value, children });
|
|
49
58
|
};
|
|
50
59
|
var useMockState = () => _react.useContext.call(void 0, StorybookMockContext);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkKINXT2EJjs = require('./chunk-KINXT2EJ.js');
|
|
4
4
|
|
|
5
5
|
// lib/mocks/useChrome.tsx
|
|
6
6
|
var _react = require('react');
|
|
7
7
|
var _test = require('storybook/test');
|
|
8
|
+
|
|
9
|
+
// lib/mocks/DefaultCatalog.tsx
|
|
8
10
|
var _jsxruntime = require('react/jsx-runtime');
|
|
9
|
-
var chromeAppNavClickSpy = _test.fn.call(void 0, );
|
|
10
11
|
var defaultTutorials = [
|
|
11
12
|
{ id: "getting-started", title: "Getting Started", description: "Learn the basics.", time: "10 min", level: "Beginner" },
|
|
12
13
|
{ id: "custom-roles", title: "Creating Custom Roles", description: "Configure custom roles.", time: "15 min", level: "Intermediate" },
|
|
@@ -21,12 +22,17 @@ var DefaultCatalog = () => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div",
|
|
|
21
22
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { style: { margin: "0", fontSize: "14px", color: "#6a6e73" }, children: t.description })
|
|
22
23
|
] }, t.id)) })
|
|
23
24
|
] });
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
|
|
26
|
+
// lib/mocks/useChrome.tsx
|
|
27
|
+
var chromeSpies = /* @__PURE__ */ new Map();
|
|
28
|
+
function getSpy(path) {
|
|
29
|
+
if (!chromeSpies.has(path)) {
|
|
30
|
+
chromeSpies.set(path, _test.fn.call(void 0, ).mockName(path));
|
|
31
|
+
}
|
|
32
|
+
return chromeSpies.get(path);
|
|
27
33
|
}
|
|
28
34
|
function useChrome() {
|
|
29
|
-
const mock =
|
|
35
|
+
const mock = _chunkKINXT2EJjs.useMockState.call(void 0, );
|
|
30
36
|
const mockRef = _react.useRef.call(void 0, mock);
|
|
31
37
|
mockRef.current = mock;
|
|
32
38
|
const chromeRef = _react.useRef.call(void 0, null);
|
|
@@ -42,8 +48,8 @@ function useChrome() {
|
|
|
42
48
|
return mockRef.current.environment === "production";
|
|
43
49
|
},
|
|
44
50
|
isBeta: () => false,
|
|
45
|
-
getBundle: () =>
|
|
46
|
-
getApp: () =>
|
|
51
|
+
getBundle: () => mockRef.current.bundle,
|
|
52
|
+
getApp: () => mockRef.current.app,
|
|
47
53
|
auth: {
|
|
48
54
|
getToken: () => Promise.resolve("mock-token-12345"),
|
|
49
55
|
getUser: () => {
|
|
@@ -67,27 +73,114 @@ function useChrome() {
|
|
|
67
73
|
},
|
|
68
74
|
entitlements: _nullishCoalesce(_optionalChain([id, 'optionalAccess', _21 => _21.entitlements]), () => ( {}))
|
|
69
75
|
});
|
|
70
|
-
}
|
|
76
|
+
},
|
|
77
|
+
getOfflineToken: () => Promise.resolve("mock-offline-token"),
|
|
78
|
+
getRefreshToken: () => Promise.resolve("mock-refresh-token"),
|
|
79
|
+
login: () => Promise.resolve(),
|
|
80
|
+
logout: getSpy("auth.logout"),
|
|
81
|
+
reAuthWithScopes: () => Promise.resolve()
|
|
71
82
|
},
|
|
72
83
|
getUserPermissions: (app) => Promise.resolve(
|
|
73
|
-
mockRef.current.permissions.filter((p) => p.startsWith(`${app}:`)
|
|
84
|
+
mockRef.current.permissions.filter((p) => p.startsWith(`${app}:`)).map((permission) => ({ permission, resourceDefinitions: [] }))
|
|
74
85
|
),
|
|
75
|
-
appNavClick:
|
|
76
|
-
appObjectId: ()
|
|
86
|
+
appNavClick: getSpy("appNavClick"),
|
|
87
|
+
appObjectId: getSpy("appObjectId"),
|
|
88
|
+
appAction: getSpy("appAction"),
|
|
89
|
+
addWsEventListener: (_eventType, _callback) => {
|
|
90
|
+
return () => {
|
|
91
|
+
};
|
|
77
92
|
},
|
|
78
|
-
|
|
93
|
+
drawerActions: {
|
|
94
|
+
toggleDrawerContent: getSpy("drawerActions.toggleDrawerContent"),
|
|
95
|
+
setDrawerPanelContent: getSpy("drawerActions.setDrawerPanelContent"),
|
|
96
|
+
toggleDrawerPanel: getSpy("drawerActions.toggleDrawerPanel")
|
|
79
97
|
},
|
|
80
98
|
updateDocumentTitle: (title) => {
|
|
81
99
|
if (typeof document !== "undefined") {
|
|
82
100
|
document.title = title;
|
|
83
101
|
}
|
|
84
102
|
},
|
|
85
|
-
quickStarts
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
get quickStarts() {
|
|
104
|
+
return {
|
|
105
|
+
Catalog: DefaultCatalog,
|
|
106
|
+
set: getSpy("quickStarts.set"),
|
|
107
|
+
toggle: getSpy("quickStarts.toggle"),
|
|
108
|
+
version: 1,
|
|
109
|
+
activateQuickstart: () => Promise.resolve()
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
// Commonly accessed properties that should return safe defaults
|
|
113
|
+
initialized: true,
|
|
114
|
+
isChrome2: true,
|
|
115
|
+
experimentalApi: false,
|
|
116
|
+
isFedramp: false,
|
|
117
|
+
chromeHistory: { push: getSpy("chromeHistory.push"), replace: getSpy("chromeHistory.replace"), listen: () => () => {
|
|
118
|
+
} },
|
|
119
|
+
identifyApp: getSpy("identifyApp"),
|
|
120
|
+
on: (_event, _callback) => () => {
|
|
121
|
+
},
|
|
122
|
+
init: getSpy("init"),
|
|
123
|
+
isPenTest: () => false,
|
|
124
|
+
isDemo: () => false,
|
|
125
|
+
forceDemo: getSpy("forceDemo"),
|
|
126
|
+
getAvailableBundles: () => [],
|
|
127
|
+
getBundleData: () => ({ bundleId: mockRef.current.bundle, bundleTitle: "Insights" }),
|
|
128
|
+
globalFilterScope: getSpy("globalFilterScope"),
|
|
129
|
+
hideGlobalFilter: getSpy("hideGlobalFilter"),
|
|
130
|
+
removeGlobalFilter: getSpy("removeGlobalFilter"),
|
|
131
|
+
mapGlobalFilter: getSpy("mapGlobalFilter"),
|
|
132
|
+
navigation: getSpy("navigation"),
|
|
133
|
+
registerModule: getSpy("registerModule"),
|
|
134
|
+
createCase: getSpy("createCase"),
|
|
135
|
+
toggleFeedbackModal: getSpy("toggleFeedbackModal"),
|
|
136
|
+
toggleDebuggerModal: getSpy("toggleDebuggerModal"),
|
|
137
|
+
enableDebugging: getSpy("enableDebugging"),
|
|
138
|
+
usePendoFeedback: getSpy("usePendoFeedback"),
|
|
139
|
+
enablePackagesDebug: getSpy("enablePackagesDebug"),
|
|
140
|
+
requestPdf: () => Promise.resolve(),
|
|
141
|
+
isAnsibleTrialFlagActive: () => false,
|
|
142
|
+
setAnsibleTrialFlag: getSpy("setAnsibleTrialFlag"),
|
|
143
|
+
clearAnsibleTrialFlag: getSpy("clearAnsibleTrialFlag"),
|
|
144
|
+
segment: { setPageMetadata: getSpy("segment.setPageMetadata") },
|
|
145
|
+
useGlobalFilter: () => void 0,
|
|
146
|
+
visibilityFunctions: {
|
|
147
|
+
isOrgAdmin: () => Promise.resolve(mockRef.current.isOrgAdmin),
|
|
148
|
+
isActive: () => Promise.resolve(true),
|
|
149
|
+
isInternal: () => Promise.resolve(false),
|
|
150
|
+
isEntitled: () => Promise.resolve({}),
|
|
151
|
+
isProd: () => mockRef.current.environment === "production",
|
|
152
|
+
isBeta: () => false,
|
|
153
|
+
isHidden: () => true,
|
|
154
|
+
withEmail: () => Promise.resolve(true),
|
|
155
|
+
loosePermissions: () => Promise.resolve(true),
|
|
156
|
+
loosePermissionsKessel: () => Promise.resolve(true),
|
|
157
|
+
hasPermissions: () => Promise.resolve(true),
|
|
158
|
+
hasLocalStorage: () => false,
|
|
159
|
+
hasCookie: () => false,
|
|
160
|
+
apiRequest: () => Promise.resolve(true),
|
|
161
|
+
featureFlag: () => false
|
|
162
|
+
},
|
|
163
|
+
helpTopics: {
|
|
164
|
+
addHelpTopics: getSpy("helpTopics.addHelpTopics"),
|
|
165
|
+
enableTopics: () => Promise.resolve([]),
|
|
166
|
+
disableTopics: getSpy("helpTopics.disableTopics"),
|
|
167
|
+
setActiveTopic: () => Promise.resolve(),
|
|
168
|
+
closeHelpTopic: getSpy("helpTopics.closeHelpTopic")
|
|
169
|
+
},
|
|
170
|
+
enable: {
|
|
171
|
+
iqe: getSpy("enable.iqe"),
|
|
172
|
+
remediationsDebug: getSpy("enable.remediationsDebug"),
|
|
173
|
+
invTags: getSpy("enable.invTags"),
|
|
174
|
+
shortSession: getSpy("enable.shortSession"),
|
|
175
|
+
jwtDebug: getSpy("enable.jwtDebug"),
|
|
176
|
+
reduxDebug: getSpy("enable.reduxDebug"),
|
|
177
|
+
forcePendo: getSpy("enable.forcePendo"),
|
|
178
|
+
allDetails: getSpy("enable.allDetails"),
|
|
179
|
+
inventoryDrawer: getSpy("enable.inventoryDrawer"),
|
|
180
|
+
globalFilter: getSpy("enable.globalFilter"),
|
|
181
|
+
appFilter: getSpy("enable.appFilter"),
|
|
182
|
+
contextSwitcher: getSpy("enable.contextSwitcher"),
|
|
183
|
+
quickstartsDebug: getSpy("enable.quickstartsDebug")
|
|
91
184
|
}
|
|
92
185
|
};
|
|
93
186
|
}
|
|
@@ -97,5 +190,4 @@ function useChrome() {
|
|
|
97
190
|
|
|
98
191
|
|
|
99
192
|
|
|
100
|
-
|
|
101
|
-
exports.chromeAppNavClickSpy = chromeAppNavClickSpy; exports.configureChromeMock = configureChromeMock; exports.useChrome = useChrome;
|
|
193
|
+
exports.chromeSpies = chromeSpies; exports.useChrome = useChrome;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function
|
|
2
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
3
|
-
var _url = require('url');
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// lib/main/createMainConfig.ts
|
|
4
2
|
function createMainConfig(options = {}) {
|
|
5
3
|
const {
|
|
6
4
|
stories = ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
|
|
@@ -38,8 +36,6 @@ function createMainConfig(options = {}) {
|
|
|
38
36
|
addons.push("@storybook/addon-a11y");
|
|
39
37
|
}
|
|
40
38
|
addons.push(...extraAddons);
|
|
41
|
-
const currentDir = typeof __dirname !== "undefined" ? __dirname : _path2.default.dirname(_url.fileURLToPath.call(void 0, import.meta.url));
|
|
42
|
-
const hubMocksDir = _path2.default.resolve(currentDir, "mocks");
|
|
43
39
|
const config = {
|
|
44
40
|
stories,
|
|
45
41
|
addons,
|
|
@@ -57,14 +53,18 @@ function createMainConfig(options = {}) {
|
|
|
57
53
|
}
|
|
58
54
|
})),
|
|
59
55
|
webpackFinal: async (webpackConfig) => {
|
|
56
|
+
const path = await Promise.resolve().then(() => _interopRequireWildcard(require("path")));
|
|
57
|
+
const { fileURLToPath } = await Promise.resolve().then(() => _interopRequireWildcard(require("url")));
|
|
58
|
+
const currentDir = typeof __dirname !== "undefined" ? __dirname : path.dirname(fileURLToPath(import.meta.url));
|
|
59
|
+
const hubMocksDir = path.resolve(currentDir, "mocks");
|
|
60
60
|
webpackConfig.resolve = {
|
|
61
61
|
...webpackConfig.resolve,
|
|
62
62
|
alias: {
|
|
63
63
|
..._optionalChain([webpackConfig, 'access', _2 => _2.resolve, 'optionalAccess', _3 => _3.alias]),
|
|
64
|
-
"@redhat-cloud-services/frontend-components/useChrome":
|
|
65
|
-
"@redhat-cloud-services/frontend-components-utilities/RBACHook":
|
|
66
|
-
"@unleash/proxy-client-react":
|
|
67
|
-
"@project-kessel/react-kessel-access-check":
|
|
64
|
+
"@redhat-cloud-services/frontend-components/useChrome": path.join(hubMocksDir, "useChrome.js"),
|
|
65
|
+
"@redhat-cloud-services/frontend-components-utilities/RBACHook": path.join(hubMocksDir, "RBACHook.js"),
|
|
66
|
+
"@unleash/proxy-client-react": path.join(hubMocksDir, "unleash.js"),
|
|
67
|
+
"@project-kessel/react-kessel-access-check": path.join(hubMocksDir, "kesselAccessCheck.js"),
|
|
68
68
|
...extraAliases
|
|
69
69
|
},
|
|
70
70
|
fallback: {
|
|
@@ -89,6 +89,7 @@ function createMainConfig(options = {}) {
|
|
|
89
89
|
if (staticDirs) {
|
|
90
90
|
config.staticDirs = staticDirs;
|
|
91
91
|
}
|
|
92
|
+
config.previewBody = () => '<div id="chrome-app-render-root"></div>';
|
|
92
93
|
return config;
|
|
93
94
|
}
|
|
94
95
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
// lib/main/createMainConfig.ts
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
2
|
function createMainConfig(options = {}) {
|
|
5
3
|
const {
|
|
6
4
|
stories = ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
|
|
@@ -38,8 +36,6 @@ function createMainConfig(options = {}) {
|
|
|
38
36
|
addons.push("@storybook/addon-a11y");
|
|
39
37
|
}
|
|
40
38
|
addons.push(...extraAddons);
|
|
41
|
-
const currentDir = typeof __dirname !== "undefined" ? __dirname : path.dirname(fileURLToPath(import.meta.url));
|
|
42
|
-
const hubMocksDir = path.resolve(currentDir, "mocks");
|
|
43
39
|
const config = {
|
|
44
40
|
stories,
|
|
45
41
|
addons,
|
|
@@ -57,6 +53,10 @@ function createMainConfig(options = {}) {
|
|
|
57
53
|
}
|
|
58
54
|
},
|
|
59
55
|
webpackFinal: async (webpackConfig) => {
|
|
56
|
+
const path = await import("path");
|
|
57
|
+
const { fileURLToPath } = await import("url");
|
|
58
|
+
const currentDir = typeof __dirname !== "undefined" ? __dirname : path.dirname(fileURLToPath(import.meta.url));
|
|
59
|
+
const hubMocksDir = path.resolve(currentDir, "mocks");
|
|
60
60
|
webpackConfig.resolve = {
|
|
61
61
|
...webpackConfig.resolve,
|
|
62
62
|
alias: {
|
|
@@ -89,6 +89,7 @@ function createMainConfig(options = {}) {
|
|
|
89
89
|
if (staticDirs) {
|
|
90
90
|
config.staticDirs = staticDirs;
|
|
91
91
|
}
|
|
92
|
+
config.previewBody = () => '<div id="chrome-app-render-root"></div>';
|
|
92
93
|
return config;
|
|
93
94
|
}
|
|
94
95
|
export {
|