Skip to content

Commit 0b6214c

Browse files
vishalshrm539Sharma
andauthored
Fixed incorrect view metadata due to incorrect pageClass (#493)
Co-authored-by: Sharma <[email protected]>
1 parent 8a86f61 commit 0b6214c

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

packages/react-sdk-components/src/components/infra/Containers/ViewContainer/ViewContainer.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
12
import React, { createElement, useContext, useEffect, useState } from 'react';
23
import { Box, CircularProgress } from '@mui/material';
34

45
import createPConnectComponent from '../../../../bridge/react_pconnect';
56
import StoreContext from '../../../../bridge/Context/StoreContext';
67
import { isEmptyObject } from '../../../helpers/common-utils';
78
import type { PConnProps } from '../../../../types/PConnProps';
9+
import { configureBrowserBookmark } from '../container-helpers';
810

911
interface ViewContainerProps extends PConnProps {
1012
// If any, enter additional props that only exist on this component
@@ -131,10 +133,7 @@ export default function ViewContainer(props: ViewContainerProps) {
131133

132134
if (!displayOnlyFA) {
133135
// configureForBrowserBookmark not applicable in Embedded mode
134-
PCore.configureForBrowserBookmark({
135-
...objectForAddContainer,
136-
defaultViewLabel
137-
});
136+
configureBrowserBookmark(pConn);
138137
}
139138
}, []);
140139

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
1+
// eslint-disable-next-line import/prefer-default-export
12
export const isContainerInitialized = (pConnect) => {
23
const context = pConnect.getContextName();
34
const containerName = pConnect.getContainerName();
45
return PCore.getContainerUtils().isContainerInitialized(context, containerName);
56
};
7+
8+
export const configureBrowserBookmark = (pConnect) => {
9+
const context = pConnect.getContextName();
10+
const containerName = pConnect.getContainerName();
11+
const envInfo = PCore.getEnvironmentInfo();
12+
const { APP } = PCore.getConstants();
13+
14+
const navPages = pConnect.getValue('pyPortal.pyPrimaryNavPages');
15+
let ruleName = '';
16+
let className = '';
17+
let defaultViewLabel = '';
18+
19+
const isNextGenLandingPageRouting = (envInfo?.environmentInfoObject as any)?.pyExecutionRuntimeName === (APP as any).INFINITY_RUNTIME;
20+
21+
if (Array.isArray(navPages) && navPages.length > 0) {
22+
const firstNavPage = navPages[0];
23+
const nestedNavPage = firstNavPage.NavigationPages?.[0];
24+
25+
if (isNextGenLandingPageRouting) {
26+
if (nestedNavPage?.pyRuleName) {
27+
ruleName = nestedNavPage.pyRuleName;
28+
className = nestedNavPage.pyClassName || '';
29+
} else if (firstNavPage?.pyRuleName) {
30+
ruleName = firstNavPage.pyRuleName;
31+
className = firstNavPage.pyClassName || '';
32+
} else if (nestedNavPage?.pyLabel) {
33+
defaultViewLabel = nestedNavPage.pyLabel;
34+
} else if (firstNavPage?.pyLabel) {
35+
defaultViewLabel = firstNavPage.pyLabel;
36+
}
37+
} else if (nestedNavPage?.pyLabel) {
38+
defaultViewLabel = nestedNavPage.pyLabel;
39+
} else if (firstNavPage?.pyLabel) {
40+
defaultViewLabel = firstNavPage.pyLabel;
41+
}
42+
}
43+
44+
PCore.configureForBrowserBookmark({
45+
context,
46+
containerName,
47+
acName: containerName,
48+
semanticURL: '',
49+
defaultViewLabel,
50+
ruleName,
51+
className
52+
});
53+
};

0 commit comments

Comments
 (0)