@pega/react-sdk-overrides 0.25.4 → 0.25.5

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.
@@ -1,3 +1,145 @@
1
+ import { Avatar, Card, CardHeader, Divider, Typography } from '@mui/material';
2
+ import makeStyles from '@mui/styles/makeStyles';
3
+ import Grid2 from '@mui/material/Grid2';
4
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
5
+ import { prepareCaseSummaryData, filterUtilities } from '@pega/react-sdk-components/lib/components/template/utils';
6
+ import { Utils } from '@pega/react-sdk-components/lib/components/helpers/utils';
7
+
8
+ const useStyles = makeStyles(theme => ({
9
+ root: {
10
+ paddingRight: theme.spacing(1),
11
+ paddingLeft: theme.spacing(1),
12
+ paddingTop: theme.spacing(1),
13
+ paddingBottom: theme.spacing(1),
14
+ marginRight: theme.spacing(1),
15
+ marginLeft: theme.spacing(1),
16
+ marginTop: theme.spacing(1),
17
+ marginBottom: theme.spacing(1)
18
+ },
19
+ caseViewHeader: {
20
+ backgroundColor: theme.palette.info.light,
21
+ color: theme.palette.getContrastText(theme.palette.info.light),
22
+ borderRadius: 'inherit'
23
+ },
24
+ caseViewIconBox: {
25
+ backgroundColor: theme.palette.info.dark,
26
+ width: theme.spacing(8),
27
+ height: theme.spacing(8),
28
+ padding: theme.spacing(1)
29
+ },
30
+ caseViewIconImage: {
31
+ filter: 'var(--svg-color)'
32
+ }
33
+ }));
34
+
1
35
  export default function SelfServiceCaseView(props) {
2
- console.log('SelfServiceCaseView props:', props);
36
+ const classes = useStyles();
37
+ const CaseViewActionsMenu = getComponentFromMap('CaseViewActionsMenu');
38
+ const CaseSummary = getComponentFromMap('CaseSummary');
39
+ const {
40
+ icon = '',
41
+ getPConnect,
42
+ header,
43
+ subheader,
44
+ showCaseLifecycle = true,
45
+ showSummaryRegion = true,
46
+ showUtilitiesRegion = true,
47
+ showCaseActions = true,
48
+ children,
49
+ caseClass,
50
+ caseInfo: { availableActions = [], availableProcesses = [], caseTypeID = '', caseTypeName = '' }
51
+ } = props;
52
+ const pConnect = getPConnect();
53
+ const [bShowCaseLifecycle, bShowSummaryRegion, bShowUtilitiesRegion, bShowCaseActions] = [
54
+ showCaseLifecycle,
55
+ showSummaryRegion,
56
+ showUtilitiesRegion,
57
+ showCaseActions
58
+ ].map((prop: boolean | string) => prop === true || prop === 'true');
59
+ const isObjectType: boolean = (PCore.getCaseUtils() as any).isObjectCaseType(caseClass);
60
+ const localeKey = pConnect?.getCaseLocaleReference();
61
+ const svgCase = Utils.getImageSrc(icon, Utils.getSDKStaticConentUrl());
62
+ const renderedRegions: any = isObjectType
63
+ ? {
64
+ caseSummary: children[0],
65
+ utilities: filterUtilities(children[2])
66
+ }
67
+ : {
68
+ caseSummary: children[0],
69
+ stages: children[1],
70
+ todo: children[2],
71
+ utilities: filterUtilities(children[4])
72
+ };
73
+ const { primarySummaryFields, secondarySummaryFields } = prepareCaseSummaryData(
74
+ renderedRegions.caseSummary,
75
+ (config: any) => config?.availableInChannel?.selfService === true
76
+ );
77
+
78
+ const isUtilitiesRegionNotEmpty: () => boolean = () => {
79
+ const utilitiesElement = renderedRegions.utilities;
80
+ if (utilitiesElement?.props?.getPConnect()?.getChildren()?.length > 0) {
81
+ return utilitiesElement.props
82
+ .getPConnect()
83
+ .getChildren()
84
+ .some((prop: { getPConnect: () => any }) => prop.getPConnect().getConfigProps().visibility !== false);
85
+ }
86
+ return false;
87
+ };
88
+
89
+ return (
90
+ <div>
91
+ {bShowCaseActions && (
92
+ <div style={{ display: 'flex', justifyContent: 'space-around', alignItems: 'center', margin: '10px' }}>
93
+ <div>{PCore.getLocaleUtils().getLocaleValue(header, '', localeKey)}</div>
94
+ <CaseViewActionsMenu
95
+ getPConnect={getPConnect}
96
+ availableActions={availableActions}
97
+ availableProcesses={availableProcesses}
98
+ caseTypeName={caseTypeName}
99
+ caseTypeID={caseTypeID}
100
+ />
101
+ </div>
102
+ )}
103
+ <div>
104
+ <Grid2 container>
105
+ <Grid2 size={{ xs: 3 }}>
106
+ {bShowSummaryRegion && (primarySummaryFields.length > 0 || secondarySummaryFields.length > 0) && (
107
+ <div>
108
+ <Card className={classes.root}>
109
+ <CardHeader
110
+ className={classes.caseViewHeader}
111
+ title={
112
+ <Typography variant='h6' component='div' id='case-name'>
113
+ {PCore.getLocaleUtils().getLocaleValue(header, '', localeKey)}
114
+ </Typography>
115
+ }
116
+ subheader={
117
+ <Typography variant='body1' component='div' id='caseId'>
118
+ {subheader}
119
+ </Typography>
120
+ }
121
+ avatar={
122
+ <Avatar className={classes.caseViewIconBox} variant='square'>
123
+ <img src={svgCase} className={classes.caseViewIconImage} />
124
+ </Avatar>
125
+ }
126
+ />
127
+ <Divider />
128
+ <CaseSummary arPrimaryFields={primarySummaryFields} arSecondaryFields={secondarySummaryFields}></CaseSummary>
129
+ <Divider />
130
+ </Card>
131
+ </div>
132
+ )}
133
+ </Grid2>
134
+
135
+ <Grid2 size={{ xs: 6 }}>
136
+ {bShowCaseLifecycle && renderedRegions.stages}
137
+ {renderedRegions.todo}
138
+ </Grid2>
139
+
140
+ {bShowUtilitiesRegion && isUtilitiesRegionNotEmpty() && <Grid2 size={{ xs: 3 }}>{renderedRegions.utilities}</Grid2>}
141
+ </Grid2>
142
+ </div>
143
+ </div>
144
+ );
3
145
  }
