@pega/custom-dx-components 0.24.15 → 0.24.16
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/package.json +1 -1
- package/src/tasks/create/templates/Constellation/Template/DETAILS/Avatar.tsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/Operator.tsx.mustache +218 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS/demo.stories.tsx.mustache +46 -13
- package/src/tasks/create/templates/Constellation/Template/DETAILS/index.tsx.mustache +2 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS/mock.ts.mustache +55 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/Avatar.tsx.mustache +78 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/Operator.tsx.mustache +218 -0
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/demo.stories.tsx.mustache +46 -12
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/index.tsx.mustache +2 -2
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/mock.ts.mustache +55 -0
- package/src/tasks/create/templates/Constellation/Template/FORM/index.tsx.mustache +1 -1
- package/src/tasks/create/templates/Constellation/Template/FORM-region/index.tsx.mustache +2 -2
- package/src/tasks/init/template/package.json.mustache +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/demo.stories.tsx +46 -13
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/index.tsx +2 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyForm/index.tsx +1 -1
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/demo.stories.tsx +46 -12
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/index.tsx +2 -2
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnForm/index.tsx +2 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/demo.stories.tsx +46 -13
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/index.tsx +2 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyForm/index.tsx +1 -1
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/Avatar.tsx +78 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/Operator.tsx +215 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/demo.stories.tsx +46 -12
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/index.tsx +2 -2
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/mock.ts +55 -0
- package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnForm/index.tsx +2 -2
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
5
|
import { Text, FieldValueList, Button, DateTimeDisplay, useTheme } from '@pega/cosmos-react-core';
|
|
6
6
|
import PegaDxilMyTwoColumnDetails from './index';
|
|
7
|
-
import { pyReviewRaw, pyReviewResolved, regionChildrenResolved } from './mock';
|
|
7
|
+
import { pyReviewRaw, pyReviewResolved, regionChildrenResolved, operatorDetails, configProps } from './mock';
|
|
8
8
|
import StatusWorkRenderer from './StatusWork';
|
|
9
|
+
import Operator from './Operator';
|
|
9
10
|
|
|
10
11
|
const meta: Meta<typeof PegaDxilMyTwoColumnDetails> = {
|
|
11
12
|
title: 'PegaDxilMyTwoColumnDetails',
|
|
@@ -19,6 +20,28 @@ const meta: Meta<typeof PegaDxilMyTwoColumnDetails> = {
|
|
|
19
20
|
export default meta;
|
|
20
21
|
type Story = StoryObj<typeof PegaDxilMyTwoColumnDetails>;
|
|
21
22
|
|
|
23
|
+
if (!window.PCore) {
|
|
24
|
+
window.PCore = {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
window.PCore.getLocaleUtils = () => {
|
|
28
|
+
return {
|
|
29
|
+
getLocaleValue: value => {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
window.PCore.getUserApi = () => {
|
|
36
|
+
return {
|
|
37
|
+
getOperatorDetails: () => {
|
|
38
|
+
return new Promise(resolve => {
|
|
39
|
+
resolve(operatorDetails);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
22
45
|
const Region = props => {
|
|
23
46
|
return <></>;
|
|
24
47
|
};
|
|
@@ -58,19 +81,30 @@ const renderField = resolvedProps => {
|
|
|
58
81
|
|
|
59
82
|
if (displayAsStatus === true) val = <StatusWorkRenderer value={value} key={key} />;
|
|
60
83
|
|
|
84
|
+
const [_label] =
|
|
85
|
+
label === 'Create operator'
|
|
86
|
+
? [configProps.createLabel, configProps.createOperator, configProps.createDateTime]
|
|
87
|
+
: label === 'Update operator'
|
|
88
|
+
? [configProps.updateLabel, configProps.updateOperator, configProps.updateDateTime]
|
|
89
|
+
: [configProps.resolveLabel, configProps.resolveOperator, configProps.resolveDateTime];
|
|
90
|
+
|
|
61
91
|
if (label === 'Create Operator')
|
|
62
92
|
val = (
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
|
|
93
|
+
<Operator
|
|
94
|
+
label={configProps.hideLabel ? '' : _label}
|
|
95
|
+
name={configProps.createOperator.userName}
|
|
96
|
+
id={configProps.createOperator.userId}
|
|
97
|
+
value={undefined}
|
|
98
|
+
validatemessage=''
|
|
99
|
+
hideLabel={false}
|
|
100
|
+
readOnly={false}
|
|
101
|
+
required={false}
|
|
102
|
+
disabled={false}
|
|
103
|
+
externalUser={undefined}
|
|
104
|
+
metaObj={undefined}
|
|
105
|
+
testId=''
|
|
106
|
+
helperText=''
|
|
107
|
+
/>
|
|
74
108
|
);
|
|
75
109
|
|
|
76
110
|
if (variant === 'inline') {
|
package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/index.tsx
CHANGED
|
@@ -35,7 +35,7 @@ function PegaDxilMyTwoColumnDetails(props: PegaDxilMyTwoColumnDetailsProps) {
|
|
|
35
35
|
const numRegions = getAllFields(getPConnect)?.length;
|
|
36
36
|
const gridRepeat = "repeat(".concat(numRegions).concat(", 1fr)");
|
|
37
37
|
|
|
38
|
-
const gridContainer: GridContainerProps = { colGap:
|
|
38
|
+
const gridContainer: GridContainerProps = { colGap: 6 };
|
|
39
39
|
gridContainer.cols = gridRepeat;
|
|
40
40
|
gridContainer.alignItems = 'start';
|
|
41
41
|
|
|
@@ -73,7 +73,7 @@ function PegaDxilMyTwoColumnDetails(props: PegaDxilMyTwoColumnDetailsProps) {
|
|
|
73
73
|
{children.map((child: any, i: number) => (
|
|
74
74
|
<Flex
|
|
75
75
|
// @ts-ignore
|
|
76
|
-
container={{ direction: 'column', alignItems: 'normal', colGap:
|
|
76
|
+
container={{ direction: 'column', alignItems: 'normal', colGap: 1, rowGap: 1.5 }}
|
|
77
77
|
key={`r-${i + 1}`}
|
|
78
78
|
>
|
|
79
79
|
<DetailsRender child={child} />
|
package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/mock.ts
CHANGED
|
@@ -233,3 +233,58 @@ export const regionChildrenResolved = [
|
|
|
233
233
|
key: 'SLA Start Time'
|
|
234
234
|
}
|
|
235
235
|
];
|
|
236
|
+
|
|
237
|
+
export const operatorDetails = {
|
|
238
|
+
data: {
|
|
239
|
+
pzLoadTime: 'January 18, 2023 10:33:19 AM EST',
|
|
240
|
+
pzPageNameHash: '_pa1519192551088960pz',
|
|
241
|
+
pyOperatorInfo: {
|
|
242
|
+
pyUserName: 'french DigV2',
|
|
243
|
+
pyPosition: '',
|
|
244
|
+
pyImageInsKey: '',
|
|
245
|
+
pySkills: [
|
|
246
|
+
{
|
|
247
|
+
pySkillName: '',
|
|
248
|
+
pzIndexOwnerKey: 'DATA-ADMIN-OPERATOR-ID FRENCHTEST.DIGV2',
|
|
249
|
+
pySkillRating: 0
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
pyReportToUserName: '',
|
|
253
|
+
pyReportTo: '',
|
|
254
|
+
pyOrganization: 'DXIL',
|
|
255
|
+
pyTitle: '',
|
|
256
|
+
pyLabel: 'frenchTest.DigV2',
|
|
257
|
+
pyEmailAddress: 'User@DigV2',
|
|
258
|
+
pyTelephone: ''
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
status: 200,
|
|
262
|
+
statusText: '',
|
|
263
|
+
headers: {
|
|
264
|
+
'content-length': '435',
|
|
265
|
+
'content-type': 'application/json;charset=UTF-8'
|
|
266
|
+
},
|
|
267
|
+
request: {}
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
export const configProps = {
|
|
271
|
+
label: 'Create operator',
|
|
272
|
+
createLabel: 'Created',
|
|
273
|
+
updateLabel: 'Updated',
|
|
274
|
+
updateDateTime: '2023-01-16T14:53:33.280Z',
|
|
275
|
+
createDateTime: '2023-01-16T14:53:33.198Z',
|
|
276
|
+
updateOperator: {
|
|
277
|
+
userId: 'admin@mediaco',
|
|
278
|
+
userName: 'admin'
|
|
279
|
+
},
|
|
280
|
+
createOperator: {
|
|
281
|
+
userId: 'admin@mediaco',
|
|
282
|
+
userName: 'admin'
|
|
283
|
+
},
|
|
284
|
+
resolveLabel: '',
|
|
285
|
+
resolveOperator: '',
|
|
286
|
+
resolveDateTime: '',
|
|
287
|
+
hideLabel: true,
|
|
288
|
+
key: '_532zx1dah',
|
|
289
|
+
displayMode: 'LABELS_LEFT'
|
|
290
|
+
};
|
|
@@ -22,7 +22,7 @@ function PegaDxilMyTwoColumnForm(props: PegaDxilMyTwoColumnFormProps) {
|
|
|
22
22
|
|
|
23
23
|
const numRegions = children?.length;
|
|
24
24
|
const gridRepeat = "repeat(".concat(numRegions).concat(", 1fr)");
|
|
25
|
-
const gridContainer = {"colGap" :
|
|
25
|
+
const gridContainer = {"colGap" : 6};
|
|
26
26
|
// @ts-ignore
|
|
27
27
|
gridContainer.cols = gridRepeat;
|
|
28
28
|
// @ts-ignore
|
|
@@ -40,7 +40,7 @@ function PegaDxilMyTwoColumnForm(props: PegaDxilMyTwoColumnFormProps) {
|
|
|
40
40
|
{children.map((child: any, i: number) => (
|
|
41
41
|
<Flex
|
|
42
42
|
// @ts-ignore
|
|
43
|
-
container={{ direction: 'column', alignItems: 'normal', colGap:
|
|
43
|
+
container={{ direction: 'column', alignItems: 'normal', colGap: 1, rowGap: 1.5 }}
|
|
44
44
|
key={`r-${i + 1}`}
|
|
45
45
|
>
|
|
46
46
|
<DetailsRender child={child} />
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { Avatar as CosmosAvatar, withConfiguration } from '@pega/cosmos-react-core';
|
|
5
|
+
import type { PConnFieldProps } from './PConnProps';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// interface for props
|
|
9
|
+
interface PegaDxilMyDetailsAvatarProps extends PConnFieldProps {
|
|
10
|
+
// If any, enter additional props that only exist on TextInput here
|
|
11
|
+
metaObj: any;
|
|
12
|
+
showStatus: boolean;
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function Avatar(props: PegaDxilMyDetailsAvatarProps) {
|
|
17
|
+
const { metaObj, showStatus = false } = props;
|
|
18
|
+
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
|
+
|
|
22
|
+
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
|
+
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
|
+
if (!metaObj) {
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
27
|
+
} else {
|
|
28
|
+
userName = metaObj.name;
|
|
29
|
+
userIdentifier = metaObj.ID;
|
|
30
|
+
}
|
|
31
|
+
if (!userName && userIdentifier) {
|
|
32
|
+
userName = userIdentifier;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const imageKey = !metaObj ? PCore.getEnvironmentInfo().getOperatorImageInsKey() : metaObj.image;
|
|
37
|
+
if (imageKey) {
|
|
38
|
+
PCore.getAssetLoader()
|
|
39
|
+
.getSvcImage(imageKey)
|
|
40
|
+
.then((blob) => window.URL.createObjectURL(blob))
|
|
41
|
+
.then((imagePath) => setImageBlobUrl(imagePath as React.SetStateAction<any>));
|
|
42
|
+
}
|
|
43
|
+
}, [metaObj]);
|
|
44
|
+
|
|
45
|
+
if (showStatus) {
|
|
46
|
+
const currentState = PCore.getMessagingServiceManager().getUserPresence().getUserState(userIdentifier);
|
|
47
|
+
const [userState, setUserState]: any = useState(currentState === 'online' ? 'active' : 'inactive');
|
|
48
|
+
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
const handleUserStateChange = ({ state }) => {
|
|
51
|
+
setUserState(state === 'online' ? 'active' : 'inactive');
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const subId = PCore.getMessagingServiceManager()
|
|
56
|
+
.getUserPresence()
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
.subscribe(userIdentifier, handleUserStateChange);
|
|
59
|
+
|
|
60
|
+
return function cleanup() {
|
|
61
|
+
PCore.getMessagingServiceManager().getUserPresence().unsubscribe(userIdentifier, subId);
|
|
62
|
+
};
|
|
63
|
+
}, [userIdentifier, handleUserStateChange]);
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
return <CosmosAvatar name={userName} imageSrc={imageBlobUrl as React.SetStateAction<any>} status={userState} />;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Do not render when userName does not exists
|
|
69
|
+
// TODO : In CNR case, pxRequestor is not available, please remove this condition once it populates
|
|
70
|
+
if (!userName) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return <CosmosAvatar name={userName} imageSrc={imageBlobUrl as React.SetStateAction<any>} />;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
export default withConfiguration(Avatar);
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { useState, useEffect, Fragment } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
Link,
|
|
5
|
+
Button,
|
|
6
|
+
Popover,
|
|
7
|
+
useOuterEvent,
|
|
8
|
+
useElement,
|
|
9
|
+
Progress,
|
|
10
|
+
FormField,
|
|
11
|
+
useTheme,
|
|
12
|
+
withConfiguration
|
|
13
|
+
} from '@pega/cosmos-react-core';
|
|
14
|
+
import { Glimpse } from '@pega/cosmos-react-work';
|
|
15
|
+
import { EmailDisplay } from '@pega/cosmos-react-core';
|
|
16
|
+
|
|
17
|
+
import type { PConnFieldProps } from './PConnProps';
|
|
18
|
+
|
|
19
|
+
import Avatar from './Avatar';
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
// interface for props
|
|
23
|
+
interface PegaDxilMyDetailsOperatorProps extends PConnFieldProps {
|
|
24
|
+
// If any, enter additional props that only exist on TextInput here
|
|
25
|
+
name: string;
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
metaObj: any;
|
|
29
|
+
externalUser: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let pTarget = null;
|
|
33
|
+
|
|
34
|
+
function Operator(props: PegaDxilMyDetailsOperatorProps) {
|
|
35
|
+
const { id, name, label, testId, helperText, externalUser, metaObj } = props;
|
|
36
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
37
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
38
|
+
const [popoverEl, setPopoverEl] = useElement(null);
|
|
39
|
+
const [popoverContent, setpopoverContent] = useState(null);
|
|
40
|
+
const theme: any = useTheme();
|
|
41
|
+
|
|
42
|
+
/* If the id has changed, we need to reset the popover */
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
pTarget = null;
|
|
45
|
+
}, [id]);
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
const OperatorPreview = () => {
|
|
50
|
+
const localizedVal = PCore.getLocaleUtils().getLocaleValue;
|
|
51
|
+
const localeCategory = 'Operator';
|
|
52
|
+
setpopoverContent(
|
|
53
|
+
<Progress variant='ring' message={localizedVal('Loading operator...', localeCategory)} placement='local' />
|
|
54
|
+
);
|
|
55
|
+
if (externalUser && externalUser.classID !== 'Data-Party-Operator') {
|
|
56
|
+
const fields = [
|
|
57
|
+
{
|
|
58
|
+
id: 'pyFirstName',
|
|
59
|
+
name: localizedVal('Name', localeCategory),
|
|
60
|
+
value: externalUser.name
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: 'pyEmail1',
|
|
64
|
+
name: localizedVal('Email', localeCategory),
|
|
65
|
+
value:
|
|
66
|
+
externalUser.email !== '' ? <Link href={`mailto:${externalUser.email}`}>{externalUser.email}</Link> : ''
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'pyPhoneNumber',
|
|
70
|
+
name: localizedVal('Phone', localeCategory),
|
|
71
|
+
value: externalUser.phone !== '' ? <Link href={`tel:${externalUser.phone}`}>{externalUser.phone}</Link> : ''
|
|
72
|
+
}
|
|
73
|
+
];
|
|
74
|
+
setIsLoading(false);
|
|
75
|
+
setpopoverContent(
|
|
76
|
+
<Glimpse
|
|
77
|
+
visual={
|
|
78
|
+
<Avatar
|
|
79
|
+
metaObj={{
|
|
80
|
+
name: externalUser.name
|
|
81
|
+
}}
|
|
82
|
+
/>
|
|
83
|
+
}
|
|
84
|
+
primary={externalUser.name}
|
|
85
|
+
secondary={[externalUser.position]}
|
|
86
|
+
fields={fields}
|
|
87
|
+
target={pTarget}
|
|
88
|
+
/>
|
|
89
|
+
);
|
|
90
|
+
} else {
|
|
91
|
+
return PCore.getUserApi()
|
|
92
|
+
.getOperatorDetails(id, true)
|
|
93
|
+
.then(res => {
|
|
94
|
+
if (res.data?.pyOperatorInfo) {
|
|
95
|
+
const fields = [];
|
|
96
|
+
const data = res.data;
|
|
97
|
+
if (data.pyOperatorInfo && data.pyOperatorInfo.pyUserName) {
|
|
98
|
+
fields.push({
|
|
99
|
+
id: 'Name',
|
|
100
|
+
name: localizedVal('Name', localeCategory),
|
|
101
|
+
value: data.pyOperatorInfo.pyUserName
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (data.pyOperatorInfo && data.pyOperatorInfo.pyEmailAddress) {
|
|
105
|
+
fields.push({
|
|
106
|
+
id: 'Email',
|
|
107
|
+
name: localizedVal('Email address', localeCategory),
|
|
108
|
+
value: <EmailDisplay value={data.pyOperatorInfo.pyEmailAddress} />
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
const opAvatar = (
|
|
112
|
+
<Avatar
|
|
113
|
+
metaObj={{
|
|
114
|
+
image: '',
|
|
115
|
+
name: data.pyOperatorInfo.pyUserName
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
setIsLoading(false);
|
|
121
|
+
setpopoverContent(
|
|
122
|
+
<Glimpse
|
|
123
|
+
heading={{
|
|
124
|
+
primary: data.pyOperatorInfo.pyUserName,
|
|
125
|
+
secondary: data.pyOperatorInfo.pyEmailAddress,
|
|
126
|
+
visual: opAvatar
|
|
127
|
+
}}
|
|
128
|
+
fields={fields}
|
|
129
|
+
target={pTarget}
|
|
130
|
+
onDismiss={() => {pTarget = null;}}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
const clickAction = (e: any) => {
|
|
140
|
+
|
|
141
|
+
setIsOpen(!isOpen);
|
|
142
|
+
if (pTarget === null) {
|
|
143
|
+
pTarget = e.currentTarget;
|
|
144
|
+
OperatorPreview();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const hidePopover = () => {
|
|
149
|
+
if (isOpen) {
|
|
150
|
+
setIsOpen(false);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
useOuterEvent('mousedown', [popoverEl], hidePopover); // Call the method on clicking outside these elements
|
|
155
|
+
|
|
156
|
+
const hideOnEscape = (e: any) => {
|
|
157
|
+
if (e.key === 'Escape') hidePopover(); // Call the method when Escape key is pressed
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const comp = (
|
|
161
|
+
<Fragment>
|
|
162
|
+
{metaObj ? (
|
|
163
|
+
<Button
|
|
164
|
+
variant='text'
|
|
165
|
+
aria-haspopup
|
|
166
|
+
aria-expanded={isOpen}
|
|
167
|
+
onClick={clickAction}
|
|
168
|
+
onKeyDown={hideOnEscape}
|
|
169
|
+
data-test-id={testId}
|
|
170
|
+
style={label !== null ? { width: 'max-content', height: theme.components.input.height } : undefined}
|
|
171
|
+
>
|
|
172
|
+
<Avatar {...props} />
|
|
173
|
+
</Button>
|
|
174
|
+
) : (
|
|
175
|
+
<Button
|
|
176
|
+
variant='link'
|
|
177
|
+
aria-haspopup
|
|
178
|
+
aria-expanded={isOpen}
|
|
179
|
+
onClick={clickAction}
|
|
180
|
+
onKeyDown={hideOnEscape}
|
|
181
|
+
data-test-id={testId}
|
|
182
|
+
style={label !== null ? { width: 'max-content', height: theme.components.input.height } : undefined}
|
|
183
|
+
>
|
|
184
|
+
{name}
|
|
185
|
+
</Button>
|
|
186
|
+
)}
|
|
187
|
+
|
|
188
|
+
{isOpen && (
|
|
189
|
+
<Popover
|
|
190
|
+
ref={setPopoverEl}
|
|
191
|
+
groupId='operator'
|
|
192
|
+
target={pTarget}
|
|
193
|
+
placement='bottom-start'
|
|
194
|
+
style={isLoading ? { position: 'relative', width: '10rem', minHeight: '4rem' } : undefined}
|
|
195
|
+
strategy='fixed'
|
|
196
|
+
>
|
|
197
|
+
{popoverContent}
|
|
198
|
+
</Popover>
|
|
199
|
+
)}
|
|
200
|
+
</Fragment>
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
if (label !== null) {
|
|
204
|
+
return (
|
|
205
|
+
<FormField label={label} info={helperText}>
|
|
206
|
+
{comp}
|
|
207
|
+
</FormField>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return comp;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
export default withConfiguration(Operator);
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
5
|
import { Text, FieldValueList, Button, DateTimeDisplay, useTheme } from '@pega/cosmos-react-core';
|
|
6
6
|
import PegaDxilMyDetails from './index';
|
|
7
|
-
import { pyReviewRaw, pyReviewResolved, regionChildrenResolved } from './mock';
|
|
7
|
+
import { pyReviewRaw, pyReviewResolved, regionChildrenResolved, operatorDetails, configProps } from './mock';
|
|
8
8
|
import StatusWorkRenderer from './StatusWork';
|
|
9
|
-
|
|
9
|
+
import Operator from './Operator';
|
|
10
10
|
|
|
11
11
|
const meta: Meta<typeof PegaDxilMyDetails> = {
|
|
12
12
|
title: 'PegaDxilMyDetails',
|
|
@@ -20,6 +20,28 @@ const meta: Meta<typeof PegaDxilMyDetails> = {
|
|
|
20
20
|
export default meta;
|
|
21
21
|
type Story = StoryObj<typeof PegaDxilMyDetails>;
|
|
22
22
|
|
|
23
|
+
if (!window.PCore) {
|
|
24
|
+
window.PCore = {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
window.PCore.getLocaleUtils = () => {
|
|
28
|
+
return {
|
|
29
|
+
getLocaleValue: value => {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
window.PCore.getUserApi = () => {
|
|
36
|
+
return {
|
|
37
|
+
getOperatorDetails: () => {
|
|
38
|
+
return new Promise(resolve => {
|
|
39
|
+
resolve(operatorDetails);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
23
45
|
const Region = props => {
|
|
24
46
|
return <></>;
|
|
25
47
|
};
|
|
@@ -60,19 +82,30 @@ const renderField = resolvedProps => {
|
|
|
60
82
|
|
|
61
83
|
if (displayAsStatus === true) val = <StatusWorkRenderer value={value} key={key} />;
|
|
62
84
|
|
|
85
|
+
const [_label] =
|
|
86
|
+
label === 'Create operator'
|
|
87
|
+
? [configProps.createLabel, configProps.createOperator, configProps.createDateTime]
|
|
88
|
+
: label === 'Update operator'
|
|
89
|
+
? [configProps.updateLabel, configProps.updateOperator, configProps.updateDateTime]
|
|
90
|
+
: [configProps.resolveLabel, configProps.resolveOperator, configProps.resolveDateTime];
|
|
91
|
+
|
|
63
92
|
if (label === 'Create Operator')
|
|
64
93
|
val = (
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
|
|
94
|
+
<Operator
|
|
95
|
+
label={configProps.hideLabel ? '' : _label}
|
|
96
|
+
name={configProps.createOperator.userName}
|
|
97
|
+
id={configProps.createOperator.userId}
|
|
98
|
+
value={undefined}
|
|
99
|
+
validatemessage=''
|
|
100
|
+
hideLabel={false}
|
|
101
|
+
readOnly={false}
|
|
102
|
+
required={false}
|
|
103
|
+
disabled={false}
|
|
104
|
+
externalUser={undefined}
|
|
105
|
+
metaObj={undefined}
|
|
106
|
+
testId=''
|
|
107
|
+
helperText=''
|
|
108
|
+
/>
|
|
76
109
|
);
|
|
77
110
|
|
|
78
111
|
if (variant === 'inline') {
|
|
@@ -41,7 +41,7 @@ function PegaDxilMyDetails(props: PegaDxilMyDetailsProps) {
|
|
|
41
41
|
const numRegions = getAllFields(getPConnect)?.length;
|
|
42
42
|
const gridRepeat = "repeat(".concat(numRegions).concat(", 1fr)");
|
|
43
43
|
|
|
44
|
-
const gridContainer: GridContainerProps = { colGap:
|
|
44
|
+
const gridContainer: GridContainerProps = { colGap: 6 };
|
|
45
45
|
gridContainer.cols = gridRepeat;
|
|
46
46
|
gridContainer.alignItems = 'start';
|
|
47
47
|
|
|
@@ -82,7 +82,7 @@ function PegaDxilMyDetails(props: PegaDxilMyDetailsProps) {
|
|
|
82
82
|
|
|
83
83
|
<Flex
|
|
84
84
|
// @ts-ignore
|
|
85
|
-
container={{ direction: 'column', alignItems: 'normal', colGap:
|
|
85
|
+
container={{ direction: 'column', alignItems: 'normal', colGap: 1, rowGap: 1.5 }}
|
|
86
86
|
key={`r-${i + 1}`}
|
|
87
87
|
>
|
|
88
88
|
<DetailsRender child={child} />
|
|
@@ -193,3 +193,58 @@ export const regionChildrenResolved = [
|
|
|
193
193
|
key: 'SLA Start Time'
|
|
194
194
|
}
|
|
195
195
|
];
|
|
196
|
+
|
|
197
|
+
export const operatorDetails = {
|
|
198
|
+
data: {
|
|
199
|
+
pzLoadTime: 'January 18, 2023 10:33:19 AM EST',
|
|
200
|
+
pzPageNameHash: '_pa1519192551088960pz',
|
|
201
|
+
pyOperatorInfo: {
|
|
202
|
+
pyUserName: 'french DigV2',
|
|
203
|
+
pyPosition: '',
|
|
204
|
+
pyImageInsKey: '',
|
|
205
|
+
pySkills: [
|
|
206
|
+
{
|
|
207
|
+
pySkillName: '',
|
|
208
|
+
pzIndexOwnerKey: 'DATA-ADMIN-OPERATOR-ID FRENCHTEST.DIGV2',
|
|
209
|
+
pySkillRating: 0
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
pyReportToUserName: '',
|
|
213
|
+
pyReportTo: '',
|
|
214
|
+
pyOrganization: 'DXIL',
|
|
215
|
+
pyTitle: '',
|
|
216
|
+
pyLabel: 'frenchTest.DigV2',
|
|
217
|
+
pyEmailAddress: 'User@DigV2',
|
|
218
|
+
pyTelephone: ''
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
status: 200,
|
|
222
|
+
statusText: '',
|
|
223
|
+
headers: {
|
|
224
|
+
'content-length': '435',
|
|
225
|
+
'content-type': 'application/json;charset=UTF-8'
|
|
226
|
+
},
|
|
227
|
+
request: {}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export const configProps = {
|
|
231
|
+
label: 'Create operator',
|
|
232
|
+
createLabel: 'Created',
|
|
233
|
+
updateLabel: 'Updated',
|
|
234
|
+
updateDateTime: '2023-01-16T14:53:33.280Z',
|
|
235
|
+
createDateTime: '2023-01-16T14:53:33.198Z',
|
|
236
|
+
updateOperator: {
|
|
237
|
+
userId: 'admin@mediaco',
|
|
238
|
+
userName: 'admin'
|
|
239
|
+
},
|
|
240
|
+
createOperator: {
|
|
241
|
+
userId: 'admin@mediaco',
|
|
242
|
+
userName: 'admin'
|
|
243
|
+
},
|
|
244
|
+
resolveLabel: '',
|
|
245
|
+
resolveOperator: '',
|
|
246
|
+
resolveDateTime: '',
|
|
247
|
+
hideLabel: true,
|
|
248
|
+
key: '_532zx1dah',
|
|
249
|
+
displayMode: 'LABELS_LEFT'
|
|
250
|
+
};
|
|
@@ -38,7 +38,7 @@ function PegaDxilMyForm(props: PegaDxilMyFormProps) {
|
|
|
38
38
|
{children.map((child: any, i: number) => (
|
|
39
39
|
<Flex
|
|
40
40
|
// @ts-ignore
|
|
41
|
-
container={{ direction: 'column', alignItems: 'normal', colGap:
|
|
41
|
+
container={{ direction: 'column', alignItems: 'normal', colGap: 1, rowGap: 1.5 }}
|
|
42
42
|
key={`r-${i + 1}`}
|
|
43
43
|
>
|
|
44
44
|
<DetailsRender child={child} />
|