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
|
@@ -20,7 +20,7 @@ import { getUpdatedCardSize, getResizeHandles, handleCardVariables } from '../..
|
|
|
20
20
|
import { determineLayout, BASE_CLASS_NAME, DEFAULT_FONT_SIZE } from './valueCardUtils.js';
|
|
21
21
|
import ValueContent from './ValueContent.js';
|
|
22
22
|
|
|
23
|
-
var _excluded = ["title", "content", "size", "values", "isEditable", "isResizable", "i18n", "dataState", "id", "locale", "customFormatter", "formatter", "children", "fontSize", "isNumberValueCompact", "testID", "testId", "onAttributeClick", "className"];
|
|
23
|
+
var _excluded = ["title", "content", "size", "values", "isEditable", "isResizable", "i18n", "dataState", "id", "locale", "customFormatter", "formatter", "children", "fontSize", "isNumberValueCompact", "testID", "testId", "onAttributeClick", "className", "shouldUseTranslatedLabels"];
|
|
24
24
|
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; }
|
|
25
25
|
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; }
|
|
26
26
|
|
|
@@ -50,6 +50,7 @@ var ValueCard = function ValueCard(_ref) {
|
|
|
50
50
|
testId = _ref.testId,
|
|
51
51
|
onAttributeClick = _ref.onAttributeClick,
|
|
52
52
|
className = _ref.className,
|
|
53
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
53
54
|
others = _objectWithoutProperties(_ref, _excluded);
|
|
54
55
|
var availableActions = _objectSpread({
|
|
55
56
|
expand: false
|
|
@@ -74,6 +75,7 @@ var ValueCard = function ValueCard(_ref) {
|
|
|
74
75
|
isResizable: isResizable,
|
|
75
76
|
resizeHandles: resizeHandles,
|
|
76
77
|
i18n: i18n,
|
|
78
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
77
79
|
locale: locale,
|
|
78
80
|
id: id,
|
|
79
81
|
className: classnames(className, _defineProperty(_defineProperty({}, "".concat(BASE_CLASS_NAME, "__horizontal"), layout === CARD_LAYOUTS.HORIZONTAL), "".concat(BASE_CLASS_NAME, "__vertical"), layout === CARD_LAYOUTS.VERTICAL))
|
|
@@ -97,7 +99,9 @@ var ValueCard = function ValueCard(_ref) {
|
|
|
97
99
|
values: values,
|
|
98
100
|
isEditable: isEditable,
|
|
99
101
|
fontSize: fontSize,
|
|
100
|
-
isNumberValueCompact: isNumberValueCompact
|
|
102
|
+
isNumberValueCompact: isNumberValueCompact,
|
|
103
|
+
i18n: i18n,
|
|
104
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels
|
|
101
105
|
}, others)), resizeHandles);
|
|
102
106
|
};
|
|
103
107
|
ValueCard.propTypes = _objectSpread(_objectSpread({}, CardPropTypes), ValueContentPropTypes);
|
|
@@ -114,7 +118,8 @@ ValueCard.defaultProps = {
|
|
|
114
118
|
isNumberValueCompact: false,
|
|
115
119
|
// TODO: fix this default in V3, so that cards are unique not inherited from the base Card
|
|
116
120
|
testId: 'Card',
|
|
117
|
-
onAttributeClick: null
|
|
121
|
+
onAttributeClick: null,
|
|
122
|
+
shouldUseTranslatedLabels: false
|
|
118
123
|
};
|
|
119
124
|
ValueCard.__docgenInfo = {
|
|
120
125
|
"description": "This components responsibilities include:\nRendering the attribute groups\nDetermining the layout\ndetermines the data to render",
|
|
@@ -197,6 +202,13 @@ ValueCard.__docgenInfo = {
|
|
|
197
202
|
"computed": false
|
|
198
203
|
},
|
|
199
204
|
"required": false
|
|
205
|
+
},
|
|
206
|
+
"shouldUseTranslatedLabels": {
|
|
207
|
+
"defaultValue": {
|
|
208
|
+
"value": "false",
|
|
209
|
+
"computed": false
|
|
210
|
+
},
|
|
211
|
+
"required": false
|
|
200
212
|
}
|
|
201
213
|
},
|
|
202
214
|
"composes": ["../../constants/CardPropTypes"]
|
|
@@ -20,7 +20,7 @@ import DataStateRenderer from '../Card/DataStateRenderer.js';
|
|
|
20
20
|
import { DEFAULT_FONT_SIZE, BASE_CLASS_NAME, determineValue } from './valueCardUtils.js';
|
|
21
21
|
import Attribute from './Attribute.js';
|
|
22
22
|
|
|
23
|
-
var _excluded = ["id", "title", "content", "values", "layout", "dataState", "locale", "isEditable", "customFormatter", "formatter", "fontSize", "isNumberValueCompact", "testId", "onAttributeClick", "size"];
|
|
23
|
+
var _excluded = ["id", "title", "content", "values", "layout", "dataState", "locale", "isEditable", "shouldUseTranslatedLabels", "customFormatter", "formatter", "fontSize", "isNumberValueCompact", "testId", "onAttributeClick", "size"];
|
|
24
24
|
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; }
|
|
25
25
|
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; }
|
|
26
26
|
var propTypes = _objectSpread({
|
|
@@ -28,7 +28,9 @@ var propTypes = _objectSpread({
|
|
|
28
28
|
title: PropTypes.string,
|
|
29
29
|
layout: PropTypes.oneOf(['HORIZONTAL', 'VERTICAL']),
|
|
30
30
|
locale: PropTypes.string,
|
|
31
|
-
isEditable: PropTypes.bool
|
|
31
|
+
isEditable: PropTypes.bool,
|
|
32
|
+
/** whether to use translated labels in cards */
|
|
33
|
+
shouldUseTranslatedLabels: PropTypes.bool
|
|
32
34
|
}, ValueContentPropTypes);
|
|
33
35
|
var defaultProps = {
|
|
34
36
|
id: 'valueContent-id',
|
|
@@ -36,6 +38,7 @@ var defaultProps = {
|
|
|
36
38
|
layout: 'VERTICAL',
|
|
37
39
|
locale: 'en',
|
|
38
40
|
isEditable: false,
|
|
41
|
+
shouldUseTranslatedLabels: false,
|
|
39
42
|
dataState: null,
|
|
40
43
|
values: null,
|
|
41
44
|
fontSize: DEFAULT_FONT_SIZE,
|
|
@@ -55,6 +58,7 @@ var ValueContent = function ValueContent(_ref) {
|
|
|
55
58
|
dataState = _ref.dataState,
|
|
56
59
|
locale = _ref.locale,
|
|
57
60
|
isEditable = _ref.isEditable,
|
|
61
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
58
62
|
customFormatter = _ref.customFormatter,
|
|
59
63
|
formatter = _ref.formatter,
|
|
60
64
|
fontSize = _ref.fontSize,
|
|
@@ -75,6 +79,8 @@ var ValueContent = function ValueContent(_ref) {
|
|
|
75
79
|
locale: locale,
|
|
76
80
|
isEditable: isEditable,
|
|
77
81
|
title: title,
|
|
82
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
83
|
+
i18n: others.i18n,
|
|
78
84
|
renderIconByName: others.renderIconByName,
|
|
79
85
|
value: determineValue(attribute.dataSourceId, values, attribute.dataFilter),
|
|
80
86
|
secondaryValue: attribute.secondaryValue && _objectSpread(_objectSpread({}, attribute.secondaryValue), {}, {
|
|
@@ -165,6 +171,17 @@ ValueContent.__docgenInfo = {
|
|
|
165
171
|
},
|
|
166
172
|
"required": false
|
|
167
173
|
},
|
|
174
|
+
"shouldUseTranslatedLabels": {
|
|
175
|
+
"defaultValue": {
|
|
176
|
+
"value": "false",
|
|
177
|
+
"computed": false
|
|
178
|
+
},
|
|
179
|
+
"description": "whether to use translated labels in cards",
|
|
180
|
+
"type": {
|
|
181
|
+
"name": "bool"
|
|
182
|
+
},
|
|
183
|
+
"required": false
|
|
184
|
+
},
|
|
168
185
|
"dataState": {
|
|
169
186
|
"defaultValue": {
|
|
170
187
|
"value": "null",
|
|
@@ -172,6 +172,8 @@ var TableCardPropTypes = {
|
|
|
172
172
|
defaultFilterStringPlaceholdText: PropTypes.string,
|
|
173
173
|
downloadIconDescription: PropTypes.string
|
|
174
174
|
}),
|
|
175
|
+
/** whether to use translated labels in cards */
|
|
176
|
+
shouldUseTranslatedLabels: PropTypes.bool,
|
|
175
177
|
cardVariables: PropTypes.objectOf(PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.number, PropTypes.bool])),
|
|
176
178
|
/** default date format pattern that follows the dayjs formatting patterns */
|
|
177
179
|
defaultDateFormatPattern: PropTypes.string
|
|
@@ -4,6 +4,7 @@ import _typeof from '@babel/runtime/helpers/typeof';
|
|
|
4
4
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
5
5
|
import mapValues from '../node_modules/lodash-es/mapValues.js';
|
|
6
6
|
import isNil from '../node_modules/lodash-es/isNil.js';
|
|
7
|
+
import isEmpty from '../node_modules/lodash-es/isEmpty.js';
|
|
7
8
|
import 'core-js/modules/es.symbol.js';
|
|
8
9
|
import 'core-js/modules/es.array.concat.js';
|
|
9
10
|
import 'core-js/modules/es.array.filter.js';
|
|
@@ -573,4 +574,18 @@ var isTimeBasedCard = function isTimeBasedCard(card) {
|
|
|
573
574
|
})) || ((_card$content2 = card.content) === null || _card$content2 === void 0 ? void 0 : _card$content2.type) === BAR_CHART_TYPES.SIMPLE && ((_card$content3 = card.content) === null || _card$content3 === void 0 ? void 0 : _card$content3.timeDataSourceId) || ((_card$content4 = card.content) === null || _card$content4 === void 0 ? void 0 : _card$content4.type) === BAR_CHART_TYPES.STACKED && ((_card$content5 = card.content) === null || _card$content5 === void 0 ? void 0 : _card$content5.timeDataSourceId);
|
|
574
575
|
};
|
|
575
576
|
|
|
576
|
-
|
|
577
|
+
/**
|
|
578
|
+
* Get translated label or title from i18n object, fallback to original if not found
|
|
579
|
+
* @param {string} label - The label or title key to translate
|
|
580
|
+
* @param {boolean} shouldUseTranslatedLabels - Flag to determine if translation should be used
|
|
581
|
+
* @param {Object} i18n - The i18n object containing translations
|
|
582
|
+
* @returns {string} - The translated label or original label if translation not found
|
|
583
|
+
*/
|
|
584
|
+
var getTranslatedLabel = function getTranslatedLabel(label, shouldUseTranslatedLabels, i18n) {
|
|
585
|
+
if (!isEmpty(label) && shouldUseTranslatedLabels && i18n && i18n[label]) {
|
|
586
|
+
return i18n[label];
|
|
587
|
+
}
|
|
588
|
+
return label;
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
export { chartValueFormatter, compareGrains, determineCardRange, determinePrecision, fetchDataURL, findMatchingAlertRange, findMatchingThresholds, formatNumberWithPrecision, getCardVariables, getResizeHandles, getTranslatedLabel, getUpdatedCardSize, getVariables, handleCardVariables, handleTooltip, increaseSmallCardSize, isTimeBasedCard, replaceVariables, useCardResizing };
|
|
@@ -51,7 +51,7 @@ var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
|
51
51
|
var warning__default = /*#__PURE__*/_interopDefault(warning);
|
|
52
52
|
|
|
53
53
|
var _excluded = ["isSelected", "children", "dimensions", "id", "style", "className", "onScroll", "onMouseDown", "onMouseUp", "onTouchEnd", "onTouchStart", "onFocus", "onBlur", "tabIndex", "testID", "testId"],
|
|
54
|
-
_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"];
|
|
54
|
+
_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"];
|
|
55
55
|
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; }
|
|
56
56
|
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__default.default(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; }
|
|
57
57
|
var prefix = Settings.settings.prefix,
|
|
@@ -267,7 +267,8 @@ var defaultProps = {
|
|
|
267
267
|
overrides: undefined,
|
|
268
268
|
type: null,
|
|
269
269
|
data: null,
|
|
270
|
-
content: null
|
|
270
|
+
content: null,
|
|
271
|
+
shouldUseTranslatedLabels: false
|
|
271
272
|
};
|
|
272
273
|
|
|
273
274
|
/** Dumb component that renders the card basics */
|
|
@@ -275,7 +276,7 @@ var Card = function Card(props) {
|
|
|
275
276
|
var _overrides$errorMessa, _overrides$errorMessa2, _overrides$errorMessa3;
|
|
276
277
|
var size = props.size,
|
|
277
278
|
children = props.children,
|
|
278
|
-
|
|
279
|
+
titleProp = props.title,
|
|
279
280
|
subtitleProp = props.subtitle,
|
|
280
281
|
hasTitleWrap = props.hasTitleWrap;
|
|
281
282
|
props.layout;
|
|
@@ -289,7 +290,7 @@ var Card = function Card(props) {
|
|
|
289
290
|
error = props.error,
|
|
290
291
|
hideHeader = props.hideHeader,
|
|
291
292
|
id = props.id,
|
|
292
|
-
|
|
293
|
+
tooltipProp = props.tooltip,
|
|
293
294
|
titleTextTooltip = props.titleTextTooltip,
|
|
294
295
|
timeRange = props.timeRange,
|
|
295
296
|
timeRangeOptions = props.timeRangeOptions,
|
|
@@ -314,8 +315,13 @@ var Card = function Card(props) {
|
|
|
314
315
|
data = props.data,
|
|
315
316
|
content = props.content,
|
|
316
317
|
extraHeaderContent = props.extraHeaderContent,
|
|
318
|
+
shouldUseTranslatedLabels = props.shouldUseTranslatedLabels,
|
|
317
319
|
others = _objectWithoutProperties__default.default(props, _excluded2);
|
|
318
320
|
|
|
321
|
+
// Get translated title if shouldUseTranslatedLabels is true
|
|
322
|
+
var title = cardUtilityFunctions.getTranslatedLabel(titleProp, shouldUseTranslatedLabels, i18n);
|
|
323
|
+
var tooltip = cardUtilityFunctions.getTranslatedLabel(tooltipProp, shouldUseTranslatedLabels, i18n);
|
|
324
|
+
|
|
319
325
|
// TODO: remove once final version of range prop is supported
|
|
320
326
|
React.useEffect(function () {
|
|
321
327
|
if (typeof (availableActions === null || availableActions === void 0 ? void 0 : availableActions.range) === 'string') {
|
|
@@ -803,6 +809,13 @@ Card.__docgenInfo = {
|
|
|
803
809
|
"computed": false
|
|
804
810
|
},
|
|
805
811
|
"required": false
|
|
812
|
+
},
|
|
813
|
+
"shouldUseTranslatedLabels": {
|
|
814
|
+
"defaultValue": {
|
|
815
|
+
"value": "false",
|
|
816
|
+
"computed": false
|
|
817
|
+
},
|
|
818
|
+
"required": false
|
|
806
819
|
}
|
|
807
820
|
},
|
|
808
821
|
"composes": ["../../constants/CardPropTypes"]
|
|
@@ -59,6 +59,8 @@ var propTypes = {
|
|
|
59
59
|
modalHelpText: PropTypes__default.default.string,
|
|
60
60
|
modalIconDescription: PropTypes__default.default.string
|
|
61
61
|
}),
|
|
62
|
+
/** whether to use translated labels in cards */
|
|
63
|
+
shouldUseTranslatedLabels: PropTypes__default.default.bool,
|
|
62
64
|
/** if provided, returns an array of strings which are the dataItems to be allowed
|
|
63
65
|
* on each card
|
|
64
66
|
* getValidDataItems(card, selectedTimeRange)
|
|
@@ -120,6 +122,7 @@ var defaultProps = {
|
|
|
120
122
|
modalHelpText: 'The JSON definition for this card is provided below. You can modify this data directly to update the card configuration.',
|
|
121
123
|
modalIconDescription: 'Close'
|
|
122
124
|
},
|
|
125
|
+
shouldUseTranslatedLabels: false,
|
|
123
126
|
getValidDataItems: null,
|
|
124
127
|
getValidTimeRanges: null,
|
|
125
128
|
dataItems: [],
|
|
@@ -141,6 +144,7 @@ var CardEditForm = function CardEditForm(_ref) {
|
|
|
141
144
|
availableDimensions = _ref.availableDimensions,
|
|
142
145
|
dataSeriesItemLinks = _ref.dataSeriesItemLinks,
|
|
143
146
|
onFetchDynamicDemoHotspots = _ref.onFetchDynamicDemoHotspots,
|
|
147
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
144
148
|
actions = _ref.actions;
|
|
145
149
|
var mergedI18n = React.useMemo(function () {
|
|
146
150
|
return _objectSpread(_objectSpread({}, defaultProps.i18n), i18n);
|
|
@@ -157,6 +161,7 @@ var CardEditForm = function CardEditForm(_ref) {
|
|
|
157
161
|
onChange: onChange,
|
|
158
162
|
isSummaryDashboard: isSummaryDashboard,
|
|
159
163
|
i18n: mergedI18n,
|
|
164
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
160
165
|
dataItems: dataItems,
|
|
161
166
|
availableDimensions: availableDimensions,
|
|
162
167
|
getValidDataItems: getValidDataItems,
|
|
@@ -304,6 +309,17 @@ CardEditForm.__docgenInfo = {
|
|
|
304
309
|
},
|
|
305
310
|
"required": false
|
|
306
311
|
},
|
|
312
|
+
"shouldUseTranslatedLabels": {
|
|
313
|
+
"defaultValue": {
|
|
314
|
+
"value": "false",
|
|
315
|
+
"computed": false
|
|
316
|
+
},
|
|
317
|
+
"description": "whether to use translated labels in cards",
|
|
318
|
+
"type": {
|
|
319
|
+
"name": "bool"
|
|
320
|
+
},
|
|
321
|
+
"required": false
|
|
322
|
+
},
|
|
307
323
|
"getValidDataItems": {
|
|
308
324
|
"defaultValue": {
|
|
309
325
|
"value": "null",
|
|
@@ -89,6 +89,8 @@ var propTypes = {
|
|
|
89
89
|
thisQuarterLabel: PropTypes__default.default.string,
|
|
90
90
|
thisYearLabel: PropTypes__default.default.string
|
|
91
91
|
}),
|
|
92
|
+
/** whether to use translated labels in cards */
|
|
93
|
+
shouldUseTranslatedLabels: PropTypes__default.default.bool,
|
|
92
94
|
/** if provided, returns an array of strings which are the timeRanges to be allowed
|
|
93
95
|
* on each card
|
|
94
96
|
* getValidTimeRanges(card, selectedDataItems)
|
|
@@ -125,6 +127,7 @@ var propTypes = {
|
|
|
125
127
|
var defaultProps = {
|
|
126
128
|
cardConfig: {},
|
|
127
129
|
i18n: {},
|
|
130
|
+
shouldUseTranslatedLabels: false,
|
|
128
131
|
getValidDataItems: null,
|
|
129
132
|
getValidTimeRanges: null,
|
|
130
133
|
dataItems: [],
|
|
@@ -154,6 +157,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
|
|
|
154
157
|
isSummaryDashboard = _ref.isSummaryDashboard,
|
|
155
158
|
onChange = _ref.onChange,
|
|
156
159
|
i18n = _ref.i18n,
|
|
160
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
157
161
|
dataItems = _ref.dataItems,
|
|
158
162
|
getValidDataItems = _ref.getValidDataItems,
|
|
159
163
|
getValidTimeRanges = _ref.getValidTimeRanges,
|
|
@@ -188,6 +192,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
|
|
|
188
192
|
,
|
|
189
193
|
onChange: onChange,
|
|
190
194
|
i18n: mergedI18n,
|
|
195
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
191
196
|
getValidTimeRanges: getValidTimeRanges,
|
|
192
197
|
currentBreakpoint: currentBreakpoint,
|
|
193
198
|
selectedDataItems: selectedDataItems,
|
|
@@ -234,6 +239,7 @@ var CardEditFormContent = function CardEditFormContent(_ref) {
|
|
|
234
239
|
getValidDataItems: getValidDataItems,
|
|
235
240
|
availableDimensions: availableDimensions,
|
|
236
241
|
i18n: mergedI18n,
|
|
242
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
237
243
|
dataSeriesItemLinks: dataSeriesItemLinks,
|
|
238
244
|
translateWithId: handleTranslation,
|
|
239
245
|
actions: actions
|
|
@@ -472,6 +478,17 @@ CardEditFormContent.__docgenInfo = {
|
|
|
472
478
|
},
|
|
473
479
|
"required": false
|
|
474
480
|
},
|
|
481
|
+
"shouldUseTranslatedLabels": {
|
|
482
|
+
"defaultValue": {
|
|
483
|
+
"value": "false",
|
|
484
|
+
"computed": false
|
|
485
|
+
},
|
|
486
|
+
"description": "whether to use translated labels in cards",
|
|
487
|
+
"type": {
|
|
488
|
+
"name": "bool"
|
|
489
|
+
},
|
|
490
|
+
"required": false
|
|
491
|
+
},
|
|
475
492
|
"getValidDataItems": {
|
|
476
493
|
"defaultValue": {
|
|
477
494
|
"value": "null",
|
|
@@ -136,6 +136,8 @@ var propTypes = {
|
|
|
136
136
|
primaryButtonLabelText: PropTypes__default.default.string,
|
|
137
137
|
secondaryButtonLabelText: PropTypes__default.default.string
|
|
138
138
|
}),
|
|
139
|
+
/** whether to use translated labels in cards */
|
|
140
|
+
shouldUseTranslatedLabels: PropTypes__default.default.bool,
|
|
139
141
|
actions: editorUtils.DashboardEditorActionsPropTypes,
|
|
140
142
|
/**
|
|
141
143
|
* Used to override the default behaviour of handleDataItemEdit. if we dont pass any function then it uses handleDefaultDataItemEdit function by default
|
|
@@ -189,6 +191,7 @@ var defaultProps = {
|
|
|
189
191
|
secondaryButtonLabelText: 'Cancel',
|
|
190
192
|
decimalPlacesLabel: 'Decimal places'
|
|
191
193
|
},
|
|
194
|
+
shouldUseTranslatedLabels: false,
|
|
192
195
|
editDataSeries: [],
|
|
193
196
|
showEditor: false,
|
|
194
197
|
setShowEditor: null,
|
|
@@ -259,6 +262,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
|
|
|
259
262
|
availableDimensions = _ref.availableDimensions,
|
|
260
263
|
onChange = _ref.onChange,
|
|
261
264
|
i18n = _ref.i18n,
|
|
265
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
262
266
|
isLarge = _ref.isLarge,
|
|
263
267
|
_ref$actions$dataSeri = _ref.actions.dataSeriesFormActions,
|
|
264
268
|
hasAggregationsDropDown = _ref$actions$dataSeri.hasAggregationsDropDown,
|
|
@@ -415,7 +419,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
|
|
|
415
419
|
label: evt.target.value
|
|
416
420
|
}));
|
|
417
421
|
},
|
|
418
|
-
value: editDataItem.label,
|
|
422
|
+
value: cardUtilityFunctions.getTranslatedLabel(editDataItem.label, shouldUseTranslatedLabels, i18n),
|
|
419
423
|
helperText: mergedI18n.dataItemEditorDataItemHelperText(mergedI18n.dataItemSource, editDataItem.dataItemId)
|
|
420
424
|
})), hasColorDropdown &&
|
|
421
425
|
/*#__PURE__*/
|
|
@@ -462,7 +466,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
|
|
|
462
466
|
unit: evt.target.value
|
|
463
467
|
}));
|
|
464
468
|
},
|
|
465
|
-
value: editDataItem.unit
|
|
469
|
+
value: cardUtilityFunctions.getTranslatedLabel(editDataItem.unit, shouldUseTranslatedLabels, i18n)
|
|
466
470
|
})), /*#__PURE__*/React__default.default.createElement("div", {
|
|
467
471
|
className: "".concat(baseClassName, "--input-group--item")
|
|
468
472
|
}, hasDecimalPlacesDropdown && /*#__PURE__*/React__default.default.createElement(react.Dropdown, {
|
|
@@ -560,7 +564,7 @@ var DataSeriesFormItemModal = function DataSeriesFormItemModal(_ref) {
|
|
|
560
564
|
},
|
|
561
565
|
columnType: editDataItem.columnType || editDataItem.type
|
|
562
566
|
}));
|
|
563
|
-
}, [availableDimensions, availableDimensionsItems, availableGrains, baseClassName, cardConfig, editDataItem, handleTranslation, hasAggregationsDropDown, hasColorDropdown, hasDataFilterDropdown, hasDecimalPlacesDropdown, hasGrainsDropDown, hasThresholds, hasTooltip, hasUnit, id, initialAggregation, initialGrain, isSummaryDashboard, isTimeBasedCard, mergedI18n, selectedDimensionFilter, setEditDataItem, type]);
|
|
567
|
+
}, [availableDimensions, availableDimensionsItems, availableGrains, baseClassName, cardConfig, editDataItem, handleTranslation, hasAggregationsDropDown, hasColorDropdown, hasDataFilterDropdown, hasDecimalPlacesDropdown, hasGrainsDropDown, hasThresholds, hasTooltip, hasUnit, i18n, id, initialAggregation, initialGrain, isSummaryDashboard, isTimeBasedCard, mergedI18n, selectedDimensionFilter, setEditDataItem, shouldUseTranslatedLabels, type]);
|
|
564
568
|
return /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, showEditor && /*#__PURE__*/React__default.default.createElement("div", {
|
|
565
569
|
className: "".concat(baseClassName, "--modal-wrapper")
|
|
566
570
|
}, /*#__PURE__*/React__default.default.createElement(ComposedModal.default, {
|
|
@@ -790,6 +794,17 @@ DataSeriesFormItemModal.__docgenInfo = {
|
|
|
790
794
|
},
|
|
791
795
|
"required": false
|
|
792
796
|
},
|
|
797
|
+
"shouldUseTranslatedLabels": {
|
|
798
|
+
"defaultValue": {
|
|
799
|
+
"value": "false",
|
|
800
|
+
"computed": false
|
|
801
|
+
},
|
|
802
|
+
"description": "whether to use translated labels in cards",
|
|
803
|
+
"type": {
|
|
804
|
+
"name": "bool"
|
|
805
|
+
},
|
|
806
|
+
"required": false
|
|
807
|
+
},
|
|
793
808
|
"editDataSeries": {
|
|
794
809
|
"defaultValue": {
|
|
795
810
|
"value": "[]",
|
|
@@ -34,6 +34,7 @@ var DataSeriesFormItemModal = require('../DataSeriesFormItemModal.js');
|
|
|
34
34
|
var LayoutConstants = require('../../../../../constants/LayoutConstants.js');
|
|
35
35
|
var ContentFormItemTitle = require('../ContentFormItemTitle.js');
|
|
36
36
|
var HierarchyDataFormItems = require('../HierarchyDataFormItems/HierarchyDataFormItems.js');
|
|
37
|
+
var cardUtilityFunctions = require('../../../../../utils/cardUtilityFunctions.js');
|
|
37
38
|
var BarChartDataSeriesContent = require('./BarChartDataSeriesContent.js');
|
|
38
39
|
var iconsReact = require('@carbon/icons-react');
|
|
39
40
|
|
|
@@ -132,6 +133,8 @@ var propTypes = {
|
|
|
132
133
|
incrementNumberText: PropTypes__default.default.string,
|
|
133
134
|
decrementNumberText: PropTypes__default.default.string
|
|
134
135
|
}),
|
|
136
|
+
/** whether to use translated labels in cards */
|
|
137
|
+
shouldUseTranslatedLabels: PropTypes__default.default.bool,
|
|
135
138
|
translateWithId: PropTypes__default.default.func.isRequired,
|
|
136
139
|
actions: editorUtils.DashboardEditorActionsPropTypes
|
|
137
140
|
};
|
|
@@ -165,6 +168,7 @@ var defaultProps = {
|
|
|
165
168
|
incrementNumberText: 'Increment number',
|
|
166
169
|
decrementNumberText: 'Decrement number'
|
|
167
170
|
},
|
|
171
|
+
shouldUseTranslatedLabels: false,
|
|
168
172
|
getValidDataItems: null,
|
|
169
173
|
dataItems: [],
|
|
170
174
|
selectedDataItems: [],
|
|
@@ -252,6 +256,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
|
|
|
252
256
|
selectedTimeRange = _ref2.selectedTimeRange,
|
|
253
257
|
availableDimensions = _ref2.availableDimensions,
|
|
254
258
|
i18n = _ref2.i18n,
|
|
259
|
+
shouldUseTranslatedLabels = _ref2.shouldUseTranslatedLabels,
|
|
255
260
|
dataSeriesItemLinks = _ref2.dataSeriesItemLinks,
|
|
256
261
|
translateWithId = _ref2.translateWithId,
|
|
257
262
|
actions = _ref2.actions;
|
|
@@ -397,7 +402,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
|
|
|
397
402
|
return {
|
|
398
403
|
id: dataItem.dataSourceId,
|
|
399
404
|
content: {
|
|
400
|
-
value: dataItem.label || dataItem.dataItemId,
|
|
405
|
+
value: cardUtilityFunctions.getTranslatedLabel(dataItem.label || dataItem.dataItemId, shouldUseTranslatedLabels, i18n),
|
|
401
406
|
icon: cardConfig.type === LayoutConstants.CARD_TYPES.TIMESERIES || cardConfig.type === LayoutConstants.CARD_TYPES.BAR ? /*#__PURE__*/React__default.default.createElement("div", {
|
|
402
407
|
className: "".concat(baseClassName, "--data-item-list--item-color-icon"),
|
|
403
408
|
style: {
|
|
@@ -434,7 +439,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
|
|
|
434
439
|
}
|
|
435
440
|
};
|
|
436
441
|
})) || [];
|
|
437
|
-
}, [cardConfig.type, handleEditButton, handleRemoveButton, mergedI18n.edit, mergedI18n.remove]);
|
|
442
|
+
}, [cardConfig.type, handleEditButton, handleRemoveButton, i18n, mergedI18n.edit, mergedI18n.remove, shouldUseTranslatedLabels]);
|
|
438
443
|
var dataItemListItems = React.useMemo(function () {
|
|
439
444
|
return generateListItems(dataSection);
|
|
440
445
|
}, [dataSection, generateListItems]);
|
|
@@ -455,6 +460,7 @@ var DataSeriesFormItem = function DataSeriesFormItem(_ref2) {
|
|
|
455
460
|
dataSection: dataSection,
|
|
456
461
|
onChange: _onChange,
|
|
457
462
|
i18n: mergedI18n,
|
|
463
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
458
464
|
actions: actions,
|
|
459
465
|
options: {
|
|
460
466
|
hasColorDropdown: type === LayoutConstants.CARD_TYPES.TIMESERIES || type === LayoutConstants.CARD_TYPES.BAR,
|
|
@@ -776,6 +782,17 @@ DataSeriesFormItem.__docgenInfo = {
|
|
|
776
782
|
},
|
|
777
783
|
"required": false
|
|
778
784
|
},
|
|
785
|
+
"shouldUseTranslatedLabels": {
|
|
786
|
+
"defaultValue": {
|
|
787
|
+
"value": "false",
|
|
788
|
+
"computed": false
|
|
789
|
+
},
|
|
790
|
+
"description": "whether to use translated labels in cards",
|
|
791
|
+
"type": {
|
|
792
|
+
"name": "bool"
|
|
793
|
+
},
|
|
794
|
+
"required": false
|
|
795
|
+
},
|
|
779
796
|
"getValidDataItems": {
|
|
780
797
|
"defaultValue": {
|
|
781
798
|
"value": "null",
|
|
@@ -21,6 +21,7 @@ var react = require('@carbon/react');
|
|
|
21
21
|
var LayoutConstants = require('../../../constants/LayoutConstants.js');
|
|
22
22
|
var Settings = require('../../../constants/Settings.js');
|
|
23
23
|
var editorUtils = require('../../DashboardEditor/editorUtils.js');
|
|
24
|
+
var cardUtilityFunctions = require('../../../utils/cardUtilityFunctions.js');
|
|
24
25
|
|
|
25
26
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
26
27
|
|
|
@@ -85,6 +86,8 @@ var propTypes = {
|
|
|
85
86
|
thisQuarterLabel: PropTypes__default.default.string,
|
|
86
87
|
thisYearLabel: PropTypes__default.default.string
|
|
87
88
|
}),
|
|
89
|
+
/** whether to use translated labels in cards */
|
|
90
|
+
shouldUseTranslatedLabels: PropTypes__default.default.bool,
|
|
88
91
|
/** if provided, returns an array of strings which are the timeRanges to be allowed
|
|
89
92
|
* on each card
|
|
90
93
|
* getValidTimeRanges(card, selectedDataItems)
|
|
@@ -118,6 +121,7 @@ var defaultProps = {
|
|
|
118
121
|
thisQuarterLabel: 'This quarter',
|
|
119
122
|
thisYearLabel: 'This year'
|
|
120
123
|
},
|
|
124
|
+
shouldUseTranslatedLabels: false,
|
|
121
125
|
selectedDataItems: [],
|
|
122
126
|
getValidTimeRanges: null,
|
|
123
127
|
currentBreakpoint: 'xl',
|
|
@@ -141,6 +145,7 @@ var CommonCardEditFormFields = function CommonCardEditFormFields(_ref) {
|
|
|
141
145
|
var cardConfig = _ref.cardConfig,
|
|
142
146
|
_onChange = _ref.onChange,
|
|
143
147
|
i18n = _ref.i18n,
|
|
148
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
144
149
|
getValidTimeRanges = _ref.getValidTimeRanges,
|
|
145
150
|
currentBreakpoint = _ref.currentBreakpoint,
|
|
146
151
|
selectedDataItems = _ref.selectedDataItems,
|
|
@@ -171,7 +176,7 @@ var CommonCardEditFormFields = function CommonCardEditFormFields(_ref) {
|
|
|
171
176
|
title: evt.target.value
|
|
172
177
|
}));
|
|
173
178
|
},
|
|
174
|
-
value: title
|
|
179
|
+
value: cardUtilityFunctions.getTranslatedLabel(title, shouldUseTranslatedLabels, mergedI18n)
|
|
175
180
|
})), /*#__PURE__*/React__default.default.createElement("div", {
|
|
176
181
|
className: "".concat(baseClassName, "--input")
|
|
177
182
|
}, /*#__PURE__*/React__default.default.createElement(react.TextArea, {
|
|
@@ -183,7 +188,7 @@ var CommonCardEditFormFields = function CommonCardEditFormFields(_ref) {
|
|
|
183
188
|
description: evt.target.value
|
|
184
189
|
}));
|
|
185
190
|
},
|
|
186
|
-
value: description
|
|
191
|
+
value: cardUtilityFunctions.getTranslatedLabel(description, shouldUseTranslatedLabels, mergedI18n)
|
|
187
192
|
})), /*#__PURE__*/React__default.default.createElement("div", {
|
|
188
193
|
className: "".concat(baseClassName, "--input")
|
|
189
194
|
}, /*#__PURE__*/React__default.default.createElement(react.Dropdown, {
|
|
@@ -464,6 +469,17 @@ CommonCardEditFormFields.__docgenInfo = {
|
|
|
464
469
|
},
|
|
465
470
|
"required": false
|
|
466
471
|
},
|
|
472
|
+
"shouldUseTranslatedLabels": {
|
|
473
|
+
"defaultValue": {
|
|
474
|
+
"value": "false",
|
|
475
|
+
"computed": false
|
|
476
|
+
},
|
|
477
|
+
"description": "whether to use translated labels in cards",
|
|
478
|
+
"type": {
|
|
479
|
+
"name": "bool"
|
|
480
|
+
},
|
|
481
|
+
"required": false
|
|
482
|
+
},
|
|
467
483
|
"selectedDataItems": {
|
|
468
484
|
"defaultValue": {
|
|
469
485
|
"value": "[]",
|
|
@@ -149,6 +149,8 @@ var propTypes = {
|
|
|
149
149
|
searchPlaceHolderText: PropTypes__default.default.string,
|
|
150
150
|
editDataItems: PropTypes__default.default.string
|
|
151
151
|
}),
|
|
152
|
+
/** whether to use translated labels in cards */
|
|
153
|
+
shouldUseTranslatedLabels: PropTypes__default.default.bool,
|
|
152
154
|
currentBreakpoint: PropTypes__default.default.string,
|
|
153
155
|
isSummaryDashboard: PropTypes__default.default.bool,
|
|
154
156
|
/** Id that can be used for testing */
|
|
@@ -182,6 +184,7 @@ var defaultProps = {
|
|
|
182
184
|
modalHelpText: 'The JSON definition for this card is provided below. You can modify this data directly to update the card configuration.',
|
|
183
185
|
modalIconDescription: 'Close'
|
|
184
186
|
},
|
|
187
|
+
shouldUseTranslatedLabels: false,
|
|
185
188
|
getValidDimensions: null,
|
|
186
189
|
getValidDataItems: null,
|
|
187
190
|
getValidTimeRanges: null,
|
|
@@ -327,6 +330,7 @@ var CardEditor = function CardEditor(_ref) {
|
|
|
327
330
|
onRenderCardEditForm = _ref.onRenderCardEditForm,
|
|
328
331
|
icons = _ref.icons,
|
|
329
332
|
i18n = _ref.i18n,
|
|
333
|
+
shouldUseTranslatedLabels = _ref.shouldUseTranslatedLabels,
|
|
330
334
|
currentBreakpoint = _ref.currentBreakpoint,
|
|
331
335
|
testId = _ref.testId,
|
|
332
336
|
dataSeriesItemLinks = _ref.dataSeriesItemLinks,
|
|
@@ -392,6 +396,7 @@ var CardEditor = function CardEditor(_ref) {
|
|
|
392
396
|
getValidTimeRanges: getValidTimeRanges,
|
|
393
397
|
availableDimensions: availableDimensions,
|
|
394
398
|
i18n: mergedI18n,
|
|
399
|
+
shouldUseTranslatedLabels: shouldUseTranslatedLabels,
|
|
395
400
|
currentBreakpoint: currentBreakpoint,
|
|
396
401
|
dataSeriesItemLinks: dataSeriesItemLinks,
|
|
397
402
|
onFetchDynamicDemoHotspots: onFetchDynamicDemoHotspots,
|
|
@@ -557,6 +562,17 @@ CardEditor.__docgenInfo = {
|
|
|
557
562
|
},
|
|
558
563
|
"required": false
|
|
559
564
|
},
|
|
565
|
+
"shouldUseTranslatedLabels": {
|
|
566
|
+
"defaultValue": {
|
|
567
|
+
"value": "false",
|
|
568
|
+
"computed": false
|
|
569
|
+
},
|
|
570
|
+
"description": "whether to use translated labels in cards",
|
|
571
|
+
"type": {
|
|
572
|
+
"name": "bool"
|
|
573
|
+
},
|
|
574
|
+
"required": false
|
|
575
|
+
},
|
|
560
576
|
"getValidDimensions": {
|
|
561
577
|
"defaultValue": {
|
|
562
578
|
"value": "null",
|