@@ -36,8 +36,8 @@ const useStyles = makeStyles(theme => ({
36
36
  marginRight: theme.spacing(2)
37
37
  },
38
38
  appListLogo: {
39
- width: '3.6rem',
40
- filter: 'var(--svg-color)'
39
+ maxWidth: '100%',
40
+ height: '3rem'
41
41
  },
42
42
  appName: {
43
43
  marginLeft: theme.spacing(2),
@@ -85,7 +85,7 @@ export default function WssNavBar(props: WssNavBarProps) {
85
85
  return (
86
86
  <div id='NavBar' className='nav-bar'>
87
87
  <AppBar position='static' color='primary'>
88
- <Container maxWidth='xl'>
88
+ <Container maxWidth={false}>
89
89
  <Toolbar disableGutters style={{ justifyContent: 'space-between' }}>
90
90
  <Button id='appName' style={{ textTransform: 'capitalize' }} onClick={appInfo.onClick}>
91
91
  <img src={appInfo.imageSrc} className={classes.appListLogo} />
@@ -0,0 +1,58 @@
1
+ import type { ReactNode } from 'react';
2
+ import { isValidElement } from 'react';
3
+
4
+ export function prepareCaseSummaryData(caseSummaryRegion, portalSpecificVisibilityChecker?) {
5
+ const filterVisibleChildren = children => {
6
+ return children
7
+ ?.getPConnect()
8
+ ?.getChildren()
9
+ ?.filter(child => {
10
+ const configProps = child.getPConnect().getConfigProps();
11
+ const defaultVisibilityCn = !('visibility' in configProps) || configProps.visibility === true;
12
+ return defaultVisibilityCn && (portalSpecificVisibilityChecker?.(configProps) ?? true);
13
+ });
14
+ };
15
+ const convertChildrenToSummaryData = children => {
16
+ return children?.map(childItem => {
17
+ const childPConnData = childItem.getPConnect().resolveConfigProps(childItem.getPConnect().getRawMetadata());
18
+ return childPConnData;
19
+ });
20
+ };
21
+
22
+ const summaryFieldChildren = caseSummaryRegion.props
23
+ .getPConnect()
24
+ .getChildren()[0]
25
+ ?.getPConnect()
26
+ ?.getReferencedViewPConnect()
27
+ ?.getPConnect()
28
+ ?.getChildren();
29
+
30
+ const primarySummaryFields =
31
+ summaryFieldChildren && summaryFieldChildren.length > 0
32
+ ? convertChildrenToSummaryData(filterVisibleChildren(summaryFieldChildren[0]))
33
+ : undefined;
34
+ const secondarySummaryFields =
35
+ summaryFieldChildren && summaryFieldChildren.length > 1
36
+ ? convertChildrenToSummaryData(filterVisibleChildren(summaryFieldChildren[1]))
37
+ : undefined;
38
+
39
+ return {
40
+ primarySummaryFields,
41
+ secondarySummaryFields
42
+ };
43
+ }
44
+
45
+ export const filterUtilities = (utils: ReactNode) => {
46
+ let utilsMeta;
47
+ if (isValidElement(utils)) {
48
+ const pConnect = utils.props.getPConnect();
49
+ utilsMeta = pConnect.getRawMetadata?.();
50
+ if (!utilsMeta?.children?.length) return;
51
+ utilsMeta = {
52
+ ...utilsMeta,
53
+ children: utilsMeta.children.filter((child: any) => child.config?.availableInChannel?.selfService === true)
54
+ };
55
+ return utilsMeta.children?.length ? pConnect.createComponent(utilsMeta) : undefined;
56
+ }
57
+ return utilsMeta;
58
+ };
@@ -82,19 +82,15 @@ function getID(assignment: any) {
82
82
 
83
83
  const useStyles = makeStyles(theme => ({
84
84
  root: {
85
- marginTop: theme.spacing(1),
86
85
  marginBottom: theme.spacing(1),
87
86
  paddingBottom: theme.spacing(1),
88
- borderLeft: '6px solid',
89
- borderLeftColor: theme.palette.primary.light
87
+ borderRadius: 16
90
88
  },
91
89
  avatar: {
92
90
  backgroundColor: theme.palette.primary.light,
93
91
  color: theme.palette.getContrastText(theme.palette.primary.light)
94
92
  },
95
93
  todoWrapper: {
96
- borderLeft: '6px solid',
97
- borderLeftColor: theme.palette.primary.light,
98
94
  padding: theme.spacing(1),
99
95
  margin: theme.spacing(1)
100
96
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/react-sdk-overrides",
3
- "version": "0.25.4",
3
+ "version": "0.25.5",
4
4
  "description": "React SDK - Code for overriding components",
5
5
  "_filesComment": "During packing, npm ignores everything NOT in the files list",
6
6
  "files": [