Skip to content

Commit e8f8877

Browse files
4manasamanasa
andauthored
Added QuickCreate component to support Quick links in wss portal (#305)
Co-authored-by: manasa <[email protected]>
1 parent dfc1cda commit e8f8877

File tree

8 files changed

+131
-3
lines changed

8 files changed

+131
-3
lines changed

src/bridge/react_pconnect.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import SemanticLink from '../components/forms/SemanticLink';
5454
import UserReference from '../components/forms/UserReference';
5555
import Confirmation from '../components/templates/Confirmation';
5656
import BannerPage from '../components/templates/BannerPage';
57+
import QuickCreate from '../components/widgets/QuickCreate';
5758

5859
const connectRedux = (component, c11nEnv) => {
5960

@@ -336,6 +337,10 @@ const getComponent = (c11nEnv, declarative) => {
336337
component = SemanticLink;
337338
break;
338339

340+
case "QuickCreate":
341+
component = QuickCreate;
342+
break;
343+
339344
default:
340345
// eslint-disable-next-line no-console
341346
console.log( `getComponent doesn't have an entry for type ${type}`);

src/components/designSystemExtensions/Banner/index.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+
}

src/components/templates/AppShell/index.tsx

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

src/components/templates/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+
}

src/components/templates/WssNavBar/index.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 '../../designSystemExtensions/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+
}

0 commit comments

Comments
 (0)