@pega/custom-dx-components 0.242.48 → 0.242.49
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/constants.js +3 -1
- package/src/tasks/create/templates/Constellation/Template/DETAILS/Avatar.tsx.mustache +4 -4
- package/src/tasks/create/templates/Constellation/Template/DETAILS-region/Avatar.tsx.mustache +4 -4
- package/src/tasks/create/templates/Constellation/Widget/PAGE-CASE/Avatar.tsx.mustache +4 -4
- package/src/tasks/create/templates/Launchpad/Widget/PAGE-CASE/Avatar.tsx.mustache +4 -4
- package/src/tasks/export-archive/helper.js +21 -4
- package/src/tasks/import-archive/helper.js +25 -16
- package/src/tasks/init/template/package.json.mustache +2 -2
- package/tests/assets/library/components/{createAll/Constellation/Pega_DXIL_MyDetails → create/shared}/Avatar.tsx +5 -5
- package/tests/assets/library/components/{createAll/Constellation/Pega_DXIL_MyDetails → create/shared}/Operator.tsx +1 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDetails/demo.stories.tsx +1 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/index.tsx +1 -1
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/demo.stories.tsx +1 -1
- package/tests/assets/library/components/createAll/Constellation/{Pega_DXIL_MyPageCaseWidget → shared}/Avatar.tsx +8 -7
- package/tests/assets/library/components/createAll/Constellation/{Pega_DXIL_MyPageCaseWidget → shared}/Operator.tsx +3 -3
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDetails/Avatar.tsx +4 -4
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/Avatar.tsx +4 -4
- package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/Avatar.tsx +4 -4
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyDetails/Avatar.tsx +4 -4
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/Avatar.tsx +4 -4
- package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/Avatar.tsx +4 -4
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/Avatar.tsx +0 -76
- package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyTwoColumnDetails/Operator.tsx +0 -215
package/package.json
CHANGED
package/src/constants.js
CHANGED
|
@@ -16,14 +16,14 @@ interface {{COMPONENT_CLASS_NAME}}AvatarProps extends PConnFieldProps {
|
|
|
16
16
|
function Avatar(props: {{COMPONENT_CLASS_NAME}}AvatarProps) {
|
|
17
17
|
const { metaObj, showStatus = false } = props;
|
|
18
18
|
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
-
let userName:
|
|
20
|
-
let userIdentifier:
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
21
|
|
|
22
22
|
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
23
|
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
24
|
if (!metaObj) {
|
|
25
|
-
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
-
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName() ?? "";
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier() ?? "";
|
|
27
27
|
} else {
|
|
28
28
|
userName = metaObj.name;
|
|
29
29
|
userIdentifier = metaObj.ID;
|
package/src/tasks/create/templates/Constellation/Template/DETAILS-region/Avatar.tsx.mustache
CHANGED
|
@@ -16,14 +16,14 @@ interface {{COMPONENT_CLASS_NAME}}AvatarProps extends PConnFieldProps {
|
|
|
16
16
|
function Avatar(props: {{COMPONENT_CLASS_NAME}}AvatarProps) {
|
|
17
17
|
const { metaObj, showStatus = false } = props;
|
|
18
18
|
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
-
let userName:
|
|
20
|
-
let userIdentifier:
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
21
|
|
|
22
22
|
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
23
|
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
24
|
if (!metaObj) {
|
|
25
|
-
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
-
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName() ?? "";
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier() ?? "";
|
|
27
27
|
} else {
|
|
28
28
|
userName = metaObj.name;
|
|
29
29
|
userIdentifier = metaObj.ID;
|
|
@@ -16,14 +16,14 @@ interface {{COMPONENT_CLASS_NAME}}AvatarProps extends PConnFieldProps {
|
|
|
16
16
|
function Avatar(props: {{COMPONENT_CLASS_NAME}}AvatarProps) {
|
|
17
17
|
const { metaObj, showStatus = false } = props;
|
|
18
18
|
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
-
let userName:
|
|
20
|
-
let userIdentifier:
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
21
|
|
|
22
22
|
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
23
|
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
24
|
if (!metaObj) {
|
|
25
|
-
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
-
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName() ?? "";
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier() ?? "";
|
|
27
27
|
} else {
|
|
28
28
|
userName = metaObj.name;
|
|
29
29
|
userIdentifier = metaObj.ID;
|
|
@@ -16,14 +16,14 @@ interface {{COMPONENT_CLASS_NAME}}AvatarProps extends PConnFieldProps {
|
|
|
16
16
|
function Avatar(props: {{COMPONENT_CLASS_NAME}}AvatarProps) {
|
|
17
17
|
const { metaObj, showStatus = false } = props;
|
|
18
18
|
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
-
let userName:
|
|
20
|
-
let userIdentifier:
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
21
|
|
|
22
22
|
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
23
|
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
24
|
if (!metaObj) {
|
|
25
|
-
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
-
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName() ?? "";
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier() ?? "";
|
|
27
27
|
} else {
|
|
28
28
|
userName = metaObj.name;
|
|
29
29
|
userIdentifier = metaObj.ID;
|
|
@@ -93,15 +93,32 @@ export const updateSavedExportFilePath = async(filePath) => {
|
|
|
93
93
|
|
|
94
94
|
let defaultPath = join(path.sep, arPathParts[0], arPathParts[1], arPathParts[2]);
|
|
95
95
|
|
|
96
|
-
if (
|
|
97
|
-
//
|
|
98
|
-
|
|
96
|
+
if (path.sep != "/") {
|
|
97
|
+
// windows
|
|
98
|
+
if (defaultPath.indexOf(path.sep) === 0) {
|
|
99
|
+
// if start with \\, then remove
|
|
100
|
+
defaultPath = defaultPath.substring(1);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (filePath.indexOf(defaultPath) === 0) {
|
|
104
|
+
// same starting path, so we can save the relative
|
|
105
|
+
const relativePath = filePath.replace(defaultPath.concat(path.sep), "");
|
|
99
106
|
|
|
100
|
-
if (relativePath != configDef.importRelativePath) {
|
|
101
107
|
await setConfigExportRelativePath(relativePath);
|
|
102
108
|
await forceDefaultsUpdate();
|
|
109
|
+
|
|
103
110
|
}
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// mac
|
|
114
|
+
if (filePath.indexOf(defaultPath) === 0) {
|
|
115
|
+
// same starting path, so we can save the relative
|
|
116
|
+
const relativePath = filePath.replace(defaultPath.concat("/"), "");
|
|
104
117
|
|
|
118
|
+
await setConfigExportRelativePath(relativePath);
|
|
119
|
+
await forceDefaultsUpdate();
|
|
105
120
|
|
|
121
|
+
}
|
|
106
122
|
}
|
|
123
|
+
|
|
107
124
|
}
|
|
@@ -190,17 +190,6 @@ export const updateTempArchive = async(libraryName, version, devBuild) => {
|
|
|
190
190
|
// remove -dev if exists
|
|
191
191
|
const justVersion = version.replace("-dev", "");
|
|
192
192
|
|
|
193
|
-
// open tasks.config and update it
|
|
194
|
-
// await setTasksConfig(libraryName, justVersion, devBuild, tempStoreDirectory);
|
|
195
|
-
|
|
196
|
-
// open package.json, update org
|
|
197
|
-
// await setPackageOrg(configDef.organization, tempStoreDirectory);
|
|
198
|
-
|
|
199
|
-
// update all the components
|
|
200
|
-
// const compDir = join(tempStoreDirectory, "src", "components");
|
|
201
|
-
// const compList = await getComponents(compDir);
|
|
202
|
-
|
|
203
|
-
// await renameComponents(compList, libraryName, version, compDir);
|
|
204
193
|
|
|
205
194
|
const tasks = new Listr(
|
|
206
195
|
[
|
|
@@ -290,12 +279,32 @@ export const updateSavedFilePath = async(filePath) => {
|
|
|
290
279
|
|
|
291
280
|
let defaultPath = join(path.sep, arPathParts[0], arPathParts[1], arPathParts[2]);
|
|
292
281
|
|
|
293
|
-
if (
|
|
294
|
-
//
|
|
295
|
-
|
|
282
|
+
if (path.sep != "/") {
|
|
283
|
+
// windows
|
|
284
|
+
if (defaultPath.indexOf(path.sep) === 0) {
|
|
285
|
+
// if start with \\, then remove
|
|
286
|
+
defaultPath = defaultPath.substring(1);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (filePath.indexOf(defaultPath) === 0) {
|
|
290
|
+
// same starting path, so we can save the relative
|
|
291
|
+
const relativePath = filePath.replace(defaultPath.concat(path.sep), "");
|
|
292
|
+
|
|
293
|
+
await setConfigImportRelativePath(relativePath);
|
|
294
|
+
await forceDefaultsUpdate();
|
|
296
295
|
|
|
297
|
-
|
|
298
|
-
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
// mac
|
|
300
|
+
if (filePath.indexOf(defaultPath) === 0) {
|
|
301
|
+
// same starting path, so we can save the relative
|
|
302
|
+
const relativePath = filePath.replace(defaultPath.concat("/"), "");
|
|
299
303
|
|
|
304
|
+
await setConfigImportRelativePath(relativePath);
|
|
305
|
+
await forceDefaultsUpdate();
|
|
306
|
+
|
|
307
|
+
}
|
|
300
308
|
}
|
|
309
|
+
|
|
301
310
|
}
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"_internal-test-coverage": "node --input-type=module --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand node_modules/@pega/custom-dx-component --ci --testResultsProcessor='jest-junit' --coverage",
|
|
49
49
|
"_internal-test": "echo 'Running functional and unit tests will DELETE existing local components, proceed (y/n)?' && read proceed && if test \"$proceed\" = \"y\"; then npm run _internal-test-full; fi ",
|
|
50
50
|
"_internal-test-full": "npm run _internal-test-functional && npm run _internal-test-unit",
|
|
51
|
-
"_internal-test-functional": "echo '
|
|
51
|
+
"_internal-test-functional": "echo 'Make sure you authenticate!!' && npm run test:functional:local --prefix node_modules/@pega/custom-dx-components",
|
|
52
52
|
"_internal-test-unit": "npm run test:unit:local --prefix node_modules/@pega/custom-dx-components",
|
|
53
53
|
"_internal-build-jest-assets": "custom-dx-components buildJestAssets",
|
|
54
54
|
"_internal-buildLibrary": "custom-dx-components buildLibrary",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@pega/configs": "^0.15.1",
|
|
103
|
-
"@pega/custom-dx-components": "~0.242.
|
|
103
|
+
"@pega/custom-dx-components": "~0.242.49",
|
|
104
104
|
"@pega/pcore-pconnect-typedefs": "~3.2.0-alpha.1",
|
|
105
105
|
"@storybook/addon-actions": "^7.6.19",
|
|
106
106
|
"@storybook/addon-essentials": "^7.6.19",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
4
|
import { Avatar as CosmosAvatar, withConfiguration } from '@pega/cosmos-react-core';
|
|
5
|
-
import type { PConnFieldProps } from '
|
|
5
|
+
import type { PConnFieldProps } from './PConnProps';
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
// interface for props
|
|
@@ -16,14 +16,14 @@ interface PegaDxilMyDetailsAvatarProps extends PConnFieldProps {
|
|
|
16
16
|
function Avatar(props: PegaDxilMyDetailsAvatarProps) {
|
|
17
17
|
const { metaObj, showStatus = false } = props;
|
|
18
18
|
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
-
let userName:
|
|
20
|
-
let userIdentifier:
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
21
|
|
|
22
22
|
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
23
|
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
24
|
if (!metaObj) {
|
|
25
|
-
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
-
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName() ?? "";
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier() ?? "";
|
|
27
27
|
} else {
|
|
28
28
|
userName = metaObj.name;
|
|
29
29
|
userIdentifier = metaObj.ID;
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import { Glimpse } from '@pega/cosmos-react-work';
|
|
15
15
|
import { EmailDisplay } from '@pega/cosmos-react-core';
|
|
16
16
|
|
|
17
|
-
import type { PConnFieldProps } from '
|
|
17
|
+
import type { PConnFieldProps } from './PConnProps';
|
|
18
18
|
|
|
19
19
|
import Avatar from './Avatar';
|
|
20
20
|
|
package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyDetails/demo.stories.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { Text, FieldValueList, Button, DateTimeDisplay, useTheme } from '@pega/c
|
|
|
5
5
|
import PegaDxilMyDetails from './index';
|
|
6
6
|
import { pyReviewRaw, pyReviewResolved, regionChildrenResolved, operatorDetails, configProps } from './mock';
|
|
7
7
|
import StatusWorkRenderer from './StatusWork';
|
|
8
|
-
import Operator from '
|
|
8
|
+
import Operator from '../shared/Operator';
|
|
9
9
|
import type C11nEnv from '@pega/pcore-pconnect-typedefs/interpreter/c11n-env';
|
|
10
10
|
|
|
11
11
|
const meta: Meta<typeof PegaDxilMyDetails> = {
|
package/tests/assets/library/components/createAll/Constellation/Pega_DXIL_MyPageCaseWidget/index.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import { DateTimeDisplay, Card, CardHeader, CardContent, Flex, withConfiguration
|
|
|
6
6
|
import type { PConnFieldProps } from '../shared/PConnProps';
|
|
7
7
|
|
|
8
8
|
// includes in bundle
|
|
9
|
-
import Operator from '
|
|
9
|
+
import Operator from '../shared/Operator';
|
|
10
10
|
|
|
11
11
|
import StyledPegaDxilMyPageCaseWidgetWrapper from './styles';
|
|
12
12
|
|
|
@@ -4,7 +4,7 @@ import { Text, FieldValueList, Button, DateTimeDisplay, useTheme } from '@pega/c
|
|
|
4
4
|
import PegaDxilMyTwoColumnDetails from './index';
|
|
5
5
|
import { pyReviewRaw, pyReviewResolved, regionChildrenResolved, operatorDetails, configProps } from './mock';
|
|
6
6
|
import StatusWorkRenderer from './StatusWork';
|
|
7
|
-
import Operator from '
|
|
7
|
+
import Operator from '../shared/Operator';
|
|
8
8
|
import type C11nEnv from '@pega/pcore-pconnect-typedefs/interpreter/c11n-env';
|
|
9
9
|
|
|
10
10
|
const meta: Meta<typeof PegaDxilMyTwoColumnDetails> = {
|
|
@@ -2,28 +2,28 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
4
|
import { Avatar as CosmosAvatar, withConfiguration } from '@pega/cosmos-react-core';
|
|
5
|
-
import type { PConnFieldProps } from '
|
|
5
|
+
import type { PConnFieldProps } from './PConnProps';
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
// interface for props
|
|
9
|
-
interface
|
|
9
|
+
interface PegaDxilMyDetailsAvatarProps extends PConnFieldProps {
|
|
10
10
|
// If any, enter additional props that only exist on TextInput here
|
|
11
11
|
metaObj: any;
|
|
12
12
|
showStatus: boolean;
|
|
13
13
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function Avatar(props:
|
|
16
|
+
function Avatar(props: PegaDxilMyDetailsAvatarProps) {
|
|
17
17
|
const { metaObj, showStatus = false } = props;
|
|
18
18
|
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
-
let userName:
|
|
20
|
-
let userIdentifier:
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
21
|
|
|
22
22
|
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
23
|
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
24
|
if (!metaObj) {
|
|
25
|
-
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
-
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName() ?? "";
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier() ?? "";
|
|
27
27
|
} else {
|
|
28
28
|
userName = metaObj.name;
|
|
29
29
|
userIdentifier = metaObj.ID;
|
|
@@ -59,6 +59,7 @@ function Avatar(props: PegaDxilMyPageCaseWidgetAvatarProps) {
|
|
|
59
59
|
PCore.getMessagingServiceManager().getUserPresence().unsubscribe(userIdentifier, subId);
|
|
60
60
|
};
|
|
61
61
|
}, [userIdentifier, handleUserStateChange]);
|
|
62
|
+
|
|
62
63
|
return <CosmosAvatar name={userName} imageSrc={imageBlobUrl as React.SetStateAction<any>} status={userState} />;
|
|
63
64
|
}
|
|
64
65
|
|
|
@@ -14,13 +14,13 @@ import {
|
|
|
14
14
|
import { Glimpse } from '@pega/cosmos-react-work';
|
|
15
15
|
import { EmailDisplay } from '@pega/cosmos-react-core';
|
|
16
16
|
|
|
17
|
-
import type { PConnFieldProps } from '
|
|
17
|
+
import type { PConnFieldProps } from './PConnProps';
|
|
18
18
|
|
|
19
19
|
import Avatar from './Avatar';
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
// interface for props
|
|
23
|
-
interface
|
|
23
|
+
interface PegaDxilMyDetailsOperatorProps extends PConnFieldProps {
|
|
24
24
|
// If any, enter additional props that only exist on TextInput here
|
|
25
25
|
name: string;
|
|
26
26
|
id: string;
|
|
@@ -31,7 +31,7 @@ interface PegaDxilMyPageCaseWidgetOperatorProps extends PConnFieldProps {
|
|
|
31
31
|
|
|
32
32
|
let pTarget = null;
|
|
33
33
|
|
|
34
|
-
function Operator(props:
|
|
34
|
+
function Operator(props: PegaDxilMyDetailsOperatorProps) {
|
|
35
35
|
const { id, name, label, testId, helperText, externalUser, metaObj } = props;
|
|
36
36
|
const [isOpen, setIsOpen] = useState(false);
|
|
37
37
|
const [isLoading, setIsLoading] = useState(true);
|
package/tests/assets/original/components/createAll/Constellation/Pega_DXIL_MyDetails/Avatar.tsx
CHANGED
|
@@ -16,14 +16,14 @@ interface PegaDxilMyDetailsAvatarProps extends PConnFieldProps {
|
|
|
16
16
|
function Avatar(props: PegaDxilMyDetailsAvatarProps) {
|
|
17
17
|
const { metaObj, showStatus = false } = props;
|
|
18
18
|
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
-
let userName:
|
|
20
|
-
let userIdentifier:
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
21
|
|
|
22
22
|
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
23
|
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
24
|
if (!metaObj) {
|
|
25
|
-
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
-
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName() ?? "";
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier() ?? "";
|
|
27
27
|
} else {
|
|
28
28
|
userName = metaObj.name;
|
|
29
29
|
userIdentifier = metaObj.ID;
|
|
@@ -16,14 +16,14 @@ interface PegaDxilMyPageCaseWidgetAvatarProps extends PConnFieldProps {
|
|
|
16
16
|
function Avatar(props: PegaDxilMyPageCaseWidgetAvatarProps) {
|
|
17
17
|
const { metaObj, showStatus = false } = props;
|
|
18
18
|
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
-
let userName:
|
|
20
|
-
let userIdentifier:
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
21
|
|
|
22
22
|
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
23
|
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
24
|
if (!metaObj) {
|
|
25
|
-
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
-
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName() ?? "";
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier() ?? "";
|
|
27
27
|
} else {
|
|
28
28
|
userName = metaObj.name;
|
|
29
29
|
userIdentifier = metaObj.ID;
|
|
@@ -16,14 +16,14 @@ interface PegaDxilMyTwoColumnDetailsAvatarProps extends PConnFieldProps {
|
|
|
16
16
|
function Avatar(props: PegaDxilMyTwoColumnDetailsAvatarProps) {
|
|
17
17
|
const { metaObj, showStatus = false } = props;
|
|
18
18
|
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
-
let userName:
|
|
20
|
-
let userIdentifier:
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
21
|
|
|
22
22
|
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
23
|
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
24
|
if (!metaObj) {
|
|
25
|
-
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
-
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName() ?? "";
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier() ?? "";
|
|
27
27
|
} else {
|
|
28
28
|
userName = metaObj.name;
|
|
29
29
|
userIdentifier = metaObj.ID;
|
|
@@ -16,14 +16,14 @@ interface PegaDxilMyDetailsAvatarProps extends PConnFieldProps {
|
|
|
16
16
|
function Avatar(props: PegaDxilMyDetailsAvatarProps) {
|
|
17
17
|
const { metaObj, showStatus = false } = props;
|
|
18
18
|
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
-
let userName:
|
|
20
|
-
let userIdentifier:
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
21
|
|
|
22
22
|
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
23
|
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
24
|
if (!metaObj) {
|
|
25
|
-
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
-
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName() ?? "";
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier() ?? "";
|
|
27
27
|
} else {
|
|
28
28
|
userName = metaObj.name;
|
|
29
29
|
userIdentifier = metaObj.ID;
|
package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyPageCaseWidget/Avatar.tsx
CHANGED
|
@@ -16,14 +16,14 @@ interface PegaDxilMyPageCaseWidgetAvatarProps extends PConnFieldProps {
|
|
|
16
16
|
function Avatar(props: PegaDxilMyPageCaseWidgetAvatarProps) {
|
|
17
17
|
const { metaObj, showStatus = false } = props;
|
|
18
18
|
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
-
let userName:
|
|
20
|
-
let userIdentifier:
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
21
|
|
|
22
22
|
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
23
|
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
24
|
if (!metaObj) {
|
|
25
|
-
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
-
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName() ?? "";
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier() ?? "";
|
|
27
27
|
} else {
|
|
28
28
|
userName = metaObj.name;
|
|
29
29
|
userIdentifier = metaObj.ID;
|
package/tests/assets/original/components/createAll/Launchpad/Pega_DXIL_MyTwoColumnDetails/Avatar.tsx
CHANGED
|
@@ -16,14 +16,14 @@ interface PegaDxilMyTwoColumnDetailsAvatarProps extends PConnFieldProps {
|
|
|
16
16
|
function Avatar(props: PegaDxilMyTwoColumnDetailsAvatarProps) {
|
|
17
17
|
const { metaObj, showStatus = false } = props;
|
|
18
18
|
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
-
let userName:
|
|
20
|
-
let userIdentifier:
|
|
19
|
+
let userName: string;
|
|
20
|
+
let userIdentifier: string;
|
|
21
21
|
|
|
22
22
|
// TODO Below if conditions can be removed once we have apis to get worklist/mywork info
|
|
23
23
|
// This is non CaseView case (Dashboard, MyWork etc)
|
|
24
24
|
if (!metaObj) {
|
|
25
|
-
userName = PCore.getEnvironmentInfo().getOperatorName();
|
|
26
|
-
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier();
|
|
25
|
+
userName = PCore.getEnvironmentInfo().getOperatorName() ?? "";
|
|
26
|
+
userIdentifier = PCore.getEnvironmentInfo().getOperatorIdentifier() ?? "";
|
|
27
27
|
} else {
|
|
28
28
|
userName = metaObj.name;
|
|
29
29
|
userIdentifier = metaObj.ID;
|
|
@@ -1,76 +0,0 @@
|
|
|
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 '../shared/PConnProps';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// interface for props
|
|
9
|
-
interface PegaDxilMyTwoColumnDetailsAvatarProps 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: PegaDxilMyTwoColumnDetailsAvatarProps) {
|
|
17
|
-
const { metaObj, showStatus = false } = props;
|
|
18
|
-
const [imageBlobUrl, setImageBlobUrl] = useState(null);
|
|
19
|
-
let userName: any;
|
|
20
|
-
let userIdentifier: any;
|
|
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
|
-
const handleUserStateChange = ({ state } : any) => {
|
|
50
|
-
setUserState(state === 'online' ? 'active' : 'inactive');
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
const subId = PCore.getMessagingServiceManager()
|
|
55
|
-
.getUserPresence()
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
.subscribe(userIdentifier, handleUserStateChange);
|
|
58
|
-
|
|
59
|
-
return function cleanup() {
|
|
60
|
-
PCore.getMessagingServiceManager().getUserPresence().unsubscribe(userIdentifier, subId);
|
|
61
|
-
};
|
|
62
|
-
}, [userIdentifier, handleUserStateChange]);
|
|
63
|
-
return <CosmosAvatar name={userName} imageSrc={imageBlobUrl as React.SetStateAction<any>} status={userState} />;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Do not render when userName does not exists
|
|
67
|
-
// TODO : In CNR case, pxRequestor is not available, please remove this condition once it populates
|
|
68
|
-
if (!userName) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return <CosmosAvatar name={userName} imageSrc={imageBlobUrl as React.SetStateAction<any>} />;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
export default withConfiguration(Avatar);
|
|
@@ -1,215 +0,0 @@
|
|
|
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 '../shared/PConnProps';
|
|
18
|
-
|
|
19
|
-
import Avatar from './Avatar';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// interface for props
|
|
23
|
-
interface PegaDxilMyTwoColumnDetailsOperatorProps 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: PegaDxilMyTwoColumnDetailsOperatorProps) {
|
|
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);
|