carbon-addons-iot-react 5.9.2 → 5.10.1
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/es/components/Card/Card.js +18 -5
- package/es/components/CardEditor/CardEditForm/CardEditForm.js +16 -0
- package/es/components/CardEditor/CardEditForm/CardEditFormContent.js +17 -0
- package/es/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItemModal.js +19 -4
- package/es/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItems/DataSeriesFormContent.js +19 -2
- package/es/components/CardEditor/CardEditForm/CommonCardEditFormFields.js +18 -2
- package/es/components/CardEditor/CardEditor.js +16 -0
- package/es/components/DashboardEditor/DashboardEditor.js +19 -1
- package/es/components/DashboardEditor/DashboardEditorCardRenderer.js +4 -2
- package/es/components/ValueCard/Attribute.js +40 -3
- package/es/components/ValueCard/ValueCard.js +15 -3
- package/es/components/ValueCard/ValueContent.js +19 -2
- package/es/constants/CardPropTypes.js +2 -0
- package/es/utils/cardUtilityFunctions.js +16 -1
- package/lib/components/Card/Card.js +17 -4
- package/lib/components/CardEditor/CardEditForm/CardEditForm.js +16 -0
- package/lib/components/CardEditor/CardEditForm/CardEditFormContent.js +17 -0
- package/lib/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItemModal.js +18 -3
- package/lib/components/CardEditor/CardEditForm/CardEditFormItems/DataSeriesFormItems/DataSeriesFormContent.js +19 -2
- package/lib/components/CardEditor/CardEditForm/CommonCardEditFormFields.js +18 -2
- package/lib/components/CardEditor/CardEditor.js +16 -0
- package/lib/components/DashboardEditor/DashboardEditor.js +19 -1
- package/lib/components/DashboardEditor/DashboardEditorCardRenderer.js +4 -2
- package/lib/components/ValueCard/Attribute.js +40 -3
- package/lib/components/ValueCard/ValueCard.js +15 -3
- package/lib/components/ValueCard/ValueContent.js +19 -2
- package/lib/constants/CardPropTypes.js +2 -0
- package/lib/utils/cardUtilityFunctions.js +16 -0
- package/package.json +1 -1
- package/umd/carbon-addons-iot-react.js +230 -22
|
@@ -26,7 +26,7 @@ import { settings } from '../../constants/Settings.js';
|
|
|
26
26
|
import { CARD_SIZES, CARD_LAYOUTS, ROW_HEIGHT, DASHBOARD_SIZES, CARD_DIMENSIONS, DASHBOARD_BREAKPOINTS, DASHBOARD_COLUMNS, CARD_TYPES, CARD_CONTENT_PADDING, CARD_TITLE_HEIGHT } from '../../constants/LayoutConstants.js';
|
|
27
27
|
import { CardPropTypes } from '../../constants/CardPropTypes.js';
|
|
28
28
|
import { getCardMinSize, filterValidAttributes } from '../../utils/componentUtilityFunctions.js';
|
|
29
|
-
import { getUpdatedCardSize, useCardResizing } from '../../utils/cardUtilityFunctions.js';
|
|
29
|
+
import { getTranslatedLabel, getUpdatedCardSize, useCardResizing } from '../../utils/cardUtilityFunctions.js';
|
|
30
30
|
import { parseValue } from '../DateTimePicker/dateTimePickerUtils.js';
|
|
31
31
|
import useSizeObserver from '../../hooks/useSizeObserver.js';
|
|
32
32
|
import EmptyState from '../EmptyState/EmptyState.js';
|
|
@@ -36,7 +36,7 @@ import CardToolbar from './CardToolbar.js';
|
|
|
36
36
|
import { CardTitle } from './CardTitle.js';
|
|
37
37
|
|
|
38
38
|
var _excluded = ["isSelected", "children", "dimensions", "id", "style", "className", "onScroll", "onMouseDown", "onMouseUp", "onTouchEnd", "onTouchStart", "onFocus", "onBlur", "tabIndex", "testID", "testId"],
|
|
39
|
-
_excluded2 = ["size", "children", "title", "subtitle", "hasTitleWrap", "layout", "isLoading", "isEmpty", "isEditable", "isExpanded", "isLazyLoading", "isResizable", "resizeHandles", "error", "hideHeader", "id", "tooltip", "titleTextTooltip", "timeRange", "timeRangeOptions", "onCardAction", "availableActions", "renderExpandIcon", "renderDateDropdownInPortal", "breakpoint", "i18n", "style", "className", "values", "testID", "testId", "contentClassName", "footerContent", "dateTimeMask", "extraActions", "padding", "overrides", "type", "data", "content", "extraHeaderContent"];
|
|
39
|
+
_excluded2 = ["size", "children", "title", "subtitle", "hasTitleWrap", "layout", "isLoading", "isEmpty", "isEditable", "isExpanded", "isLazyLoading", "isResizable", "resizeHandles", "error", "hideHeader", "id", "tooltip", "titleTextTooltip", "timeRange", "timeRangeOptions", "onCardAction", "availableActions", "renderExpandIcon", "renderDateDropdownInPortal", "breakpoint", "i18n", "style", "className", "values", "testID", "testId", "contentClassName", "footerContent", "dateTimeMask", "extraActions", "padding", "overrides", "type", "data", "content", "extraHeaderContent", "shouldUseTranslatedLabels"];
|
|
40
40
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
41
41
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
42
42
|
var prefix = settings.prefix,
|
|
@@ -252,7 +252,8 @@ var defaultProps = {
|
|
|
252
252
|
overrides: undefined,
|
|
253
253
|
type: null,
|
|
254
254
|
data: null,
|
|
255
|
-
content: null
|
|
255
|
+
content: null,
|
|
256
|
+
shouldUseTranslatedLabels: false
|
|
256
257
|
};
|
|
257
258
|
|
|
258
259
|
/** Dumb component that renders the card basics */
|
|
@@ -260,7 +261,7 @@ var Card = function Card(props) {
|
|
|
260
261
|
var _overrides$errorMessa, _overrides$errorMessa2, _overrides$errorMessa3;
|
|
261
262
|
var size = props.size,
|
|
262
263
|
children = props.children,
|
|
263
|
-
|
|
264
|
+
titleProp = props.title,
|
|
264
265
|
subtitleProp = props.subtitle,
|
|
265
266
|
hasTitleWrap = props.hasTitleWrap;
|
|
266
267
|
props.layout;
|
|
@@ -274,7 +275,7 @@ var Card = function Card(props) {
|
|
|
274
275
|
error = props.error,
|
|
275
276
|
hideHeader = props.hideHeader,
|
|
276
277
|
id = props.id,
|
|
277
|
-
|
|
278
|
+
tooltipProp = props.tooltip,
|
|
278
279
|
titleTextTooltip = props.titleTextTooltip,
|
|
279
280
|
timeRange = props.timeRange,
|
|
280
281
|
timeRangeOptions = props.timeRangeOptions,
|
|
@@ -299,8 +300,13 @@ var Card = function Card(props) {
|
|
|
299
300
|
data = props.data,
|
|
300
301
|
content = props.content,
|
|
301
302
|
extraHeaderContent = props.extraHeaderContent,
|
|
303
|
+
shouldUseTranslatedLabels = props.shouldUseTranslatedLabels,
|
|
302
304
|
others = _objectWithoutProperties(props, _excluded2);
|
|
303
305
|
|
|
306
|
+
// Get translated title if shouldUseTranslatedLabels is true
|
|
307
|
+
var title = getTranslatedLabel(titleProp, shouldUseTranslatedLabels, i18n);
|
|
308
|
+
var tooltip = getTranslatedLabel(tooltipProp, shouldUseTranslatedLabels, i18n);
|
|
309
|
+
|
|
304
310
|
// TODO: remove once final version of range prop is supported
|
|
305
311
|
useEffect(function () {
|
|
306
312
|
if (typeof (availableActions === null || availableActions === void 0 ? void 0 : availableActions.range) === 'string') {
|
|
@@ -788,6 +794,13 @@ Card.__docgenInfo = {
|
|
|
788
794
|
"computed": false
|
|
789
795
|
},
|
|
790
796
|
"required": false
|
|
797
|
+
},
|
|
798
|
+
"shouldUseTranslatedLabels": {
|
|
799
|
+
"defaultValue": {
|
|
800
|
+
"value": "false",
|
|
801
|
+
"computed": false
|
|
802
|
+
},
|
|
803
|
+
"required": false
|
|
791
804
|
}
|
|
792
805
|
},
|
|
793
806
|
"composes": ["../../constants/CardPropTypes"]
|
|
@@ -51,6 +51,8 @@ var propTypes = {
|
|
|
51
51
|
modalHelpText: PropTypes.string,
|
|
52
52
|
modalIconDescription: PropTypes.string
|
|
53
53
|
}),
|
|
54
|
+
/** whether to use translated labels in cards */
|
|
55
|
+
shouldUseTranslatedLabels: PropTypes.bool,
|
|
54
56
|
/** if provided, returns an array of strings which are the dataItems to be allowed
|
|
55
57
|
* on each card
|
|
56
58
|
* getValidDataItems(card, selectedTimeRange)
|
|
@@ -112,6 +114,7 @@ var defaultProps = {
|
|
|
112
114
|
modalHelpText: 'The JSON definition for this card is provided below. You can modify this data directly to update the card configuration.',
|
|
113
115
|
modalIconDescription: 'Close'
|
|
114
116
|
},
|
|
117
|
+
shouldUseTranslatedLabels: false,
|
|
115
118
|
getValidDataItems: null,
|
|
116
119
|
getValidTimeRanges: null,
|
|
117
120
|
dataItems: [],
|
|
@@ -133,6 +136,7 @@ var CardEditForm = function CardEditForm(_ref) {
|
|
|
133
136
|
availableDimensions = _ref.availableDimensions,
|
|
134
137
|
dataSeriesItemLinks = _ref.dataSeriesItemLinks,
|
|
135
138
|
onFetchDynamicDemoHotspots = _ref.onFetchDynamicDemoHotspots,
|
|
139
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
136
140
|
actions = _ref.actions;
|
|
137
141
|
var mergedI18n = useMemo(function () {
|
|
138
142
|
return _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
|
|
@@ -149,6 +153,7 @@ var CardEditForm = function CardEditForm(_ref) {
|
|
|
149
153
|
onChange: onChange,
|
|
150
154
|
isSummaryDashboard: isSummaryDashboard,
|
|
151
155
|
i18n: mergedI18n,
|
|
156
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
152
157
|
dataItems: dataItems,
|
|
153
158
|
availableDimensions: availableDimensions,
|
|
154
159
|
getValidDataItems: getValidDataItems,
|
|
@@ -296,6 +301,17 @@ CardEditForm.__docgenInfo = {
|
|
|
296
301
|
},
|
|
297
302
|
"required": false
|
|
298
303
|
},
|
|
304
|
+
"shouldUseTranslatedLabels": {
|
|
305
|
+
"defaultValue": {
|
|
306
|
+
"value": "false",
|
|
307
|
+
"computed": false
|
|
308
|
+
},
|
|
309
|
+
"description": "whether to use translated labels in cards",
|
|
310
|
+
"type": {
|
|
311
|
+
"name": "bool"
|
|
312
|
+
},
|
|
313
|
+
"required": false
|
|
314
|
+
},
|
|
299
315
|
"getValidDataItems": {
|
|
300
316
|
"defaultValue": {
|
|
301
317
|
"value": "null",
|
|
@@ -78,6 +78,8 @@ var propTypes = {
|
|
|
78
78
|
thisQuarterLabel: PropTypes.string,
|
|
79
79
|
thisYearLabel: PropTypes.string
|
|
80
80
|
}),
|
|
81
|
+
/** whether to use translated labels in cards */
|
|
82
|
+
shouldUseTranslatedLabels: PropTypes.bool,
|
|
81
83
|
/** if provided, returns an array of strings which are the timeRanges to be allowed
|
|
82
84
|
* on each card
|
|
83
85
|
* getValidTimeRanges(card, selectedDataItems)
|
|
@@ -114,6 +116,7 @@ var propTypes = {
|
|
|
114
116
|
var defaultProps = {
|
|
115
117
|
cardConfig: {},
|
|
116
118
|
i18n: {},
|
|
119
|
+
shouldUseTranslatedLabels: false,
|
|
117
120
|
getValidDataItems: null,
|
|
118
121
|
getValidTimeRanges: null,
|
|
119
122
|
dataItems: [],
|
|
@@ -143,6 +146,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
|
|
|
143
146
|
isSummaryDashboard = _ref.isSummaryDashboard,
|
|
144
147
|
onChange = _ref.onChange,
|
|
145
148
|
i18n = _ref.i18n,
|
|
149
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
146
150
|
dataItems = _ref.dataItems,
|
|
147
151
|
getValidDataItems = _ref.getValidDataItems,
|
|
148
152
|
getValidTimeRanges = _ref.getValidTimeRanges,
|
|
@@ -177,6 +181,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
|
|
|
177
181
|
,
|
|
178
182
|
onChange: onChange,
|
|
179
183
|
i18n: mergedI18n,
|
|
184
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
180
185
|
getValidTimeRanges: getValidTimeRanges,
|
|
181
186
|
currentBreakpoint: currentBreakpoint,
|
|
182
187
|
selectedDataItems: selectedDataItems,
|
|
@@ -223,6 +228,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
|
|
|
223
228
|
getValidDataItems: getValidDataItems,
|
|
224
229
|
availableDimensions: availableDimensions,
|
|
225
230
|
i18n: mergedI18n,
|
|
231
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
226
232
|
dataSeriesItemLinks: dataSeriesItemLinks,
|
|
227
233
|
translateWithId: handleTranslation,
|
|
228
234
|
actions: actions
|
|
@@ -461,6 +467,17 @@ CardEditFormContent.__docgenInfo = {
|
|
|
461
467
|
},
|
|
462
468
|
"required": false
|
|
463
469
|
},
|
|
470
|
+
"shouldUseTranslatedLabels": {
|
|
471
|
+
"defaultValue": {
|
|
472
|
+
"value": "false",
|
|
473
|
+
"computed": false
|
|
474
|
+
},
|
|
475
|
+
"description": "whether to use translated labels in cards",
|
|
476
|
+
"type": {
|
|
477
|
+
"name": "bool"
|
|
478
|
+
},
|
|
479
|
+
"required": false
|
|
480
|
+
},
|
|
464
481
|
"getValidDataItems": {
|
|
465
482
|
"defaultValue": {
|
|
466
483
|
"value": "null",
|
|
@@ -25,7 +25,7 @@ import { settings } from '../../../../constants/Settings.js';
|
|
|
25
25
|
import { DataItemsPropTypes, DashboardEditorActionsPropTypes, defaultDashboardEditorActionsProps, handleDefaultDataItemEdit } from '../../../DashboardEditor/editorUtils.js';
|
|
26
26
|
import ColorDropdown from '../../../ColorDropdown/ColorDropdown.js';
|
|
27
27
|
import { CARD_TYPES } from '../../../../constants/LayoutConstants.js';
|
|
28
|
-
import { isTimeBasedCard } from '../../../../utils/cardUtilityFunctions.js';
|
|
28
|
+
import { isTimeBasedCard, getTranslatedLabel } from '../../../../utils/cardUtilityFunctions.js';
|
|
29
29
|
import ThresholdsFormItem from './ThresholdsFormItem.js';
|
|
30
30
|
import ComposedModal from '../../../ComposedModal/ComposedModal.js';
|
|
31
31
|
import { WarningAlt } from '@carbon/icons-react';
|
|
@@ -127,6 +127,8 @@ var propTypes = {
|
|
|
127
127
|
primaryButtonLabelText: PropTypes.string,
|
|
128
128
|
secondaryButtonLabelText: PropTypes.string
|
|
129
129
|
}),
|
|
130
|
+
/** whether to use translated labels in cards */
|
|
131
|
+
shouldUseTranslatedLabels: PropTypes.bool,
|
|
130
132
|
actions: DashboardEditorActionsPropTypes,
|
|
131
133
|
/**
|
|
132
134
|
* Used to override the default behaviour of handleDataItemEdit. if we dont pass any function then it uses handleDefaultDataItemEdit function by default
|
|
@@ -180,6 +182,7 @@ var defaultProps = {
|
|
|
180
182
|
secondaryButtonLabelText: 'Cancel',
|
|
181
183
|
decimalPlacesLabel: 'Decimal places'
|
|
182
184
|
},
|
|
185
|
+
shouldUseTranslatedLabels: false,
|
|
183
186
|
editDataSeries: [],
|
|
184
187
|
showEditor: false,
|
|
185
188
|
setShowEditor: null,
|
|
@@ -250,6 +253,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
|
|
|
250
253
|
availableDimensions = _ref.availableDimensions,
|
|
251
254
|
onChange = _ref.onChange,
|
|
252
255
|
i18n = _ref.i18n,
|
|
256
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
253
257
|
isLarge = _ref.isLarge,
|
|
254
258
|
_ref$actions$dataSeri = _ref.actions.dataSeriesFormActions,
|
|
255
259
|
hasAggregationsDropDown = _ref$actions$dataSeri.hasAggregationsDropDown,
|
|
@@ -406,7 +410,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
|
|
|
406
410
|
label: evt.target.value
|
|
407
411
|
}));
|
|
408
412
|
},
|
|
409
|
-
value: editDataItem.label,
|
|
413
|
+
value: getTranslatedLabel(editDataItem.label, shouldUseTranslatedLabels, i18n),
|
|
410
414
|
helperText: mergedI18n.dataItemEditorDataItemHelperText(mergedI18n.dataItemSource, editDataItem.dataItemId)
|
|
411
415
|
})), hasColorDropdown &&
|
|
412
416
|
/*#__PURE__*/
|
|
@@ -453,7 +457,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
|
|
|
453
457
|
unit: evt.target.value
|
|
454
458
|
}));
|
|
455
459
|
},
|
|
456
|
-
value: editDataItem.unit
|
|
460
|
+
value: getTranslatedLabel(editDataItem.unit, shouldUseTranslatedLabels, i18n)
|
|
457
461
|
})), /*#__PURE__*/React__default.createElement("div", {
|
|
458
462
|
className: "".concat(baseClassName, "--input-group--item")
|
|
459
463
|
}, hasDecimalPlacesDropdown && /*#__PURE__*/React__default.createElement(Dropdown, {
|
|
@@ -551,7 +555,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
|
|
|
551
555
|
},
|
|
552
556
|
columnType: editDataItem.columnType || editDataItem.type
|
|
553
557
|
}));
|
|
554
|
-
}, [availableDimensions, availableDimensionsItems, availableGrains, baseClassName, cardConfig, editDataItem, handleTranslation, hasAggregationsDropDown, hasColorDropdown, hasDataFilterDropdown, hasDecimalPlacesDropdown, hasGrainsDropDown, hasThresholds, hasTooltip, hasUnit, id, initialAggregation, initialGrain, isSummaryDashboard, isTimeBasedCard$1, mergedI18n, selectedDimensionFilter, setEditDataItem, type]);
|
|
558
|
+
}, [availableDimensions, availableDimensionsItems, availableGrains, baseClassName, cardConfig, editDataItem, handleTranslation, hasAggregationsDropDown, hasColorDropdown, hasDataFilterDropdown, hasDecimalPlacesDropdown, hasGrainsDropDown, hasThresholds, hasTooltip, hasUnit, i18n, id, initialAggregation, initialGrain, isSummaryDashboard, isTimeBasedCard$1, mergedI18n, selectedDimensionFilter, setEditDataItem, shouldUseTranslatedLabels, type]);
|
|
555
559
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, showEditor && /*#__PURE__*/React__default.createElement("div", {
|
|
556
560
|
className: "".concat(baseClassName, "--modal-wrapper")
|
|
557
561
|
}, /*#__PURE__*/React__default.createElement(ComposedModal, {
|
|
@@ -781,6 +785,17 @@ DataSeriesFormItemModal.__docgenInfo = {
|
|
|
781
785
|
},
|
|
782
786
|
"required": false
|
|
783
787
|
},
|
|
788
|
+
"shouldUseTranslatedLabels": {
|
|
789
|
+
"defaultValue": {
|
|
790
|
+
"value": "false",
|
|
791
|
+
"computed": false
|
|
792
|
+
},
|
|
793
|
+
"description": "whether to use translated labels in cards",
|
|
794
|
+
"type": {
|
|
795
|
+
"name": "bool"
|
|
796
|
+
},
|
|
797
|
+
"required": false
|
|
798
|
+
},
|
|
784
799
|
"editDataSeries": {
|
|
785
800
|
"defaultValue": {
|
|
786
801
|
"value": "[]",
|
|
@@ -30,6 +30,7 @@ import DataSeriesFormItemModal from '../DataSeriesFormItemModal.js';
|
|
|
30
30
|
import { BAR_CHART_TYPES, CARD_TYPES } from '../../../../../constants/LayoutConstants.js';
|
|
31
31
|
import ContentFormItemTitle from '../ContentFormItemTitle.js';
|
|
32
32
|
import HierarchyDataFormItems, { isHierarchyDataItem } from '../HierarchyDataFormItems/HierarchyDataFormItems.js';
|
|
33
|
+
import { getTranslatedLabel } from '../../../../../utils/cardUtilityFunctions.js';
|
|
33
34
|
import BarChartDataSeriesContent from './BarChartDataSeriesContent.js';
|
|
34
35
|
import { Edit, MisuseOutline } from '@carbon/icons-react';
|
|
35
36
|
|
|
@@ -117,6 +118,8 @@ var propTypes = {
|
|
|
117
118
|
incrementNumberText: PropTypes.string,
|
|
118
119
|
decrementNumberText: PropTypes.string
|
|
119
120
|
}),
|
|
121
|
+
/** whether to use translated labels in cards */
|
|
122
|
+
shouldUseTranslatedLabels: PropTypes.bool,
|
|
120
123
|
translateWithId: PropTypes.func.isRequired,
|
|
121
124
|
actions: DashboardEditorActionsPropTypes
|
|
122
125
|
};
|
|
@@ -150,6 +153,7 @@ var defaultProps = {
|
|
|
150
153
|
incrementNumberText: 'Increment number',
|
|
151
154
|
decrementNumberText: 'Decrement number'
|
|
152
155
|
},
|
|
156
|
+
shouldUseTranslatedLabels: false,
|
|
153
157
|
getValidDataItems: null,
|
|
154
158
|
dataItems: [],
|
|
155
159
|
selectedDataItems: [],
|
|
@@ -237,6 +241,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
|
|
|
237
241
|
selectedTimeRange = _ref2.selectedTimeRange,
|
|
238
242
|
availableDimensions = _ref2.availableDimensions,
|
|
239
243
|
i18n = _ref2.i18n,
|
|
244
|
+
shouldUseTranslatedLabels = _ref2.shouldUseTranslatedLabels,
|
|
240
245
|
dataSeriesItemLinks = _ref2.dataSeriesItemLinks,
|
|
241
246
|
translateWithId = _ref2.translateWithId,
|
|
242
247
|
actions = _ref2.actions;
|
|
@@ -382,7 +387,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
|
|
|
382
387
|
return {
|
|
383
388
|
id: dataItem.dataSourceId,
|
|
384
389
|
content: {
|
|
385
|
-
value: dataItem.label || dataItem.dataItemId,
|
|
390
|
+
value: getTranslatedLabel(dataItem.label || dataItem.dataItemId, shouldUseTranslatedLabels, i18n),
|
|
386
391
|
icon: cardConfig.type === CARD_TYPES.TIMESERIES || cardConfig.type === CARD_TYPES.BAR ? /*#__PURE__*/React__default.createElement("div", {
|
|
387
392
|
className: "".concat(baseClassName, "--data-item-list--item-color-icon"),
|
|
388
393
|
style: {
|
|
@@ -419,7 +424,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
|
|
|
419
424
|
}
|
|
420
425
|
};
|
|
421
426
|
})) || [];
|
|
422
|
-
}, [cardConfig.type, handleEditButton, handleRemoveButton, mergedI18n.edit, mergedI18n.remove]);
|
|
427
|
+
}, [cardConfig.type, handleEditButton, handleRemoveButton, i18n, mergedI18n.edit, mergedI18n.remove, shouldUseTranslatedLabels]);
|
|
423
428
|
var dataItemListItems = useMemo(function () {
|
|
424
429
|
return generateListItems(dataSection);
|
|
425
430
|
}, [dataSection, generateListItems]);
|
|
@@ -440,6 +445,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
|
|
|
440
445
|
dataSection: dataSection,
|
|
441
446
|
onChange: _onChange,
|
|
442
447
|
i18n: mergedI18n,
|
|
448
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
443
449
|
actions: actions,
|
|
444
450
|
options: {
|
|
445
451
|
hasColorDropdown: type === CARD_TYPES.TIMESERIES || type === CARD_TYPES.BAR,
|
|
@@ -761,6 +767,17 @@ DataSeriesFormItem.__docgenInfo = {
|
|
|
761
767
|
},
|
|
762
768
|
"required": false
|
|
763
769
|
},
|
|
770
|
+
"shouldUseTranslatedLabels": {
|
|
771
|
+
"defaultValue": {
|
|
772
|
+
"value": "false",
|
|
773
|
+
"computed": false
|
|
774
|
+
},
|
|
775
|
+
"description": "whether to use translated labels in cards",
|
|
776
|
+
"type": {
|
|
777
|
+
"name": "bool"
|
|
778
|
+
},
|
|
779
|
+
"required": false
|
|
780
|
+
},
|
|
764
781
|
"getValidDataItems": {
|
|
765
782
|
"defaultValue": {
|
|
766
783
|
"value": "null",
|
|
@@ -17,6 +17,7 @@ import { TextInput, TextArea, Dropdown } from '@carbon/react';
|
|
|
17
17
|
import { ALLOWED_CARD_SIZES_PER_TYPE, CARD_SIZES, CARD_DIMENSIONS } from '../../../constants/LayoutConstants.js';
|
|
18
18
|
import { settings } from '../../../constants/Settings.js';
|
|
19
19
|
import { timeRangeToJSON } from '../../DashboardEditor/editorUtils.js';
|
|
20
|
+
import { getTranslatedLabel } from '../../../utils/cardUtilityFunctions.js';
|
|
20
21
|
|
|
21
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
23
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -75,6 +76,8 @@ var propTypes = {
|
|
|
75
76
|
thisQuarterLabel: PropTypes.string,
|
|
76
77
|
thisYearLabel: PropTypes.string
|
|
77
78
|
}),
|
|
79
|
+
/** whether to use translated labels in cards */
|
|
80
|
+
shouldUseTranslatedLabels: PropTypes.bool,
|
|
78
81
|
/** if provided, returns an array of strings which are the timeRanges to be allowed
|
|
79
82
|
* on each card
|
|
80
83
|
* getValidTimeRanges(card, selectedDataItems)
|
|
@@ -108,6 +111,7 @@ var defaultProps = {
|
|
|
108
111
|
thisQuarterLabel: 'This quarter',
|
|
109
112
|
thisYearLabel: 'This year'
|
|
110
113
|
},
|
|
114
|
+
shouldUseTranslatedLabels: false,
|
|
111
115
|
selectedDataItems: [],
|
|
112
116
|
getValidTimeRanges: null,
|
|
113
117
|
currentBreakpoint: 'xl',
|
|
@@ -131,6 +135,7 @@ var CommonCardEditFormFields = function CommonCardEditFormFields(_ref) {
|
|
|
131
135
|
var cardConfig = _ref.cardConfig,
|
|
132
136
|
_onChange = _ref.onChange,
|
|
133
137
|
i18n = _ref.i18n,
|
|
138
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
134
139
|
getValidTimeRanges = _ref.getValidTimeRanges,
|
|
135
140
|
currentBreakpoint = _ref.currentBreakpoint,
|
|
136
141
|
selectedDataItems = _ref.selectedDataItems,
|
|
@@ -161,7 +166,7 @@ var CommonCardEditFormFields = function CommonCardEditFormFields(_ref) {
|
|
|
161
166
|
title: evt.target.value
|
|
162
167
|
}));
|
|
163
168
|
},
|
|
164
|
-
value: title
|
|
169
|
+
value: getTranslatedLabel(title, shouldUseTranslatedLabels, mergedI18n)
|
|
165
170
|
})), /*#__PURE__*/React__default.createElement("div", {
|
|
166
171
|
className: "".concat(baseClassName, "--input")
|
|
167
172
|
}, /*#__PURE__*/React__default.createElement(TextArea, {
|
|
@@ -173,7 +178,7 @@ var CommonCardEditFormFields = function CommonCardEditFormFields(_ref) {
|
|
|
173
178
|
description: evt.target.value
|
|
174
179
|
}));
|
|
175
180
|
},
|
|
176
|
-
value: description
|
|
181
|
+
value: getTranslatedLabel(description, shouldUseTranslatedLabels, mergedI18n)
|
|
177
182
|
})), /*#__PURE__*/React__default.createElement("div", {
|
|
178
183
|
className: "".concat(baseClassName, "--input")
|
|
179
184
|
}, /*#__PURE__*/React__default.createElement(Dropdown, {
|
|
@@ -454,6 +459,17 @@ CommonCardEditFormFields.__docgenInfo = {
|
|
|
454
459
|
},
|
|
455
460
|
"required": false
|
|
456
461
|
},
|
|
462
|
+
"shouldUseTranslatedLabels": {
|
|
463
|
+
"defaultValue": {
|
|
464
|
+
"value": "false",
|
|
465
|
+
"computed": false
|
|
466
|
+
},
|
|
467
|
+
"description": "whether to use translated labels in cards",
|
|
468
|
+
"type": {
|
|
469
|
+
"name": "bool"
|
|
470
|
+
},
|
|
471
|
+
"required": false
|
|
472
|
+
},
|
|
457
473
|
"selectedDataItems": {
|
|
458
474
|
"defaultValue": {
|
|
459
475
|
"value": "[]",
|
|
@@ -136,6 +136,8 @@ var propTypes = {
|
|
|
136
136
|
searchPlaceHolderText: PropTypes.string,
|
|
137
137
|
editDataItems: PropTypes.string
|
|
138
138
|
}),
|
|
139
|
+
/** whether to use translated labels in cards */
|
|
140
|
+
shouldUseTranslatedLabels: PropTypes.bool,
|
|
139
141
|
currentBreakpoint: PropTypes.string,
|
|
140
142
|
isSummaryDashboard: PropTypes.bool,
|
|
141
143
|
/** Id that can be used for testing */
|
|
@@ -169,6 +171,7 @@ var defaultProps = {
|
|
|
169
171
|
modalHelpText: 'The JSON definition for this card is provided below. You can modify this data directly to update the card configuration.',
|
|
170
172
|
modalIconDescription: 'Close'
|
|
171
173
|
},
|
|
174
|
+
shouldUseTranslatedLabels: false,
|
|
172
175
|
getValidDimensions: null,
|
|
173
176
|
getValidDataItems: null,
|
|
174
177
|
getValidTimeRanges: null,
|
|
@@ -314,6 +317,7 @@ var CardEditor = function CardEditor(_ref) {
|
|
|
314
317
|
onRenderCardEditForm = _ref.onRenderCardEditForm,
|
|
315
318
|
icons = _ref.icons,
|
|
316
319
|
i18n = _ref.i18n,
|
|
320
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
317
321
|
currentBreakpoint = _ref.currentBreakpoint,
|
|
318
322
|
testId = _ref.testId,
|
|
319
323
|
dataSeriesItemLinks = _ref.dataSeriesItemLinks,
|
|
@@ -379,6 +383,7 @@ var CardEditor = function CardEditor(_ref) {
|
|
|
379
383
|
getValidTimeRanges: getValidTimeRanges,
|
|
380
384
|
availableDimensions: availableDimensions,
|
|
381
385
|
i18n: mergedI18n,
|
|
386
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
382
387
|
currentBreakpoint: currentBreakpoint,
|
|
383
388
|
dataSeriesItemLinks: dataSeriesItemLinks,
|
|
384
389
|
onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
|
|
@@ -544,6 +549,17 @@ CardEditor.__docgenInfo = {
|
|
|
544
549
|
},
|
|
545
550
|
"required": false
|
|
546
551
|
},
|
|
552
|
+
"shouldUseTranslatedLabels": {
|
|
553
|
+
"defaultValue": {
|
|
554
|
+
"value": "false",
|
|
555
|
+
"computed": false
|
|
556
|
+
},
|
|
557
|
+
"description": "whether to use translated labels in cards",
|
|
558
|
+
"type": {
|
|
559
|
+
"name": "bool"
|
|
560
|
+
},
|
|
561
|
+
"required": false
|
|
562
|
+
},
|
|
547
563
|
"getValidDimensions": {
|
|
548
564
|
"defaultValue": {
|
|
549
565
|
"value": "null",
|
|
@@ -25,6 +25,7 @@ import { CARD_TYPES, DASHBOARD_EDITOR_CARD_TYPES } from '../../constants/LayoutC
|
|
|
25
25
|
import DashboardGrid from '../Dashboard/DashboardGrid.js';
|
|
26
26
|
import CardEditor from '../CardEditor/CardEditor.js';
|
|
27
27
|
import ImageGalleryModal, { ImagePropTypes } from '../ImageGalleryModal/ImageGalleryModal.js';
|
|
28
|
+
import { getTranslatedLabel } from '../../utils/cardUtilityFunctions.js';
|
|
28
29
|
import DashboardEditorHeader from './DashboardEditorHeader/DashboardEditorHeader.js';
|
|
29
30
|
import DashboardEditorCardRenderer from './DashboardEditorCardRenderer.js';
|
|
30
31
|
import { DataItemsPropTypes, DashboardEditorActionsPropTypes, getDefaultCard, getDuplicateCard, renderBreakpointInfo, renderDefaultIconByName, defaultDashboardEditorActionsProps } from './editorUtils.js';
|
|
@@ -291,6 +292,8 @@ var propTypes = {
|
|
|
291
292
|
abbreviateNumbersTooltip: PropTypes.string,
|
|
292
293
|
editDataItems: PropTypes.string
|
|
293
294
|
}),
|
|
295
|
+
/** whether to use translated labels in cards */
|
|
296
|
+
shouldUseTranslatedLabels: PropTypes.bool,
|
|
294
297
|
/** locale data */
|
|
295
298
|
locale: PropTypes.string,
|
|
296
299
|
/** optional link href's for each card type that will appear in a tooltip */
|
|
@@ -381,6 +384,7 @@ var defaultProps = {
|
|
|
381
384
|
saveTitleButton: 'Save title',
|
|
382
385
|
editDataItems: 'Edit data items'
|
|
383
386
|
},
|
|
387
|
+
shouldUseTranslatedLabels: false,
|
|
384
388
|
locale: 'en',
|
|
385
389
|
dataSeriesItemLinks: null,
|
|
386
390
|
onFetchDynamicDemoHotspots: function onFetchDynamicDemoHotspots() {
|
|
@@ -450,6 +454,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
|
|
|
450
454
|
isSummaryDashboard = _ref.isSummaryDashboard,
|
|
451
455
|
isLoading = _ref.isLoading,
|
|
452
456
|
i18n = _ref.i18n,
|
|
457
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
453
458
|
locale = _ref.locale,
|
|
454
459
|
dataSeriesItemLinks = _ref.dataSeriesItemLinks,
|
|
455
460
|
isTitleEditable = _ref.isTitleEditable,
|
|
@@ -706,7 +711,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
|
|
|
706
711
|
className: classnames("".concat(baseClassName, "--content"), _defineProperty({}, "".concat(baseClassName, "__overflow"), selectedBreakpointIndex !== LAYOUTS.FIT_TO_SCREEN.index)),
|
|
707
712
|
ref: scrollContainerRef
|
|
708
713
|
}, renderHeader ? renderHeader() : /*#__PURE__*/React__default.createElement(DashboardEditorHeader, {
|
|
709
|
-
title: (dashboardJson === null || dashboardJson === void 0 ? void 0 : dashboardJson.title) || title,
|
|
714
|
+
title: getTranslatedLabel(dashboardJson === null || dashboardJson === void 0 ? void 0 : dashboardJson.title, shouldUseTranslatedLabels, i18n) || title,
|
|
710
715
|
breadcrumbs: headerBreadcrumbs,
|
|
711
716
|
onImport: onImport,
|
|
712
717
|
onExport: function onExport() {
|
|
@@ -790,6 +795,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
|
|
|
790
795
|
key: cardConfig.id,
|
|
791
796
|
isResizable: isCardResizable,
|
|
792
797
|
i18n: mergedI18n,
|
|
798
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
793
799
|
isSelected: isSelected,
|
|
794
800
|
availableDimensions: availableDimensions,
|
|
795
801
|
onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
|
|
@@ -834,6 +840,7 @@ var DashboardEditor = function DashboardEditor(_ref) {
|
|
|
834
840
|
getValidDimensions: getValidDimensions,
|
|
835
841
|
availableDimensions: availableDimensions,
|
|
836
842
|
i18n: mergedI18n,
|
|
843
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
837
844
|
currentBreakpoint: currentBreakpoint,
|
|
838
845
|
dataSeriesItemLinks: dataSeriesItemLinks,
|
|
839
846
|
onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
|
|
@@ -1756,6 +1763,17 @@ DashboardEditor.__docgenInfo = {
|
|
|
1756
1763
|
},
|
|
1757
1764
|
"required": false
|
|
1758
1765
|
},
|
|
1766
|
+
"shouldUseTranslatedLabels": {
|
|
1767
|
+
"defaultValue": {
|
|
1768
|
+
"value": "false",
|
|
1769
|
+
"computed": false
|
|
1770
|
+
},
|
|
1771
|
+
"description": "whether to use translated labels in cards",
|
|
1772
|
+
"type": {
|
|
1773
|
+
"name": "bool"
|
|
1774
|
+
},
|
|
1775
|
+
"required": false
|
|
1776
|
+
},
|
|
1759
1777
|
"locale": {
|
|
1760
1778
|
"defaultValue": {
|
|
1761
1779
|
"value": "'en'",
|
|
@@ -26,7 +26,7 @@ import { handleKeyDown, handleOnClick } from './editorUtils.js';
|
|
|
26
26
|
import DashboardEditorDefaultCardRenderer from './DashboardEditorDefaultCardRenderer.js';
|
|
27
27
|
|
|
28
28
|
var _excluded = ["style", "children"],
|
|
29
|
-
_excluded2 = ["isSelected", "availableDimensions", "i18n", "onRemove", "onDuplicate", "onCardChange", "setSelectedCardId", "renderIconByName", "onShowImageGallery", "onValidateUploadedImage", "baseClassName", "renderCardPreview", "style"];
|
|
29
|
+
_excluded2 = ["isSelected", "availableDimensions", "i18n", "onRemove", "onDuplicate", "onCardChange", "setSelectedCardId", "renderIconByName", "onShowImageGallery", "onValidateUploadedImage", "baseClassName", "renderCardPreview", "style", "shouldUseTranslatedLabels"];
|
|
30
30
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
31
31
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
32
32
|
|
|
@@ -98,6 +98,7 @@ var DashboardEditorCardRenderer = /*#__PURE__*/React__default.memo(function (_re
|
|
|
98
98
|
baseClassName = _ref2.baseClassName,
|
|
99
99
|
renderCardPreview = _ref2.renderCardPreview,
|
|
100
100
|
style = _ref2.style,
|
|
101
|
+
shouldUseTranslatedLabels = _ref2.shouldUseTranslatedLabels,
|
|
101
102
|
cardConfig = _objectWithoutProperties(_ref2, _excluded2);
|
|
102
103
|
// We have to keep track of our dynamic hotspots here
|
|
103
104
|
var _useState5 = useState([]),
|
|
@@ -131,6 +132,7 @@ var DashboardEditorCardRenderer = /*#__PURE__*/React__default.memo(function (_re
|
|
|
131
132
|
key: cardConfig.id,
|
|
132
133
|
tooltip: cardConfig.description,
|
|
133
134
|
i18n: i18n,
|
|
135
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
134
136
|
availableActions: availableActions,
|
|
135
137
|
onCardAction: handleOnCardAction,
|
|
136
138
|
renderIconByName: renderIconByName,
|
|
@@ -143,7 +145,7 @@ var DashboardEditorCardRenderer = /*#__PURE__*/React__default.memo(function (_re
|
|
|
143
145
|
onBrowseClick: cardConfig.type === CARD_TYPES.IMAGE && isNil((_cardConfig$content = cardConfig.content) === null || _cardConfig$content === void 0 ? void 0 : _cardConfig$content.src) ? onShowImageGallery : undefined,
|
|
144
146
|
validateUploadedImage: cardConfig.type === CARD_TYPES.IMAGE ? onValidateUploadedImage : undefined
|
|
145
147
|
});
|
|
146
|
-
}, [baseClassName, cardConfig, handleOnCardAction, handleOnCardKeyDown, handleOnCardMouseDown, i18n, isSelected, onShowImageGallery, onValidateUploadedImage, renderIconByName, style]);
|
|
148
|
+
}, [baseClassName, cardConfig, handleOnCardAction, handleOnCardKeyDown, handleOnCardMouseDown, i18n, isSelected, onShowImageGallery, onValidateUploadedImage, renderIconByName, shouldUseTranslatedLabels, style]);
|
|
147
149
|
useEffect(function () {
|
|
148
150
|
var _cardProps$values;
|
|
149
151
|
var originalDynamicHotspot = (_cardProps$values = cardProps.values) === null || _cardProps$values === void 0 || (_cardProps$values = _cardProps$values.hotspots) === null || _cardProps$values === void 0 ? void 0 : _cardProps$values.find(function (hotspot) {
|
|
@@ -11,6 +11,7 @@ import { CARD_LAYOUTS } from '../../constants/LayoutConstants.js';
|
|
|
11
11
|
import CardIcon from '../ImageCard/CardIcon.js';
|
|
12
12
|
import useMatchingThreshold from '../../hooks/useMatchingThreshold.js';
|
|
13
13
|
import { Tooltip } from '../Tooltip/index.js';
|
|
14
|
+
import { getTranslatedLabel } from '../../utils/cardUtilityFunctions.js';
|
|
14
15
|
import ValueRenderer from './ValueRenderer.js';
|
|
15
16
|
import UnitRenderer from './UnitRenderer.js';
|
|
16
17
|
import { BASE_CLASS_NAME } from './valueCardUtils.js';
|
|
@@ -39,6 +40,9 @@ var propTypes = {
|
|
|
39
40
|
isEditable: PropTypes.bool,
|
|
40
41
|
layout: PropTypes.oneOf(Object.values(CARD_LAYOUTS)),
|
|
41
42
|
locale: PropTypes.string,
|
|
43
|
+
/** whether to use translated labels in cards */
|
|
44
|
+
shouldUseTranslatedLabels: PropTypes.bool,
|
|
45
|
+
i18n: PropTypes.objectOf(PropTypes.any),
|
|
42
46
|
renderIconByName: PropTypes.func,
|
|
43
47
|
/** Optional trend information */
|
|
44
48
|
secondaryValue: PropTypes.shape({
|
|
@@ -67,6 +71,8 @@ var defaultProps = {
|
|
|
67
71
|
customFormatter: null,
|
|
68
72
|
formatter: null,
|
|
69
73
|
isEditable: false,
|
|
74
|
+
shouldUseTranslatedLabels: false,
|
|
75
|
+
i18n: {},
|
|
70
76
|
testId: 'attribute',
|
|
71
77
|
onValueClick: null
|
|
72
78
|
};
|
|
@@ -93,6 +99,8 @@ var Attribute = function Attribute(_ref) {
|
|
|
93
99
|
isEditable = _ref.isEditable,
|
|
94
100
|
layout = _ref.layout,
|
|
95
101
|
locale = _ref.locale,
|
|
102
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
103
|
+
i18n = _ref.i18n,
|
|
96
104
|
renderIconByName = _ref.renderIconByName,
|
|
97
105
|
secondaryValue = _ref.secondaryValue,
|
|
98
106
|
value = _ref.value,
|
|
@@ -112,6 +120,10 @@ var Attribute = function Attribute(_ref) {
|
|
|
112
120
|
// need to reduce the width size to fit multiple attributes when card layout is horizontal
|
|
113
121
|
var attributeWidthPercentage = layout === CARD_LAYOUTS.HORIZONTAL ? 100 / attributeCount : 100;
|
|
114
122
|
|
|
123
|
+
// Get translated label if shouldUseTranslatedLabels is true
|
|
124
|
+
var displayLabel = getTranslatedLabel(label, shouldUseTranslatedLabels, i18n);
|
|
125
|
+
var displayUnitLabel = getTranslatedLabel(unit, shouldUseTranslatedLabels, i18n);
|
|
126
|
+
|
|
115
127
|
// Render threshold icon component
|
|
116
128
|
var renderThresholdIcon = function renderThresholdIcon() {
|
|
117
129
|
if (!(matchingThreshold !== null && matchingThreshold !== void 0 && matchingThreshold.icon)) return null;
|
|
@@ -137,10 +149,10 @@ var Attribute = function Attribute(_ref) {
|
|
|
137
149
|
}, thresholdsIconPosition === 'label' && renderThresholdIcon(), tooltip ? /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
138
150
|
direction: "right",
|
|
139
151
|
showIcon: false,
|
|
140
|
-
triggerText:
|
|
152
|
+
triggerText: displayLabel
|
|
141
153
|
}, /*#__PURE__*/React__default.createElement("p", null, tooltip)) : /*#__PURE__*/React__default.createElement("span", {
|
|
142
154
|
"data-testid": "".concat(testId, "-threshold-label")
|
|
143
|
-
},
|
|
155
|
+
}, displayLabel)), /*#__PURE__*/React__default.createElement("div", {
|
|
144
156
|
className: "".concat(BEM_BASE)
|
|
145
157
|
}, /*#__PURE__*/React__default.createElement(ValueRenderer, {
|
|
146
158
|
value: value,
|
|
@@ -160,7 +172,7 @@ var Attribute = function Attribute(_ref) {
|
|
|
160
172
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
161
173
|
className: "".concat(BEM_BASE, "-unit-with-icon")
|
|
162
174
|
}, thresholdsIconPosition === 'unit' && renderThresholdIcon(), /*#__PURE__*/React__default.createElement(UnitRenderer, {
|
|
163
|
-
unit: measurementUnitLabel ||
|
|
175
|
+
unit: measurementUnitLabel || displayUnitLabel,
|
|
164
176
|
testId: "".concat(testId, "-unit")
|
|
165
177
|
}))), !isNil(secondaryValue) ? /*#__PURE__*/React__default.createElement("div", {
|
|
166
178
|
"data-testid": "".concat(testId, "-secondary-value"),
|
|
@@ -331,6 +343,31 @@ Attribute.__docgenInfo = {
|
|
|
331
343
|
},
|
|
332
344
|
"required": false
|
|
333
345
|
},
|
|
346
|
+
"shouldUseTranslatedLabels": {
|
|
347
|
+
"defaultValue": {
|
|
348
|
+
"value": "false",
|
|
349
|
+
"computed": false
|
|
350
|
+
},
|
|
351
|
+
"description": "whether to use translated labels in cards",
|
|
352
|
+
"type": {
|
|
353
|
+
"name": "bool"
|
|
354
|
+
},
|
|
355
|
+
"required": false
|
|
356
|
+
},
|
|
357
|
+
"i18n": {
|
|
358
|
+
"defaultValue": {
|
|
359
|
+
"value": "{}",
|
|
360
|
+
"computed": false
|
|
361
|
+
},
|
|
362
|
+
"description": "",
|
|
363
|
+
"type": {
|
|
364
|
+
"name": "objectOf",
|
|
365
|
+
"value": {
|
|
366
|
+
"name": "any"
|
|
367
|
+
}
|
|
368
|
+
},
|
|
369
|
+
"required": false
|
|
370
|
+
},
|
|
334
371
|
"testId": {
|
|
335
372
|
"defaultValue": {
|
|
336
373
|
"value": "'attribute'",
|