Skip to content

Commit 4e029ab

Browse files
authored
Added QuickCreate component to support Quick links in wss portal (#107)
* Added QuickCreate component to support Quick links in wss portal
1 parent cb6114e commit 4e029ab

File tree

11 files changed

+138
-5
lines changed

11 files changed

+138
-5
lines changed

packages/react-sdk-components/src/components/designSystemExtension/Banner/Banner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default function Banner(props) {
66
const { a, b, banner } = props;
77
const { title, message, backgroundImage } = banner;
88
return (
9-
<div>
9+
<div style={{ marginBottom: '2rem' }}>
1010
<div
1111
className='background-image-style'
1212
style={{ backgroundImage: `url(${backgroundImage})` }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.quick-link-ul-list {
2+
list-style: none;
3+
padding: 0;
4+
grid-template-columns: repeat(3, 1fr);
5+
display: grid;
6+
gap: calc(1rem);
7+
}
8+
9+
.quick-link-list {
10+
background-color: #3f51b5;
11+
color: white;
12+
border-radius: 8px;
13+
}
14+
15+
.quick-link-button {
16+
text-transform: capitalize !important;
17+
font-size: 16px !important;
18+
color: white !important;
19+
padding: calc(0.5rem * 2) !important;
20+
height: 6rem;
21+
width: 100%;
22+
justify-content: start !important;
23+
}
24+
25+
.quick-link-icon {
26+
width: 1em;
27+
height: 1em;
28+
flex-shrink: 0;
29+
filter: invert(100%);
30+
}
31+
32+
.quick-link-button-span {
33+
display: flex;
34+
align-items: center;
35+
gap: 0.5rem;
36+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import { Button } from '@material-ui/core';
3+
import './WssQuickCreate.css';
4+
5+
export default function WssQuickCreate(props) {
6+
const { heading, actions } = props;
7+
8+
return (
9+
<div>
10+
<h1>{heading}</h1>
11+
<ul className='quick-link-ul-list'>
12+
{actions &&
13+
actions.map(element => {
14+
return (
15+
<li className='quick-link-list' key={element.label}>
16+
<Button className='quick-link-button' onClick={element.onClick}>
17+
<span className='quick-link-button-span'>
18+
{element.icon && <img className='quick-link-icon' src={element.icon}/>}
19+
<span>{element.label}</span>
20+
</span>
21+
</Button>
22+
</li>
23+
);
24+
})}
25+
</ul>
26+
</div>
27+
);
28+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './WssQuickCreate';

packages/react-sdk-components/src/components/template/AppShell/AppShell.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const useStyles = makeStyles(theme => ({
2424
wsscontent: {
2525
flexGrow: 1,
2626
height: '100vh',
27-
overflow: 'auto',
2827
marginLeft: theme.spacing(1),
2928
marginRight: theme.spacing(1)
3029
}

packages/react-sdk-components/src/components/template/WssNavBar/WssNavBar.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
text-transform: capitalize !important;
44
font-size: 1rem !important;
55
}
6+
7+
.nav-bar {
8+
position: sticky;
9+
inset-block-start: 0;
10+
z-index: 100;
11+
}

packages/react-sdk-components/src/components/template/WssNavBar/WssNavBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default function WssNavBar(props) {
5656
};
5757

5858
return (
59-
<div id='NavBar'>
59+
<div id='NavBar' className='nav-bar'>
6060
<AppBar position='static' color='primary'>
6161
<Container maxWidth='xl'>
6262
<Toolbar disableGutters>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import React from "react";
2+
import WssQuickCreate from '../../designSystemExtension/WssQuickCreate';
3+
import { Utils } from '../../helpers/utils';
4+
5+
declare const PCore: any;
6+
7+
export default function QuickCreate(props) {
8+
const { getPConnect, heading, showCaseIcons, classFilter } = props;
9+
const pConn = getPConnect();
10+
const createCase = (className) => {
11+
pConn
12+
.getActionsApi()
13+
.createWork(className, {})
14+
.catch((error) => {
15+
// eslint-disable-next-line no-console
16+
console.log('Error in case creation: ', error?.message)
17+
});
18+
};
19+
20+
const cases: any = [];
21+
const envInfo = PCore.getEnvironmentInfo();
22+
if (
23+
classFilter &&
24+
envInfo.environmentInfoObject &&
25+
envInfo.environmentInfoObject.pyCaseTypeList &&
26+
envInfo.environmentInfoObject.pyCaseTypeList.length > 0
27+
) {
28+
classFilter.forEach((item) => {
29+
let icon = Utils.getImageSrc('polaris-solid', PCore.getAssetLoader().getStaticServerUrl());
30+
let label = '';
31+
envInfo.environmentInfoObject.pyCaseTypeList.forEach((casetype) => {
32+
if (casetype.pyWorkTypeImplementationClassName === item) {
33+
icon = casetype.pxIcon && Utils.getImageSrc(casetype?.pxIcon, PCore.getAssetLoader().getStaticServerUrl());
34+
label = casetype.pyWorkTypeName ?? '';
35+
}
36+
});
37+
if (label !== '') {
38+
cases.push({
39+
label,
40+
onClick: () => {
41+
createCase(item);
42+
},
43+
...(showCaseIcons && { icon })
44+
});
45+
}
46+
});
47+
}
48+
49+
return (
50+
<div>
51+
<WssQuickCreate heading={heading} actions={cases}></WssQuickCreate>
52+
</div>
53+
);
54+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './QuickCreate';

packages/react-sdk-components/src/sdk-pega-component-map.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import Percentage from './components/field/Percentage';
6262
import Phone from './components/field/Phone/Phone';
6363
import PromotedFilters from './components/template/PromotedFilters';
6464
import Pulse from './components/designSystemExtension/Pulse';
65+
import QuickCreate from './components/widget/QuickCreate';
6566
import RadioButtons from './components/field/RadioButtons';
6667
import Reference from './components/infra/Reference/Reference';
6768
import Region from './components/infra/Region/Region';
@@ -93,6 +94,7 @@ import WideNarrowDetails from './components/template/WideNarrow/WideNarrowDetail
9394
import WideNarrowForm from './components/template/WideNarrow/WideNarrowForm';
9495
import WideNarrowPage from './components/template/WideNarrow/WideNarrowPage';
9596
import WssNavBar from './components/template/WssNavBar/WssNavBar';
97+
import WssQuickCreate from './components/designSystemExtension/WssQuickCreate';
9698

9799
// pegaSdkComponentMap is the JSON object where we'll store the components that are
98100
// the default implementations provided by the SDK. These will be used if there isn't
@@ -163,6 +165,7 @@ const pegaSdkComponentMap = {
163165
'Phone': Phone,
164166
'PromotedFilters': PromotedFilters,
165167
'Pulse': Pulse,
168+
'QuickCreate': QuickCreate,
166169
'reference': Reference,
167170
'RadioButtons': RadioButtons,
168171
'Region': Region,
@@ -193,7 +196,8 @@ const pegaSdkComponentMap = {
193196
'WideNarrowDetails': WideNarrowDetails,
194197
'WideNarrowForm': WideNarrowForm,
195198
'WideNarrowPage': WideNarrowPage,
196-
'WssNavBar': WssNavBar
199+
'WssNavBar': WssNavBar,
200+
'WssQuickcreate': WssQuickCreate
197201
};
198202

199203
export default pegaSdkComponentMap;

0 commit comments

Comments
 (0)