@pega/react-sdk-overrides 8.23.10 → 23.1.10

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.
Files changed (142) hide show
  1. package/lib/designSystemExtension/AlertBanner/AlertBanner.tsx +47 -0
  2. package/lib/designSystemExtension/AlertBanner/index.tsx +1 -0
  3. package/lib/designSystemExtension/Banner/Banner.tsx +12 -1
  4. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +15 -10
  5. package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +10 -11
  6. package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +10 -3
  7. package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +11 -5
  8. package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +11 -3
  9. package/lib/designSystemExtension/Operator/Operator.tsx +30 -21
  10. package/lib/designSystemExtension/Pulse/Pulse.tsx +11 -7
  11. package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +121 -0
  12. package/lib/designSystemExtension/RichTextEditor/index.tsx +1 -0
  13. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +12 -3
  14. package/lib/field/AutoComplete/AutoComplete.tsx +38 -19
  15. package/lib/field/CancelAlert/CancelAlert.tsx +21 -12
  16. package/lib/field/Checkbox/Checkbox.tsx +42 -9
  17. package/lib/field/Currency/Currency.tsx +24 -16
  18. package/lib/field/Currency/currency-utils.ts +1 -2
  19. package/lib/field/Date/Date.tsx +32 -18
  20. package/lib/field/DateTime/DateTime.tsx +27 -16
  21. package/lib/field/Decimal/Decimal.tsx +82 -19
  22. package/lib/field/Dropdown/Dropdown.tsx +60 -15
  23. package/lib/field/Email/Email.tsx +17 -9
  24. package/lib/field/Integer/Integer.tsx +15 -7
  25. package/lib/field/Percentage/Percentage.tsx +15 -7
  26. package/lib/field/Phone/Phone.tsx +21 -12
  27. package/lib/field/RadioButtons/RadioButtons.tsx +57 -28
  28. package/lib/field/RichText/RichText.tsx +95 -0
  29. package/lib/field/RichText/index.tsx +1 -0
  30. package/lib/field/ScalarList/ScalarList.tsx +73 -0
  31. package/lib/field/ScalarList/config-ext.json +8 -0
  32. package/lib/field/ScalarList/index.tsx +1 -0
  33. package/lib/field/SemanticLink/SemanticLink.tsx +26 -25
  34. package/lib/field/SemanticLink/utils.ts +2 -1
  35. package/lib/field/TextArea/TextArea.tsx +14 -5
  36. package/lib/field/TextContent/TextContent.tsx +10 -1
  37. package/lib/field/TextInput/TextInput.tsx +40 -11
  38. package/lib/field/Time/Time.tsx +29 -26
  39. package/lib/field/URL/URL.tsx +24 -8
  40. package/lib/field/UserReference/UserReference.tsx +52 -60
  41. package/lib/helpers/{attachmentHelpers.js → attachmentHelpers.ts} +5 -5
  42. package/lib/helpers/auth.js +752 -401
  43. package/lib/helpers/authManager.ts +933 -0
  44. package/lib/helpers/case-utils.tsx +103 -0
  45. package/lib/helpers/common-utils.ts +4 -0
  46. package/lib/helpers/config_access.js +63 -145
  47. package/lib/helpers/data_page.ts +2 -1
  48. package/lib/helpers/date-format-utils.ts +29 -19
  49. package/lib/helpers/{event-utils.js → event-utils.ts} +1 -1
  50. package/lib/helpers/{field-group-utils.js → field-group-utils.ts} +10 -11
  51. package/lib/helpers/formatters/{Currency.js → Currency.ts} +13 -12
  52. package/lib/helpers/formatters/{CurrencyMap.js → CurrencyMap.ts} +8 -5
  53. package/lib/helpers/formatters/{Date.js → Date.ts} +2 -2
  54. package/lib/helpers/formatters/{common.js → common.ts} +4 -4
  55. package/lib/helpers/formatters/{index.js → index.ts} +3 -3
  56. package/lib/helpers/simpleTableHelpers.ts +10 -6
  57. package/lib/helpers/state-utils.tsx +47 -0
  58. package/lib/helpers/template-utils.ts +3 -4
  59. package/lib/helpers/utils.ts +12 -4
  60. package/lib/helpers/versionHelpers.ts +0 -1
  61. package/lib/infra/ActionButtons/ActionButtons.tsx +13 -18
  62. package/lib/infra/Assignment/Assignment.tsx +44 -35
  63. package/lib/infra/AssignmentCard/AssignmentCard.tsx +15 -19
  64. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +76 -64
  65. package/lib/infra/Containers/FlowContainer/{helpers.js → helpers.ts} +18 -16
  66. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +41 -25
  67. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +25 -30
  68. package/lib/infra/DashboardFilter/DashboardFilter.tsx +16 -20
  69. package/lib/infra/DashboardFilter/filterUtils.tsx +4 -1
  70. package/lib/infra/DeferLoad/DeferLoad.tsx +16 -19
  71. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +21 -20
  72. package/lib/infra/MultiStep/MultiStep.tsx +24 -24
  73. package/lib/infra/NavBar/NavBar.tsx +23 -24
  74. package/lib/infra/Reference/Reference.tsx +14 -18
  75. package/lib/infra/Region/Region.tsx +8 -6
  76. package/lib/infra/RootContainer/RootContainer.tsx +32 -39
  77. package/lib/infra/Stages/Stages.tsx +15 -9
  78. package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx +8 -1
  79. package/lib/infra/VerticalTabs/VerticalTabs/VerticalTabs.tsx +12 -12
  80. package/lib/infra/View/View.tsx +30 -57
  81. package/lib/template/AppShell/AppShell.tsx +51 -34
  82. package/lib/template/BannerPage/BannerPage.tsx +26 -31
  83. package/lib/template/CaseSummary/CaseSummary.tsx +15 -8
  84. package/lib/template/CaseView/CaseView.tsx +137 -100
  85. package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +27 -27
  86. package/lib/template/Confirmation/Confirmation.tsx +29 -52
  87. package/lib/template/DataReference/DataReference.tsx +51 -53
  88. package/lib/template/DefaultForm/DefaultForm.tsx +29 -20
  89. package/lib/template/DefaultForm/utils/index.ts +33 -0
  90. package/lib/template/Details/Details/Details.tsx +16 -17
  91. package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +13 -16
  92. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +19 -18
  93. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +20 -18
  94. package/lib/template/Details/DynamicTabs/DynamicTabs.tsx +78 -0
  95. package/lib/template/Details/DynamicTabs/config.json +36 -0
  96. package/lib/template/Details/DynamicTabs/index.tsx +1 -0
  97. package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +24 -27
  98. package/lib/template/InlineDashboard/InlineDashboard.tsx +11 -7
  99. package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +20 -18
  100. package/lib/template/ListPage/ListPage.tsx +14 -13
  101. package/lib/template/ListView/ListView.tsx +244 -314
  102. package/lib/template/ListView/{hooks.js → hooks.ts} +3 -1
  103. package/lib/template/ListView/{utils.js → utils.ts} +172 -23
  104. package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +12 -17
  105. package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +16 -1
  106. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +19 -18
  107. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +9 -1
  108. package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +17 -17
  109. package/lib/template/OneColumn/OneColumn/OneColumn.tsx +8 -7
  110. package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +10 -10
  111. package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +5 -7
  112. package/lib/template/PromotedFilters/PromotedFilters.tsx +23 -17
  113. package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +103 -6
  114. package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +29 -8
  115. package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +26 -31
  116. package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +33 -36
  117. package/lib/template/SubTabs/SubTabs.tsx +10 -11
  118. package/lib/template/SubTabs/tabUtils.ts +0 -2
  119. package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +10 -15
  120. package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +10 -10
  121. package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +10 -12
  122. package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +17 -3
  123. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +35 -25
  124. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +7 -1
  125. package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +15 -17
  126. package/lib/template/WssNavBar/WssNavBar.tsx +20 -3
  127. package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +13 -21
  128. package/lib/widget/Attachment/Attachment.css +15 -3
  129. package/lib/widget/Attachment/Attachment.tsx +51 -32
  130. package/lib/widget/CaseHistory/CaseHistory.tsx +13 -11
  131. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +13 -1
  132. package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +40 -26
  133. package/lib/widget/Followers/Followers.tsx +10 -11
  134. package/lib/widget/QuickCreate/QuickCreate.tsx +15 -6
  135. package/lib/widget/SummaryItem/SummaryItem.tsx +12 -4
  136. package/lib/widget/SummaryList/SummaryList.tsx +17 -3
  137. package/lib/widget/ToDo/ToDo.tsx +69 -104
  138. package/package.json +1 -1
  139. package/lib/helpers/authManager.js +0 -631
  140. /package/lib/helpers/formatters/{Boolean.js → Boolean.ts} +0 -0
  141. /package/lib/helpers/{reactContextHelpers.js → reactContextHelpers.ts} +0 -0
  142. /package/lib/template/ListView/{DefaultViewMeta.js → DefaultViewMeta.ts} +0 -0
