@availity/mui-spaces 1.0.23 → 1.0.25
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/CHANGELOG.md +4 -0
- package/dist/index.js +7 -2
- package/dist/index.mjs +7 -2
- package/package.json +1 -1
- package/src/lib/SpacesLink/linkHandlers.tsx +10 -2
- package/src/lib/SpacesLink/useLink.test.tsx +56 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [1.0.25](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.24...@availity/mui-spaces@1.0.25) (2025-06-11)
|
|
6
|
+
|
|
7
|
+
## [1.0.24](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.23...@availity/mui-spaces@1.0.24) (2025-06-11)
|
|
8
|
+
|
|
5
9
|
## [1.0.23](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.22...@availity/mui-spaces@1.0.23) (2025-06-10)
|
|
6
10
|
|
|
7
11
|
|
package/dist/index.js
CHANGED
|
@@ -787,9 +787,14 @@ var openLink = (space, params) => __async(void 0, null, function* () {
|
|
|
787
787
|
}
|
|
788
788
|
if (params == null ? void 0 : params.akaname) yield updateTopApps(space, params.akaname);
|
|
789
789
|
const spaceId = (params == null ? void 0 : params.payerSpaceId) || ((_c = (_b = space.parents) == null ? void 0 : _b[0]) == null ? void 0 : _c.id);
|
|
790
|
-
const
|
|
790
|
+
const essentialsDomainRegex = /(test|qa(p?)-)?essentials\.availity\.com/;
|
|
791
|
+
const needsSpaceId = !(0, import_resolve_url2.isAbsoluteUrl)(space.link.url) || essentialsDomainRegex.test(space.link.url);
|
|
791
792
|
const urlWithParams = needsSpaceId ? updateUrl(space.link.url, "spaceId", spaceId) : space.link.url;
|
|
792
|
-
|
|
793
|
+
let url = !(0, import_resolve_url2.isAbsoluteUrl)(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
|
|
794
|
+
if (!(0, import_resolve_url2.isAbsoluteUrl)(url) && !essentialsDomainRegex.test(document.referrer) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
|
|
795
|
+
const referrer = new URL(document.referrer);
|
|
796
|
+
url = `${referrer.origin}${url}`;
|
|
797
|
+
}
|
|
793
798
|
const target = getTarget(space.link.target);
|
|
794
799
|
window.open(url, target);
|
|
795
800
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -745,9 +745,14 @@ var openLink = (space, params) => __async(void 0, null, function* () {
|
|
|
745
745
|
}
|
|
746
746
|
if (params == null ? void 0 : params.akaname) yield updateTopApps(space, params.akaname);
|
|
747
747
|
const spaceId = (params == null ? void 0 : params.payerSpaceId) || ((_c = (_b = space.parents) == null ? void 0 : _b[0]) == null ? void 0 : _c.id);
|
|
748
|
-
const
|
|
748
|
+
const essentialsDomainRegex = /(test|qa(p?)-)?essentials\.availity\.com/;
|
|
749
|
+
const needsSpaceId = !isAbsoluteUrl2(space.link.url) || essentialsDomainRegex.test(space.link.url);
|
|
749
750
|
const urlWithParams = needsSpaceId ? updateUrl(space.link.url, "spaceId", spaceId) : space.link.url;
|
|
750
|
-
|
|
751
|
+
let url = !isAbsoluteUrl2(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
|
|
752
|
+
if (!isAbsoluteUrl2(url) && !essentialsDomainRegex.test(document.referrer) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
|
|
753
|
+
const referrer = new URL(document.referrer);
|
|
754
|
+
url = `${referrer.origin}${url}`;
|
|
755
|
+
}
|
|
751
756
|
const target = getTarget(space.link.target);
|
|
752
757
|
window.open(url, target);
|
|
753
758
|
});
|
package/package.json
CHANGED
|
@@ -12,10 +12,18 @@ export const openLink: OpenLink = async (space, params) => {
|
|
|
12
12
|
if (params?.akaname) await updateTopApps(space, params.akaname);
|
|
13
13
|
|
|
14
14
|
const spaceId = params?.payerSpaceId || space.parents?.[0]?.id;
|
|
15
|
+
|
|
16
|
+
const essentialsDomainRegex = /(test|qa(p?)-)?essentials\.availity\.com/;
|
|
15
17
|
const needsSpaceId =
|
|
16
|
-
!isAbsoluteUrl(space.link.url) ||
|
|
18
|
+
!isAbsoluteUrl(space.link.url) || essentialsDomainRegex.test(space.link.url);
|
|
17
19
|
const urlWithParams = needsSpaceId ? updateUrl(space.link.url, 'spaceId', spaceId) : space.link.url;
|
|
18
|
-
|
|
20
|
+
|
|
21
|
+
let url = !isAbsoluteUrl(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
|
|
22
|
+
|
|
23
|
+
if (!isAbsoluteUrl(url) && !essentialsDomainRegex.test(document.referrer) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
|
|
24
|
+
const referrer = new URL(document.referrer);
|
|
25
|
+
url = `${referrer.origin}${url}`
|
|
26
|
+
}
|
|
19
27
|
|
|
20
28
|
const target = getTarget(space.link.target);
|
|
21
29
|
|
|
@@ -29,6 +29,8 @@ const buildSpacesLink = (space: Space, linkAttributes: Record<any, any>) => {
|
|
|
29
29
|
);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
const originalDocumentReferrer = document.referrer;
|
|
33
|
+
|
|
32
34
|
describe('useLink', () => {
|
|
33
35
|
beforeAll(() => {
|
|
34
36
|
// Start the interception.
|
|
@@ -38,9 +40,14 @@ describe('useLink', () => {
|
|
|
38
40
|
Object.defineProperty(window, 'open', { value: jest.fn() });
|
|
39
41
|
});
|
|
40
42
|
afterEach(() => {
|
|
43
|
+
Object.defineProperty(document, 'referrer', {
|
|
44
|
+
writable: true,
|
|
45
|
+
value: originalDocumentReferrer,
|
|
46
|
+
});
|
|
41
47
|
jest.clearAllMocks();
|
|
42
48
|
cleanup();
|
|
43
49
|
server.resetHandlers();
|
|
50
|
+
|
|
44
51
|
});
|
|
45
52
|
|
|
46
53
|
const space: Space = {
|
|
@@ -205,6 +212,8 @@ describe('useLink', () => {
|
|
|
205
212
|
});
|
|
206
213
|
});
|
|
207
214
|
|
|
215
|
+
|
|
216
|
+
|
|
208
217
|
it('should call legacySSO on enter keypress with disclaimerId metadata', async () => {
|
|
209
218
|
space.id = '8';
|
|
210
219
|
space.configurationId = '8';
|
|
@@ -228,6 +237,7 @@ describe('useLink', () => {
|
|
|
228
237
|
});
|
|
229
238
|
});
|
|
230
239
|
|
|
240
|
+
|
|
231
241
|
it('should call ssoId onclick with ssoId metadata', async () => {
|
|
232
242
|
space.id = '9';
|
|
233
243
|
space.configurationId = '9';
|
|
@@ -276,4 +286,50 @@ describe('useLink', () => {
|
|
|
276
286
|
expect(window.open).not.toHaveBeenCalled();
|
|
277
287
|
});
|
|
278
288
|
});
|
|
289
|
+
|
|
290
|
+
it('should build relative onprem path to full url - t14', async () => {
|
|
291
|
+
Object.defineProperty(document, 'referrer', {
|
|
292
|
+
value: new URL("https://t14-apps.availity.com"),
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
space.id = '11';
|
|
296
|
+
space.configurationId = '11';
|
|
297
|
+
space.link = { text: 'the link', target: '_self', url: '/public/spaces/url' };
|
|
298
|
+
space.type = 'APPLICATION';
|
|
299
|
+
space.meta = {};
|
|
300
|
+
|
|
301
|
+
const { container } = render(buildSpacesLink(space, { spaceId: space.id }));
|
|
302
|
+
|
|
303
|
+
const linkHeader11 = await waitFor(() => container.querySelector('#app-title-11'));
|
|
304
|
+
|
|
305
|
+
if (linkHeader11) fireEvent.click(linkHeader11);
|
|
306
|
+
|
|
307
|
+
await waitFor(() => {
|
|
308
|
+
expect(window.open).toHaveBeenCalledWith('https://t14-apps.availity.com/public/spaces/url?spaceId=11', '_self');
|
|
309
|
+
expect(nativeForm).not.toHaveBeenCalled();
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it('should build relative onprem path to full url - test', async () => {
|
|
314
|
+
Object.defineProperty(document, 'referrer', {
|
|
315
|
+
value: new URL("https://test-apps.availity.com"),
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
space.id = '12';
|
|
319
|
+
space.configurationId = '12';
|
|
320
|
+
space.link = { text: 'the link', target: '_self', url: '/public/spaces/url' };
|
|
321
|
+
space.type = 'APPLICATION';
|
|
322
|
+
space.meta = {};
|
|
323
|
+
|
|
324
|
+
const { container } = render(buildSpacesLink(space, { spaceId: space.id }));
|
|
325
|
+
|
|
326
|
+
const linkHeader = await waitFor(() => container.querySelector('#app-title-12'));
|
|
327
|
+
|
|
328
|
+
if (linkHeader) fireEvent.click(linkHeader);
|
|
329
|
+
|
|
330
|
+
await waitFor(() => {
|
|
331
|
+
expect(window.open).toHaveBeenCalledWith('https://test-apps.availity.com/public/spaces/url?spaceId=12', '_self');
|
|
332
|
+
expect(nativeForm).not.toHaveBeenCalled();
|
|
333
|
+
});
|
|
334
|
+
});
|
|
279
335
|
});
|