@availity/mui-spaces 1.0.23 → 1.0.24

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 CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [1.0.24](https://github.com/Availity/element/compare/@availity/mui-spaces@1.0.23...@availity/mui-spaces@1.0.24) (2025-06-11)
6
+
5
7
  ## [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
8
 
7
9
 
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 needsSpaceId = !(0, import_resolve_url2.isAbsoluteUrl)(space.link.url) || /(test|qa(p?)-)?essentials\.availity\.com/.test(space.link.url);
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
- const url = !(0, import_resolve_url2.isAbsoluteUrl)(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
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(window.location.origin) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
795
+ const appsDomain = window.location.origin.replace("essentials", "apps");
796
+ url = `${appsDomain}${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 needsSpaceId = !isAbsoluteUrl2(space.link.url) || /(test|qa(p?)-)?essentials\.availity\.com/.test(space.link.url);
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
- const url = !isAbsoluteUrl2(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
751
+ let url = !isAbsoluteUrl2(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
752
+ if (!isAbsoluteUrl2(url) && essentialsDomainRegex.test(window.location.origin) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
753
+ const appsDomain = window.location.origin.replace("essentials", "apps");
754
+ url = `${appsDomain}${url}`;
755
+ }
751
756
  const target = getTarget(space.link.target);
752
757
  window.open(url, target);
753
758
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/mui-spaces",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "Availity MUI Spaces Component - part of the @availity/element design system",
5
5
  "keywords": [
6
6
  "react",
@@ -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) || /(test|qa(p?)-)?essentials\.availity\.com/.test(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
- const url = !isAbsoluteUrl(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
20
+
21
+ let url = !isAbsoluteUrl(space.link.url) ? getUrl(urlWithParams, false, false) : urlWithParams;
22
+
23
+ if (!isAbsoluteUrl(url) && essentialsDomainRegex.test(window.location.origin) && /\/web\/|\/public\/(apps|spaces)/.test(url)) {
24
+ const appsDomain = window.location.origin.replace("essentials", "apps");
25
+ url = `${appsDomain}${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 originalWindowLocation = window.location;
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(window, 'location', {
44
+ writable: true,
45
+ value: originalWindowLocation,
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,27 @@ describe('useLink', () => {
276
286
  expect(window.open).not.toHaveBeenCalled();
277
287
  });
278
288
  });
289
+
290
+ it('should replace essentials with apps for onprem', async () => {
291
+ Object.defineProperty(window, 'location', {
292
+ value: new URL("https://test-essentials.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://test-apps.availity.com/public/spaces/url?spaceId=11', '_self');
309
+ expect(nativeForm).not.toHaveBeenCalled();
310
+ });
311
+ });
279
312
  });