@@ -1,29 +1,32 @@
1
1
  /* eslint-disable no-template-curly-in-string */
2
- const EURO = {
2
+
3
+ type CurrencyMapType = { name: string, symbolFormat: string, currencyCode: string}
4
+
5
+ const EURO: CurrencyMapType = {
3
6
  name: "Euro (EUR)",
4
7
  symbolFormat: "\u20AC{#}",
5
8
  currencyCode: "EUR {#}"
6
9
  };
7
10
 
8
- const USD = {
11
+ const USD: CurrencyMapType = {
9
12
  name: "U.S. Dollar (USD)",
10
13
  symbolFormat: "${#}",
11
14
  currencyCode: "USD {#}"
12
15
  };
13
16
 
14
- const XAF = {
17
+ const XAF: CurrencyMapType = {
15
18
  name: "CFA Franc (BEAC) (XAF)",
16
19
  symbolFormat: "XAF {#}",
17
20
  currencyCode: "XAF {#}"
18
21
  };
19
22
 
20
- const XCD = {
23
+ const XCD: CurrencyMapType = {
21
24
  name: "East Caribbean Dollar (XCD)",
22
25
  symbolFormat: "${#}",
23
26
  currencyCode: "XCD {#}"
24
27
  };
25
28
 
26
- const XPF = {
29
+ const XPF: CurrencyMapType = {
27
30
  name: "Pacific Franc (XPF)",
28
31
  symbolFormat: "₣{#}",
29
32
  currencyCode: "XPF {#}"
@@ -13,8 +13,8 @@ const types = ["fromNow", "customFormat"];
13
13
 
14
14
  // value should be in ISO 8601 format.
15
15
  function DateFormatter(
16
- value,
17
- { type = types[1], format = "DD/MM/YYYY", timezone } = {}
16
+ value: string,
17
+ { type = types[1], format = "DD/MM/YYYY", timezone = "America/New_York" } = {}
18
18
  ) {
19
19
  if (!value) return value;
20
20
  switch (type) {
@@ -1,14 +1,14 @@
1
- export function getLocale(locale) {
1
+
2
+ export function getLocale(locale: string = '') {
2
3
  // use locale if specified
3
4
  if (locale) return locale;
4
5
  // otherwise, use operator locale if it's defined
5
- if (window.PCore.getEnvironmentInfo().getUseLocale()) return window.PCore.getEnvironmentInfo().getUseLocale();
6
+ if (PCore.getEnvironmentInfo().getLocale()) return PCore.getEnvironmentInfo().getLocale();
6
7
  // fallback
7
8
  return Intl.DateTimeFormat().resolvedOptions().locale;
8
9
  }
9
10
 
10
- export function getCurrentTimezone(timezone) {
11
+ export function getCurrentTimezone(timezone: string = "America/New_York" ) {
11
12
  if (timezone) return timezone;
12
- // eslint-disable-next-line no-undef
13
13
  return PCore?.getLocaleUtils?.().getTimeZoneInUse?.();
14
14
  }
@@ -9,7 +9,7 @@ export default {
9
9
  ...DateFormatter
10
10
  };
11
11
 
12
- function getDateObject(text) {
12
+ function getDateObject(text): Date {
13
13
  // TODO - cleanup formatters util functions as DX APIs are returning values per ISO std now.
14
14
  const timeStamp = text.replace(/-/g, "");
15
15
  const isDateTime = timeStamp.indexOf("GMT") !== -1;
@@ -58,8 +58,8 @@ function parseDateInISO(value) {
58
58
  return value ? getDateObject(value).toISOString() : value;
59
59
  }
60
60
 
61
- export function format(value, type, options = {}) {
62
- let formattedValue;
61
+ export function format(value, type, options = {}): string {
62
+ let formattedValue: string;
63
63
 
64
64
  switch (type?.toLowerCase()) {
65
65
  case "currency": {
@@ -1,6 +1,5 @@
1
1
  import { Utils } from './utils';
2
2
 
3
- declare const PCore;
4
3
 
5
4
  export const TABLE_CELL = "SdkRenderer";
6
5
  export const DELETE_ICON = "DeleteIcon";
@@ -8,7 +7,7 @@ export const DELETE_ICON = "DeleteIcon";
8
7
  // BUG-615253: Workaround for autosize in table with lazy loading components
9
8
  /* istanbul ignore next */
10
9
  function getFieldWidth(field, label) {
11
- let width;
10
+ let width: number;
12
11
  switch (field.type) {
13
12
  case "Time":
14
13
  width = 150;
@@ -46,7 +45,7 @@ function getFieldWidth(field, label) {
46
45
  export const getContext = (thePConn) => {
47
46
  const contextName = thePConn.getContextName();
48
47
  const pageReference = thePConn.getPageReference();
49
- let { referenceList } = thePConn.getStateProps().config;
48
+ let { referenceList } = thePConn.getStateProps()?.config || thePConn.getStateProps();
50
49
  const pageReferenceForRows = referenceList.startsWith(".")
51
50
  ? `${pageReference}.${referenceList.substring(1)}`
52
51
  : referenceList;
@@ -65,7 +64,7 @@ export const getContext = (thePConn) => {
65
64
  };
66
65
 
67
66
  export const populateRowKey = (rawData) => {
68
- return rawData.map((row, index) => {
67
+ return rawData.map((row: any, index: number) => {
69
68
  return { ...row, index };
70
69
  });
71
70
  };
@@ -103,6 +102,7 @@ export const buildMetaForListView = (
103
102
  ruleClass,
104
103
  name,
105
104
  propertyLabel,
105
+ isDataObject,
106
106
  parameters
107
107
  ) => {
108
108
  return {
@@ -112,10 +112,12 @@ export const buildMetaForListView = (
112
112
  referenceList: fieldMetadata.datasource.name,
113
113
  parameters: parameters ?? fieldMetadata.datasource.parameters,
114
114
  personalization: false,
115
+ isDataObject,
115
116
  grouping: true,
116
117
  globalSearch: true,
117
118
  reorderFields: true,
118
119
  toggleFieldVisibility: true,
120
+ title: propertyLabel,
119
121
  personalizationId: "" /* TODO */,
120
122
  template: "ListView",
121
123
  presets: [
@@ -207,7 +209,7 @@ export const createMetaForTable = (fields, renderMode) => {
207
209
  * @param {number} index - index of the page list to add
208
210
  */
209
211
  export const getAddRowCallback = (pConnect, index) => {
210
- return () => pConnect.getListActions().insert({}, index);
212
+ return () => pConnect.getListActions().insert({}, index, ''); // 3rd arg null until typedef marked correctly as optional
211
213
  };
212
214
 
213
215
  /**
@@ -216,7 +218,9 @@ export const getAddRowCallback = (pConnect, index) => {
216
218
  * @param {string} referenceList - referenceList
217
219
  * @param {string} pageReference - pageReference
218
220
  */
219
- export const createPConnect = (contextName, referenceList, pageReference) => {
221
+ // NOTE: use of type "any" is required since TypeScript doesn't allow private/protected properties
222
+ // to be exported from a class (TS4094 error)
223
+ export function createPConnect(contextName, referenceList, pageReference): any {
220
224
  const options = {
221
225
  context: contextName,
222
226
  pageReference,
@@ -0,0 +1,47 @@
1
+ import React, { useContext } from 'react';
2
+ import { connect, Provider, shallowEqual } from 'react-redux';
3
+ import ReactReduxContext from '@pega/react-sdk-components/lib/bridge/Context/StoreContext';
4
+
5
+
6
+ const connectToState = (mapStateToProps = () => {}) => {
7
+ return (Component: any) => {
8
+ const ConnectedComponent = connect(mapStateToProps, null, null, {
9
+ areStatePropsEqual: (next, prev: any) => {
10
+ // Compare visibility
11
+ const prevWasVisible = prev.visibility !== false;
12
+ if (next.visibility !== undefined && next.visibility !== prevWasVisible) {
13
+ return false;
14
+ }
15
+ // Compare start props
16
+ const c11nEnv = next.getPConnect();
17
+ const allStateProps = c11nEnv.getStateProps();
18
+ for (const key in allStateProps) {
19
+ if (
20
+ !shallowEqual(next[key], prev[key]) ||
21
+ (next.routingInfo && !PCore.isDeepEqual(next.routingInfo, prev.routingInfo))
22
+ ) {
23
+ return false;
24
+ }
25
+ }
26
+ /* TODO For some rawConfig we are not getting routingInfo under allStateProps */
27
+ return !(
28
+ 'routingInfo' in next &&
29
+ (!shallowEqual(next.routingInfo, prev.routingInfo) ||
30
+ !PCore.isDeepEqual(next.routingInfo, prev.routingInfo))
31
+ );
32
+ }
33
+ })(Component);
34
+
35
+ return (ownProps = {}) => {
36
+ const { store } = useContext<any>(ReactReduxContext);
37
+
38
+ return (
39
+ <Provider store={store}>
40
+ <ConnectedComponent {...ownProps} />
41
+ </Provider>
42
+ );
43
+ };
44
+ };
45
+ };
46
+
47
+ export default connectToState;
@@ -1,10 +1,9 @@
1
1
  // This file is adapted from React DX components/template/utils.js
2
2
 
3
- declare const PCore: any;
4
3
 
5
4
  export function getAllFields(pConnect: any) {
6
5
  const metadata = pConnect.getRawMetadata();
7
- let allFields = [];
6
+ let allFields: Array<any> = [];
8
7
  if (metadata.children && metadata.children.map) {
9
8
  allFields = metadata.children.map(fields => {
10
9
  const children = fields.children instanceof Array ? fields.children : [];
@@ -14,7 +13,7 @@ export function getAllFields(pConnect: any) {
14
13
  return allFields;
15
14
  }
16
15
 
17
- export function filterForFieldValueList(fields: any) {
16
+ export function filterForFieldValueList(fields: Array<any>) {
18
17
  return fields
19
18
  .filter(({ visibility }) => visibility !== false)
20
19
  .map(({ value, label }) => ({
@@ -47,7 +46,7 @@ export function getIsAssignmentView(pConnect) {
47
46
  * @param {Function} pConnect PConnect object for the component
48
47
  * @param {string} [instructions="casestep"] 'casestep', 'none', or the html content of a Rule-UI-Paragraph rule (processed via core's paragraph annotation handler)
49
48
  */
50
- export function getInstructions(pConnect, instructions = 'casestep') {
49
+ export function getInstructions(pConnect, instructions: string = 'casestep'): string | undefined {
51
50
  const caseStepInstructions =
52
51
  PCore.getConstants().CASE_INFO.INSTRUCTIONS &&
53
52
  pConnect.getValue(PCore.getConstants().CASE_INFO.INSTRUCTIONS);
@@ -2,6 +2,7 @@ import dayjs from 'dayjs';
2
2
  import customParseFormat from 'dayjs/plugin/customParseFormat';
3
3
  import localizedFormat from 'dayjs/plugin/localizedFormat';
4
4
  import relativeTime from 'dayjs/plugin/relativeTime';
5
+ import { SdkConfigAccess } from './config_access';
5
6
 
6
7
  dayjs.extend(customParseFormat);
7
8
  dayjs.extend(localizedFormat);
@@ -10,6 +11,17 @@ dayjs.extend(relativeTime);
10
11
  export class Utils {
11
12
  static lastControlID: number = 0;
12
13
 
14
+ static getSDKStaticConentUrl() {
15
+ const sdkConfigServer = SdkConfigAccess.getSdkConfigServer();
16
+
17
+ // NOTE: Needs a trailing slash! So add one if not provided
18
+ if (!sdkConfigServer.sdkContentServerUrl.endsWith('/')) {
19
+ sdkConfigServer.sdkContentServerUrl = `${sdkConfigServer.sdkContentServerUrl}/`;
20
+ }
21
+
22
+ return `${sdkConfigServer.sdkContentServerUrl}constellation/`;
23
+ }
24
+
13
25
  static getUniqueControlID(): string {
14
26
  const sPrefix = 'control-';
15
27
 
@@ -322,10 +334,6 @@ export class Utils {
322
334
  return text.charAt(text.length - 1);
323
335
  }
324
336
 
325
- static isEmptyObject(obj: Object): Boolean {
326
- return Object.keys(obj).length === 0;
327
- }
328
-
329
337
  static isObject(objValue) {
330
338
  return objValue && typeof objValue === 'object' && objValue.constructor === Object;
331
339
  }
@@ -5,7 +5,6 @@
5
5
  * PCore/PConnect is being run
6
6
  */
7
7
 
8
- declare const PCore;
9
8
 
10
9
  export const sdkVersion = "8.7";
11
10
 
@@ -1,10 +1,16 @@
1
1
  import React from "react";
2
- import PropTypes from "prop-types";
3
2
  import { makeStyles } from '@material-ui/core/styles';
4
3
 
5
4
  import Button from '@material-ui/core/Button';
6
5
  import { Grid, Divider } from "@material-ui/core";
7
6
 
7
+ // ActionButtons does NOT have getPConnect. So, no need to extend from PConnProps
8
+ interface ActionButtonsProps {
9
+ // If any, enter additional props that only exist on this component
10
+ arMainButtons?: Array<any>,
11
+ arSecondaryButtons?: Array<any>,
12
+ onButtonPress: any
13
+ }
8
14
 
9
15
 
10
16
  const useStyles = makeStyles((/* theme */) => ({
@@ -18,9 +24,11 @@ const useStyles = makeStyles((/* theme */) => ({
18
24
  }));
19
25
 
20
26
 
21
- export default function ActionButtons(props) {
22
- const { arMainButtons, arSecondaryButtons, onButtonPress } = props;
27
+ export default function ActionButtons(props: ActionButtonsProps) {
28
+ const { arMainButtons = [], arSecondaryButtons = [], onButtonPress } = props;
23
29
  const classes = useStyles();
30
+ const localizedVal = PCore.getLocaleUtils().getLocaleValue;
31
+ const localeCategory = 'Assignment';
24
32
 
25
33
  function _onButtonPress(sAction: string, sButtonType: string) {
26
34
 
@@ -35,7 +43,7 @@ export default function ActionButtons(props) {
35
43
  <Grid container spacing={1}>
36
44
  {arSecondaryButtons.map((sButton) => (
37
45
  <Grid item key={sButton.name}>
38
- <Button variant="contained" color="secondary" onClick={() => { _onButtonPress(sButton.jsAction, "secondary")}} >{sButton.name}</Button>
46
+ <Button variant="contained" color="secondary" onClick={() => { _onButtonPress(sButton.jsAction, "secondary")}} >{localizedVal(sButton.name, localeCategory)}</Button>
39
47
  </Grid>
40
48
  ))}
41
49
  </Grid>
@@ -44,7 +52,7 @@ export default function ActionButtons(props) {
44
52
  <Grid container spacing={1}>
45
53
  {arMainButtons.map((mButton) => (
46
54
  <Grid item key={mButton.name}>
47
- <Button variant="contained" color="primary" onClick={() => { _onButtonPress(mButton.jsAction, "primary")}} >{mButton.name}</Button>
55
+ <Button variant="contained" color="primary" onClick={() => { _onButtonPress(mButton.jsAction, "primary")}} >{localizedVal(mButton.name, localeCategory)}</Button>
48
56
  </Grid>
49
57
  ))}
50
58
  </Grid>
@@ -55,16 +63,3 @@ export default function ActionButtons(props) {
55
63
 
56
64
  )
57
65
  }
58
-
59
- ActionButtons.propTypes = {
60
- arMainButtons: PropTypes.array,
61
- arSecondaryButtons: PropTypes.array,
62
- onButtonPress: PropTypes.func
63
- // buildName: PropTypes.string
64
- };
65
-
66
- ActionButtons.defaultProps = {
67
- arMainButtons: [],
68
- arSecondaryButtons: []
69
- // buildName: null
70
- };
@@ -1,25 +1,43 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import PropTypes from 'prop-types';
3
-
4
- import AssignmentCard from '@pega/react-sdk-components/lib/components/infra/AssignmentCard';
5
- import MultiStep from '@pega/react-sdk-components/lib/components/infra/MultiStep';
6
2
  import Snackbar from '@material-ui/core/Snackbar';
7
3
  import IconButton from '@material-ui/core/IconButton';
8
4
  import CloseIcon from '@material-ui/icons/Close';
9
-
10
- declare const PCore: any;
11
-
12
- export default function Assignment(props) {
13
- const { getPConnect, children, itemKey, isInModal } = props;
5
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
6
+
7
+ // import type { PConnProps } from '../../../types/PConnProps';
8
+
9
+ // Can't use AssignmentProps until the following are NOT private
10
+ // getCaseInfo().isAssignmentInCreateStage()
11
+ // getCaseInfo().isLocalAction()
12
+ // interface AssignmentProps extends PConnProps {
13
+ // // If any, enter additional props that only exist on this component
14
+ // children: Array<any>,
15
+ // itemKey: string,
16
+ // isInModal: boolean,
17
+ // banners: Array<any>
18
+ // // eslint-disable-next-line react/no-unused-prop-types
19
+ // actionButtons: Array<any>,
20
+ // }
21
+
22
+
23
+ export default function Assignment(props /* : AssignmentProps */) {
24
+ // Get emitted components from map (so we can get any override that may exist)
25
+ const AssignmentCard = getComponentFromMap("AssignmentCard");
26
+ const MultiStep = getComponentFromMap("MultiStep");
27
+
28
+ const { getPConnect, children, itemKey = '', isInModal = false, banners = [] } = props;
14
29
  const thePConn = getPConnect();
15
30
 
16
31
  const [bHasNavigation, setHasNavigation] = useState(false);
17
- const [actionButtons, setActionButtons] = useState({});
32
+ const [actionButtons, setActionButtons] = useState([]);
18
33
  const [bIsVertical, setIsVertical] = useState(false);
19
34
  const [arCurrentStepIndicies, setArCurrentStepIndicies] = useState<Array<any>>([]);
20
35
  const [arNavigationSteps, setArNavigationSteps] = useState<Array<any>>([]);
21
36
 
22
37
  const actionsAPI = thePConn.getActionsApi();
38
+ const localizedVal = PCore.getLocaleUtils().getLocaleValue;
39
+ const localeCategory = 'Assignment';
40
+ const localeReference = `${getPConnect().getCaseInfo().getClassName()}!CASE!${getPConnect().getCaseInfo().getName()}`.toUpperCase();
23
41
 
24
42
  // store off bound functions to above pointers
25
43
  const finishAssignment = actionsAPI.finishAssignment.bind(actionsAPI);
@@ -66,10 +84,10 @@ export default function Assignment(props) {
66
84
 
67
85
  const oWorkItem = children[0].props.getPConnect();
68
86
  const oWorkData = oWorkItem.getDataObject();
69
- const oData = thePConn.getDataObject();
87
+ const oData = thePConn.getDataObject(''); // 1st arg empty string until typedefs allow it to be optional
70
88
 
71
89
  if (oWorkData?.caseInfo && oWorkData.caseInfo.assignments !== null) {
72
- const oCaseInfo = oData.caseInfo;
90
+ const oCaseInfo = oData["caseInfo"];
73
91
 
74
92
  if (oCaseInfo && oCaseInfo.actionButtons) {
75
93
  setActionButtons(oCaseInfo.actionButtons);
@@ -91,8 +109,13 @@ export default function Assignment(props) {
91
109
  } else {
92
110
  setIsVertical(false);
93
111
  }
94
-
95
- setArNavigationSteps(JSON.parse(JSON.stringify(oCaseInfo.navigation.steps)));
112
+ const steps = JSON.parse(JSON.stringify(oCaseInfo?.navigation?.steps));
113
+ steps.forEach(step => {
114
+ if (step.name) {
115
+ step.name = PCore.getLocaleUtils().getLocaleValue(step.name, undefined, localeReference);
116
+ }
117
+ });
118
+ setArNavigationSteps(steps);
96
119
  setArCurrentStepIndicies(
97
120
  findCurrentIndicies(arNavigationSteps, arCurrentStepIndicies, 0)
98
121
  );
@@ -134,7 +157,7 @@ export default function Assignment(props) {
134
157
  navigatePromise
135
158
  .then(() => {})
136
159
  .catch(() => {
137
- showToast(`Navigation failed!`);
160
+ showToast(`${localizedVal('Navigation failed!', localeCategory)}`);
138
161
  });
139
162
 
140
163
  break;
@@ -153,7 +176,7 @@ export default function Assignment(props) {
153
176
  onSaveActionSuccess({ caseType, caseID, assignmentID });
154
177
  })
155
178
  .catch(() => {
156
- showToast('Save failed');
179
+ showToast(`${localizedVal('Save failed', localeCategory)}`);
157
180
  });
158
181
 
159
182
  break;
@@ -167,7 +190,7 @@ export default function Assignment(props) {
167
190
  const isLocalAction =
168
191
  thePConn.getCaseInfo().isLocalAction() ||
169
192
  (PCore.getConstants().CASE_INFO.IS_LOCAL_ACTION &&
170
- getPConnect().getValue(PCore.getConstants().CASE_INFO.IS_LOCAL_ACTION));
193
+ getPConnect().getValue(PCore.getConstants().CASE_INFO.IS_LOCAL_ACTION, ''));// 2nd arg empty string until typedefs allow it to be optional
171
194
  if (isAssignmentInCreateStage && isInModal && !isLocalAction) {
172
195
  const cancelPromise = cancelCreateStageAssignment(itemKey);
173
196
 
@@ -176,7 +199,7 @@ export default function Assignment(props) {
176
199
  publish(PUB_SUB_EVENTS.EVENT_CANCEL, data);
177
200
  })
178
201
  .catch(() => {
179
- showToast(`Cancel failed!`);
202
+ showToast(`${localizedVal('Cancel failed!', localeCategory)}`);
180
203
  });
181
204
  } else {
182
205
  const cancelPromise = cancelAssignment(itemKey);
@@ -186,7 +209,7 @@ export default function Assignment(props) {
186
209
  publish(PUB_SUB_EVENTS.EVENT_CANCEL, data);
187
210
  })
188
211
  .catch(() => {
189
- showToast(`Cancel failed!`);
212
+ showToast(`${localizedVal('Cancel failed!', localeCategory)}`);
190
213
  });
191
214
  }
192
215
  break;
@@ -204,7 +227,7 @@ export default function Assignment(props) {
204
227
  finishPromise
205
228
  .then(() => {})
206
229
  .catch(() => {
207
- showToast(`Submit failed!`);
230
+ showToast(`${localizedVal('Submit failed!', localeCategory)}`);
208
231
  });
209
232
 
210
233
  break;
@@ -218,6 +241,7 @@ export default function Assignment(props) {
218
241
 
219
242
  return (
220
243
  <div id='Assignment'>
244
+ {banners}
221
245
  {bHasNavigation ? (
222
246
  <React.Fragment>
223
247
  <MultiStep
@@ -303,18 +327,3 @@ export default function Assignment(props) {
303
327
  // <lit-toast></lit-toast>
304
328
  // </div>`}
305
329
  // `;
306
-
307
- Assignment.propTypes = {
308
- children: PropTypes.node.isRequired,
309
- getPConnect: PropTypes.func.isRequired,
310
- itemKey: PropTypes.string,
311
- isInModal: PropTypes.bool
312
- // actionButtons: PropTypes.object
313
- // buildName: PropTypes.string
314
- };
315
-
316
- Assignment.defaultProps = {
317
- itemKey: null,
318
- isInModal: false
319
- // buildName: null
320
- };
@@ -1,9 +1,21 @@
1
1
  import React, { useState, useEffect } from "react";
2
- import PropTypes from "prop-types";
2
+ import type { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
3
+ import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
4
+
5
+ interface AssignmentCardProps extends PConnProps {
6
+ // If any, enter additional props that only exist on this component
7
+ children: Array<any>,
8
+ actionButtons: any,
9
+ onButtonPress: any,
10
+ // eslint-disable-next-line react/no-unused-prop-types
11
+ itemKey?: string
12
+ }
13
+
3
14
 
4
- import ActionButtons from "@pega/react-sdk-components/lib/components/infra/ActionButtons";
15
+ export default function AssignmentCard(props: AssignmentCardProps) {
16
+ // Get emitted components from map (so we can get any override that may exist)
17
+ const ActionButtons = getComponentFromMap("ActionButtons");
5
18
 
6
- export default function AssignmentCard(props) {
7
19
  const { children, actionButtons, onButtonPress} = props;
8
20
 
9
21
  const [arMainButtons, setArMainButtons] = useState([]);
@@ -29,19 +41,3 @@ export default function AssignmentCard(props) {
29
41
  </>
30
42
  )
31
43
  }
32
-
33
- AssignmentCard.propTypes = {
34
- children: PropTypes.node.isRequired,
35
- // eslint-disable-next-line react/no-unused-prop-types
36
- getPConnect: PropTypes.func.isRequired,
37
- // eslint-disable-next-line react/no-unused-prop-types
38
- itemKey: PropTypes.string,
39
- actionButtons: PropTypes.object,
40
- onButtonPress: PropTypes.func
41
- // buildName: PropTypes.string
42
- };
43
-
44
- AssignmentCard.defaultProps = {
45
- itemKey: null,
46
- // buildName: null
47
- };