@pega/custom-dx-components 0.242.47 → 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 +21 -15
- package/src/tasks/import-archive/index.js +56 -7
- package/src/tasks/init/template/package.json.mustache +2 -2
- package/src/tasks/show-status/index.js +1 -1
- package/src/tasks/switch-lib/index.js +0 -18
- package/src/util.js +10 -9
- 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,15 +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), "");
|
|
296
292
|
|
|
297
|
-
if (relativePath != configDef.importRelativePath) {
|
|
298
293
|
await setConfigImportRelativePath(relativePath);
|
|
299
294
|
await forceDefaultsUpdate();
|
|
295
|
+
|
|
300
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("/"), "");
|
|
301
303
|
|
|
304
|
+
await setConfigImportRelativePath(relativePath);
|
|
305
|
+
await forceDefaultsUpdate();
|
|
302
306
|
|
|
307
|
+
}
|
|
303
308
|
}
|
|
309
|
+
|
|
304
310
|
}
|
|
@@ -5,6 +5,7 @@ import { join } from 'path';
|
|
|
5
5
|
import inquirer from 'inquirer';
|
|
6
6
|
import ncp from 'ncp';
|
|
7
7
|
import chalk from 'chalk';
|
|
8
|
+
import { Listr } from 'listr2';
|
|
8
9
|
|
|
9
10
|
import {
|
|
10
11
|
sanitize,
|
|
@@ -19,10 +20,14 @@ import {
|
|
|
19
20
|
zipVersionAndArchive,
|
|
20
21
|
getLibraryArchiveDirectories,
|
|
21
22
|
hasLibraryAndVersion,
|
|
22
|
-
cleanUpTemp
|
|
23
|
+
cleanUpTemp,
|
|
24
|
+
hasArchives,
|
|
25
|
+
restoreFromArchive,
|
|
26
|
+
forceDefaultsUpdate
|
|
23
27
|
} from '../../util.js';
|
|
24
28
|
import { TASKS_CONFIG_JSON_FILENAME, ARCHIVES_PATH, TEMP_PATH } from '../../constants.js';
|
|
25
29
|
import { getFilePathQuestions, getFileNameQuestions, updateTempArchive, updateSavedFilePath } from './helper.js';
|
|
30
|
+
import { showCurrentStatus } from '../show-status/index.js';
|
|
26
31
|
|
|
27
32
|
export const DXCB_CONFIG_INTERNAL_JSON_FILENAME = 'src/dxcb.config.json';
|
|
28
33
|
const currentDirectory = process.cwd();
|
|
@@ -214,7 +219,7 @@ export const moveComp = async(componentKey, orgLibName, version, copyShared, opt
|
|
|
214
219
|
fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 2 });
|
|
215
220
|
}
|
|
216
221
|
|
|
217
|
-
export const importArch = async(filePath, fileName) => {
|
|
222
|
+
export const importArch = async(filePath, fileName, hadArchive) => {
|
|
218
223
|
addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
219
224
|
|
|
220
225
|
const currentDirectory = process.cwd();
|
|
@@ -326,8 +331,44 @@ addDebugLog("importArch", `filePath: ${filePath}, fileName: ${fileName}`, "");
|
|
|
326
331
|
// delete temp directory
|
|
327
332
|
fs.rmSync(tempDirectory, { recursive: true, force: true, maxRetries: 2 });
|
|
328
333
|
|
|
329
|
-
|
|
330
|
-
|
|
334
|
+
|
|
335
|
+
if (hadArchive) {
|
|
336
|
+
console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
|
|
337
|
+
console.log(`You can switch to ${chalk.green(`${orgLibName}/${version}`)} via npm run switchLib.\n`);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
const switchToFileName = `${orgLibName}_${version}.zip`;
|
|
341
|
+
|
|
342
|
+
const tasks = new Listr(
|
|
343
|
+
[
|
|
344
|
+
{
|
|
345
|
+
title: `Restoring ${orgLibName}/${version}`,
|
|
346
|
+
task: async () => {
|
|
347
|
+
await restoreFromArchive(switchToFileName, orgLibName, version);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
],
|
|
351
|
+
{ concurrent: false, exitOnError: true }
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
console.log(`\n${chalk.green(`${fileName}`)} has been imported!`);
|
|
355
|
+
|
|
356
|
+
await tasks.run().catch(err => {
|
|
357
|
+
console.log(chalk.bold.red(err.toString()));
|
|
358
|
+
process.exit(1);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
console.log(`${chalk.bold.green(`\nSwitched to ${orgLibName}/${version}!\n`)}`);
|
|
362
|
+
|
|
363
|
+
await forceDefaultsUpdate();
|
|
364
|
+
await showCurrentStatus();
|
|
365
|
+
|
|
366
|
+
console.log('\n***************************************************************');
|
|
367
|
+
console.log(chalk.bold.yellow('Dependencies have changed between versions, recommend updating.'));
|
|
368
|
+
console.log(`PLEASE run ${chalk.bold.yellow("'npm update'")}.`);
|
|
369
|
+
console.log('****************************************************************\n');
|
|
370
|
+
}
|
|
371
|
+
|
|
331
372
|
|
|
332
373
|
}
|
|
333
374
|
|
|
@@ -349,7 +390,7 @@ export const getZipFileList = async(filePath) => {
|
|
|
349
390
|
|
|
350
391
|
export default async options => {
|
|
351
392
|
await showVersion();
|
|
352
|
-
await checkLibraryAndArchives();
|
|
393
|
+
// await checkLibraryAndArchives();
|
|
353
394
|
|
|
354
395
|
await checkPathAccess(pegaConfigJsonPath);
|
|
355
396
|
const isLibraryBased = getLibraryBased();
|
|
@@ -358,6 +399,8 @@ export default async options => {
|
|
|
358
399
|
process.exit();
|
|
359
400
|
}
|
|
360
401
|
|
|
402
|
+
const hasArch = await hasArchives();
|
|
403
|
+
|
|
361
404
|
await cleanUpTemp();
|
|
362
405
|
|
|
363
406
|
addDebugLog("importArchive", "", "+");
|
|
@@ -366,7 +409,7 @@ export default async options => {
|
|
|
366
409
|
if (options.params.length >= 5) {
|
|
367
410
|
const filePath = options.params[3];
|
|
368
411
|
const fileName = options.params[4];
|
|
369
|
-
await importArch( filePath, fileName);
|
|
412
|
+
await importArch( filePath, fileName, hasArch);
|
|
370
413
|
|
|
371
414
|
}
|
|
372
415
|
else {
|
|
@@ -388,7 +431,13 @@ export default async options => {
|
|
|
388
431
|
const {fileName} = fileNameAnswers;
|
|
389
432
|
|
|
390
433
|
|
|
391
|
-
await importArch( filePath, fileName);
|
|
434
|
+
await importArch( filePath, fileName, hasArch);
|
|
435
|
+
|
|
436
|
+
// reapply to save if changed, because imported task.config may have overriden and we want
|
|
437
|
+
// to keep what was entered as the latest
|
|
438
|
+
await updateSavedFilePath(filePath);
|
|
439
|
+
|
|
440
|
+
|
|
392
441
|
|
|
393
442
|
}
|
|
394
443
|
|
|
@@ -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",
|
|
@@ -7,7 +7,7 @@ import { showVersion, getLibraryBased, addDebugLog, getConfigDefaults, getCompon
|
|
|
7
7
|
|
|
8
8
|
export const showCurrentStatus = async () => {
|
|
9
9
|
|
|
10
|
-
const configDefaults =
|
|
10
|
+
const configDefaults = getConfigDefaults();
|
|
11
11
|
const componentList = await getComponents();
|
|
12
12
|
|
|
13
13
|
console.log("");
|
|
@@ -94,8 +94,6 @@ addDebugLog("switchLibrary", "", "+");
|
|
|
94
94
|
({ version } = nextAnswers);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
97
|
}
|
|
100
98
|
|
|
101
99
|
// in this scenario, version contains "-dev", if appropriate
|
|
@@ -132,12 +130,6 @@ addDebugLog("switchLibrary", "", "+");
|
|
|
132
130
|
process.exit(1);
|
|
133
131
|
});
|
|
134
132
|
|
|
135
|
-
// archive existing
|
|
136
|
-
// await zipVersionAndArchive(existingOrgLib, oldVersion);
|
|
137
|
-
|
|
138
|
-
// restore from archive
|
|
139
|
-
// await restoreFromArchive(switchToFileName, newOrgLib, newVersion);
|
|
140
|
-
|
|
141
133
|
console.log(`${chalk.bold.green(`\nSwitched to ${newOrgLib}/${newVersion}!\n`)}`);
|
|
142
134
|
|
|
143
135
|
await forceDefaultsUpdate();
|
|
@@ -150,16 +142,6 @@ addDebugLog("switchLibrary", "", "+");
|
|
|
150
142
|
console.log(`PLEASE run ${chalk.bold.yellow("'npm update'")}.`);
|
|
151
143
|
console.log('****************************************************************\n');
|
|
152
144
|
|
|
153
|
-
// const upateQuestions = await getRunNpmQuestions();
|
|
154
|
-
// const answers = await inquirer.prompt(upateQuestions);
|
|
155
|
-
// const { updateNpm } = answers;
|
|
156
|
-
|
|
157
|
-
// if (updateNpm) {
|
|
158
|
-
// await anotherTask.run().catch(err => {
|
|
159
|
-
// console.log(chalk.bold.red(err.toString()));
|
|
160
|
-
// process.exit(1);
|
|
161
|
-
// });
|
|
162
|
-
// }
|
|
163
145
|
}
|
|
164
146
|
|
|
165
147
|
|
package/src/util.js
CHANGED
|
@@ -134,6 +134,7 @@ export const setUpDefaults = async () => {
|
|
|
134
134
|
retrievedConfigData.importRelativePath = data[IMPORT_RELATIVE_PATH];
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
|
|
137
138
|
if (data[EXPORT_RELATIVE_PATH]) {
|
|
138
139
|
retrievedConfigData.exportRelativePath = data[EXPORT_RELATIVE_PATH];
|
|
139
140
|
}
|
|
@@ -572,9 +573,9 @@ if (showDebug) addDebugLog("getComponentsObj", "END", "-");
|
|
|
572
573
|
return compList;
|
|
573
574
|
};
|
|
574
575
|
|
|
575
|
-
export const getPegaConfig = async () => {
|
|
576
|
+
export const getPegaConfig = async (force = false) => {
|
|
576
577
|
if (showDebug) { addDebugLog("getPegaConfig", "", "+"); }
|
|
577
|
-
if (!pegaData) {
|
|
578
|
+
if (!pegaData || force) {
|
|
578
579
|
|
|
579
580
|
if (showDebug) { addDebugLog("getPegaConfig", "retrieveData", ""); }
|
|
580
581
|
const currentDirectory = process.cwd();
|
|
@@ -622,7 +623,7 @@ export const updateServerConfigRuleSetAndVersion = async (rulesetName, rulesetVe
|
|
|
622
623
|
if (showDebug) addDebugLog("updateServerConfigRuleSetAndVersion", `rulesetName: ${rulesetName}, rulesetVersion: ${rulesetVersion}`, "");
|
|
623
624
|
const currentDirectory = process.cwd();
|
|
624
625
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
625
|
-
let configData = await getPegaConfig();
|
|
626
|
+
let configData = await getPegaConfig(true);
|
|
626
627
|
let serverConfig = configData['server-config'];
|
|
627
628
|
|
|
628
629
|
serverConfig.rulesetName = rulesetName;
|
|
@@ -641,7 +642,7 @@ if (showDebug) addDebugLog("updateComponentDefaultLibrary", `library: ${library}
|
|
|
641
642
|
|
|
642
643
|
await checkPathAccess(pegaConfigJsonPath);
|
|
643
644
|
|
|
644
|
-
let config = await getPegaConfig();
|
|
645
|
+
let config = await getPegaConfig(true);
|
|
645
646
|
let componentsDefault = config.component;
|
|
646
647
|
componentsDefault.library = library;
|
|
647
648
|
|
|
@@ -657,7 +658,7 @@ if (showDebug) addDebugLog("updateComponentDefaultVersion", `version: ${version}
|
|
|
657
658
|
|
|
658
659
|
await checkPathAccess(pegaConfigJsonPath);
|
|
659
660
|
|
|
660
|
-
let config = await getPegaConfig();
|
|
661
|
+
let config = await getPegaConfig(true);
|
|
661
662
|
let componentsDefault = config.component;
|
|
662
663
|
componentsDefault.version = version;
|
|
663
664
|
|
|
@@ -679,7 +680,7 @@ export const setConfigDevBuild = async (devBuild) => {
|
|
|
679
680
|
if (showDebug) addDebugLog("setConfigDevBuild", `devBuild: ${devBuild}`, "");
|
|
680
681
|
const currentDirectory = process.cwd();
|
|
681
682
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
682
|
-
let configData = await getPegaConfig();
|
|
683
|
+
let configData = await getPegaConfig(true);
|
|
683
684
|
let serverConfig = configData['server-config'];
|
|
684
685
|
serverConfig.devBuild = devBuild;
|
|
685
686
|
|
|
@@ -692,7 +693,7 @@ export const setConfigImportRelativePath = async (importRelativePath) => {
|
|
|
692
693
|
if (showDebug) addDebugLog("setConfigImportRelativePath", `importRelativePath: ${importRelativePath}`, "");
|
|
693
694
|
const currentDirectory = process.cwd();
|
|
694
695
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
695
|
-
let configData = await getPegaConfig();
|
|
696
|
+
let configData = await getPegaConfig(true);
|
|
696
697
|
configData[IMPORT_RELATIVE_PATH] = importRelativePath;
|
|
697
698
|
|
|
698
699
|
// update file
|
|
@@ -704,7 +705,7 @@ export const setConfigExportRelativePath = async (exportRelativePath) => {
|
|
|
704
705
|
if (showDebug) addDebugLog("setConfigImportRelativePath", `exportRelativePath: ${exportRelativePath}`, "");
|
|
705
706
|
const currentDirectory = process.cwd();
|
|
706
707
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
707
|
-
let configData = await getPegaConfig();
|
|
708
|
+
let configData = await getPegaConfig(true);
|
|
708
709
|
configData[EXPORT_RELATIVE_PATH] = exportRelativePath;
|
|
709
710
|
|
|
710
711
|
// update file
|
|
@@ -813,7 +814,7 @@ export const setServerType = async(serverType) => {
|
|
|
813
814
|
if (showDebug) addDebugLog("setServerType", `serverType: ${serverType}`, "");
|
|
814
815
|
const currentDirectory = process.cwd();
|
|
815
816
|
const pegaConfigJsonPath = join(currentDirectory, TASKS_CONFIG_JSON_FILENAME);
|
|
816
|
-
let configData = await getPegaConfig();
|
|
817
|
+
let configData = await getPegaConfig(true);
|
|
817
818
|
let serverConfig = configData['server-config'];
|
|
818
819
|
serverConfig.serverType = serverType;
|
|
819
820
|
|
|
@@ -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);
|