@devtron-labs/devtron-fe-common-lib 0.0.6-beta-26 → 0.0.7-beta-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/dist/Common/Constants.d.ts +6 -0
- package/dist/Common/EmptyState/EmptyState.d.ts +2 -1
- package/dist/Common/Error.d.ts +2 -1
- package/dist/index.js +53 -60
- package/package.json +1 -1
- package/src/Common/Constants.ts +27 -14
- package/src/Common/CustomTagSelector/TagDetails.tsx +1 -1
- package/src/Common/CustomTagSelector/TagLabelValueSelector.tsx +2 -2
- package/src/Common/EmptyState/EmptyState.tsx +4 -4
- package/src/Common/Error.tsx +11 -10
- package/src/Common/Helper.tsx +26 -22
|
@@ -24,6 +24,7 @@ export declare const DEFAULT_TAG_DATA: {
|
|
|
24
24
|
propagate: boolean;
|
|
25
25
|
isInvalidKey: boolean;
|
|
26
26
|
isInvalidValue: boolean;
|
|
27
|
+
isSuggested: boolean;
|
|
27
28
|
};
|
|
28
29
|
export declare const TOAST_ACCESS_DENIED: {
|
|
29
30
|
TITLE: string;
|
|
@@ -33,4 +34,9 @@ export declare const ERROR_EMPTY_SCREEN: {
|
|
|
33
34
|
PAGE_NOT_FOUND: string;
|
|
34
35
|
PAGE_NOT_EXIST: string;
|
|
35
36
|
TAKE_BACK_HOME: string;
|
|
37
|
+
ONLY_FOR_SUPERADMIN: string;
|
|
38
|
+
NOT_AUTHORIZED: string;
|
|
39
|
+
UNAUTHORIZED: string;
|
|
40
|
+
FORBIDDEN: string;
|
|
41
|
+
REQUIRED_MANAGER_ACCESS: string;
|
|
36
42
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './emptyState.scss';
|
|
3
|
-
declare function EmptyState({ children }: {
|
|
3
|
+
declare function EmptyState({ children, className }: {
|
|
4
4
|
children: any;
|
|
5
|
+
className?: string;
|
|
5
6
|
}): JSX.Element;
|
|
6
7
|
declare namespace EmptyState {
|
|
7
8
|
var Image: ({ children }: {
|
package/dist/Common/Error.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export declare class ErrorScreenManager extends Component<{
|
|
|
10
10
|
render(): JSX.Element;
|
|
11
11
|
}
|
|
12
12
|
export declare class ErrorScreenNotAuthorized extends Component<{
|
|
13
|
-
subtitle
|
|
13
|
+
subtitle?: React.ReactChild;
|
|
14
|
+
title?: string;
|
|
14
15
|
subtitleClass?: string;
|
|
15
16
|
}> {
|
|
16
17
|
render(): JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -7,20 +7,20 @@ var reactRouter = require('react-router');
|
|
|
7
7
|
var reactRouterDom = require('react-router-dom');
|
|
8
8
|
|
|
9
9
|
function _interopNamespaceDefault(e) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
18
20
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
n.default = e;
|
|
23
|
-
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
@@ -46,7 +46,14 @@ exports.KEY_VALUE = void 0;
|
|
|
46
46
|
KEY_VALUE["KEY"] = "key";
|
|
47
47
|
KEY_VALUE["VALUE"] = "value";
|
|
48
48
|
})(exports.KEY_VALUE || (exports.KEY_VALUE = {}));
|
|
49
|
-
var DEFAULT_TAG_DATA = {
|
|
49
|
+
var DEFAULT_TAG_DATA = {
|
|
50
|
+
key: '',
|
|
51
|
+
value: '',
|
|
52
|
+
propagate: false,
|
|
53
|
+
isInvalidKey: false,
|
|
54
|
+
isInvalidValue: false,
|
|
55
|
+
isSuggested: true,
|
|
56
|
+
};
|
|
50
57
|
var TOAST_ACCESS_DENIED = {
|
|
51
58
|
TITLE: 'Access denied',
|
|
52
59
|
SUBTITLE: 'You do not have required access to perform this action',
|
|
@@ -56,6 +63,11 @@ var ERROR_EMPTY_SCREEN = {
|
|
|
56
63
|
PAGE_NOT_FOUND: 'We could not find this page',
|
|
57
64
|
PAGE_NOT_EXIST: 'This page doesn’t exist or was removed. We suggest you go back to home',
|
|
58
65
|
TAKE_BACK_HOME: 'Take me home',
|
|
66
|
+
ONLY_FOR_SUPERADMIN: 'Information on this page is available only to superadmin users.',
|
|
67
|
+
NOT_AUTHORIZED: 'Not authorized',
|
|
68
|
+
UNAUTHORIZED: 'unauthorized',
|
|
69
|
+
FORBIDDEN: 'forbidden',
|
|
70
|
+
REQUIRED_MANAGER_ACCESS: 'Looks like you don’t have access to information on this page. Please contact your manager to request access.',
|
|
59
71
|
};
|
|
60
72
|
|
|
61
73
|
/******************************************************************************
|
|
@@ -459,9 +471,9 @@ var css_248z$3 = ".empty-state {\n height: 100%;\n}\n.empty-state img {\n heig
|
|
|
459
471
|
styleInject(css_248z$3);
|
|
460
472
|
|
|
461
473
|
var _g$2;
|
|
462
|
-
function _extends$
|
|
474
|
+
function _extends$a() { _extends$a = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$a.apply(this, arguments); }
|
|
463
475
|
var SvgIcProgressing = function SvgIcProgressing(props) {
|
|
464
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$
|
|
476
|
+
return /*#__PURE__*/React__namespace.createElement("svg", _extends$a({
|
|
465
477
|
xmlns: "http://www.w3.org/2000/svg",
|
|
466
478
|
viewBox: "0 0 24 24",
|
|
467
479
|
width: "1em",
|
|
@@ -483,8 +495,8 @@ var SvgIcProgressing = function SvgIcProgressing(props) {
|
|
|
483
495
|
};
|
|
484
496
|
|
|
485
497
|
function EmptyState(_a) {
|
|
486
|
-
var children = _a.children;
|
|
487
|
-
return (jsxRuntime.jsx("div", __assign({ className: "flex column empty-state",
|
|
498
|
+
var children = _a.children, _b = _a.className, className = _b === void 0 ? '' : _b;
|
|
499
|
+
return (jsxRuntime.jsx("div", __assign({ className: "flex column empty-state ".concat(className), "w-100": true, "h-100": true }, { children: children })));
|
|
488
500
|
}
|
|
489
501
|
function Image(_a) {
|
|
490
502
|
var children = _a.children;
|
|
@@ -496,7 +508,7 @@ function Title(_a) {
|
|
|
496
508
|
}
|
|
497
509
|
function Subtitle(_a) {
|
|
498
510
|
var children = _a.children, className = _a.className;
|
|
499
|
-
return jsxRuntime.jsx("p", __assign({ className: "subtitle ".concat(className) }, { children: children }));
|
|
511
|
+
return jsxRuntime.jsx("p", __assign({ className: "subtitle ".concat(className || '') }, { children: children }));
|
|
500
512
|
}
|
|
501
513
|
function Button$1(_a) {
|
|
502
514
|
var children = _a.children;
|
|
@@ -513,8 +525,8 @@ EmptyState.Loading = Loading;
|
|
|
513
525
|
|
|
514
526
|
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e))for(t=0;t<e.length;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);else for(t in e)e[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var e,t,f=0,n="";f<arguments.length;)(e=arguments[f++])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
|
|
515
527
|
|
|
516
|
-
function _extends$
|
|
517
|
-
_extends$
|
|
528
|
+
function _extends$9() {
|
|
529
|
+
_extends$9 = Object.assign || function (target) {
|
|
518
530
|
for (var i = 1; i < arguments.length; i++) {
|
|
519
531
|
var source = arguments[i];
|
|
520
532
|
|
|
@@ -528,7 +540,7 @@ function _extends$a() {
|
|
|
528
540
|
return target;
|
|
529
541
|
};
|
|
530
542
|
|
|
531
|
-
return _extends$
|
|
543
|
+
return _extends$9.apply(this, arguments);
|
|
532
544
|
}
|
|
533
545
|
|
|
534
546
|
function _objectWithoutPropertiesLoose$2(source, excluded) {
|
|
@@ -1254,7 +1266,7 @@ function ProgressBar(_ref) {
|
|
|
1254
1266
|
isIn = _ref.isIn,
|
|
1255
1267
|
theme = _ref.theme;
|
|
1256
1268
|
|
|
1257
|
-
var style = _extends$
|
|
1269
|
+
var style = _extends$9({}, userStyle, {
|
|
1258
1270
|
animationDuration: delay + "ms",
|
|
1259
1271
|
animationPlayState: isRunning ? 'running' : 'paused',
|
|
1260
1272
|
opacity: hide ? 0 : 1
|
|
@@ -1531,9 +1543,9 @@ var ToastContainer = function ToastContainer(props) {
|
|
|
1531
1543
|
,
|
|
1532
1544
|
id: containerId
|
|
1533
1545
|
}, getToastToRender(function (position, toastList) {
|
|
1534
|
-
var containerStyle = !toastList.length ? _extends$
|
|
1546
|
+
var containerStyle = !toastList.length ? _extends$9({}, style, {
|
|
1535
1547
|
pointerEvents: 'none'
|
|
1536
|
-
}) : _extends$
|
|
1548
|
+
}) : _extends$9({}, style);
|
|
1537
1549
|
return React.createElement("div", {
|
|
1538
1550
|
className: getClassName(position),
|
|
1539
1551
|
style: containerStyle,
|
|
@@ -1640,7 +1652,7 @@ function dispatchToast(content, options) {
|
|
|
1640
1652
|
|
|
1641
1653
|
|
|
1642
1654
|
function mergeOptions(type, options) {
|
|
1643
|
-
return _extends$
|
|
1655
|
+
return _extends$9({}, options, {
|
|
1644
1656
|
type: options && options.type || type,
|
|
1645
1657
|
toastId: getToastId(options)
|
|
1646
1658
|
});
|
|
@@ -1657,7 +1669,7 @@ function toast(content, options) {
|
|
|
1657
1669
|
}
|
|
1658
1670
|
|
|
1659
1671
|
toast.loading = function (content, options) {
|
|
1660
|
-
return dispatchToast(content, mergeOptions(TYPE.DEFAULT, _extends$
|
|
1672
|
+
return dispatchToast(content, mergeOptions(TYPE.DEFAULT, _extends$9({
|
|
1661
1673
|
isLoading: true,
|
|
1662
1674
|
autoClose: false,
|
|
1663
1675
|
closeOnClick: false,
|
|
@@ -1673,7 +1685,7 @@ function handlePromise(promise, _ref2, options) {
|
|
|
1673
1685
|
var id;
|
|
1674
1686
|
|
|
1675
1687
|
if (pending) {
|
|
1676
|
-
id = isStr(pending) ? toast.loading(pending, options) : toast.loading(pending.render, _extends$
|
|
1688
|
+
id = isStr(pending) ? toast.loading(pending, options) : toast.loading(pending.render, _extends$9({}, options, pending));
|
|
1677
1689
|
}
|
|
1678
1690
|
|
|
1679
1691
|
var resetParams = {
|
|
@@ -1692,7 +1704,7 @@ function handlePromise(promise, _ref2, options) {
|
|
|
1692
1704
|
return;
|
|
1693
1705
|
}
|
|
1694
1706
|
|
|
1695
|
-
var baseParams = _extends$
|
|
1707
|
+
var baseParams = _extends$9({
|
|
1696
1708
|
type: type
|
|
1697
1709
|
}, resetParams, options, {
|
|
1698
1710
|
data: result
|
|
@@ -1703,10 +1715,10 @@ function handlePromise(promise, _ref2, options) {
|
|
|
1703
1715
|
} : input; // if the id is set we know that it's an update
|
|
1704
1716
|
|
|
1705
1717
|
if (id) {
|
|
1706
|
-
toast.update(id, _extends$
|
|
1718
|
+
toast.update(id, _extends$9({}, baseParams, params));
|
|
1707
1719
|
} else {
|
|
1708
1720
|
// using toast.promise without loading
|
|
1709
|
-
toast(params.render, _extends$
|
|
1721
|
+
toast(params.render, _extends$9({}, baseParams, params));
|
|
1710
1722
|
}
|
|
1711
1723
|
|
|
1712
1724
|
return result;
|
|
@@ -1730,7 +1742,7 @@ toast.warning = /*#__PURE__*/createToastByType(TYPE.WARNING);
|
|
|
1730
1742
|
toast.warn = toast.warning;
|
|
1731
1743
|
|
|
1732
1744
|
toast.dark = function (content, options) {
|
|
1733
|
-
return dispatchToast(content, mergeOptions(TYPE.DEFAULT, _extends$
|
|
1745
|
+
return dispatchToast(content, mergeOptions(TYPE.DEFAULT, _extends$9({
|
|
1734
1746
|
theme: 'dark'
|
|
1735
1747
|
}, options)));
|
|
1736
1748
|
};
|
|
@@ -1787,7 +1799,7 @@ toast.update = function (toastId, options) {
|
|
|
1787
1799
|
var oldOptions = toast.props,
|
|
1788
1800
|
oldContent = toast.content;
|
|
1789
1801
|
|
|
1790
|
-
var nextOptions = _extends$
|
|
1802
|
+
var nextOptions = _extends$9({}, oldOptions, options, {
|
|
1791
1803
|
toastId: options.toastId || toastId,
|
|
1792
1804
|
updateId: generateToastId()
|
|
1793
1805
|
});
|
|
@@ -1956,7 +1968,7 @@ var ErrorScreenManager = /** @class */ (function (_super) {
|
|
|
1956
1968
|
case 401:
|
|
1957
1969
|
return 'Unauthorized';
|
|
1958
1970
|
case 403:
|
|
1959
|
-
return
|
|
1971
|
+
return jsxRuntime.jsx(ErrorScreenNotAuthorized, { subtitle: this.props.subtitle, subtitleClass: this.props.subtitleClass });
|
|
1960
1972
|
case 404:
|
|
1961
1973
|
return jsxRuntime.jsx(ErrorScreenNotFound, {});
|
|
1962
1974
|
case 500:
|
|
@@ -1981,9 +1993,8 @@ var ErrorScreenNotAuthorized = /** @class */ (function (_super) {
|
|
|
1981
1993
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
1982
1994
|
}
|
|
1983
1995
|
ErrorScreenNotAuthorized.prototype.render = function () {
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
: "Looks like you don't have access to information on this page. Please contact your manager to request access." }))] }));
|
|
1996
|
+
var _a, _b;
|
|
1997
|
+
return (jsxRuntime.jsxs(EmptyState, __assign({ className: "dc__align-reload-center" }, { children: [jsxRuntime.jsx(EmptyState.Image, { children: jsxRuntime.jsx("img", { src: notAuthorized, alt: "Not Authorized" }) }), jsxRuntime.jsx(EmptyState.Title, { children: jsxRuntime.jsx("h3", __assign({ className: "title" }, { children: (_a = this.props.title) !== null && _a !== void 0 ? _a : ERROR_EMPTY_SCREEN.NOT_AUTHORIZED })) }), jsxRuntime.jsx(EmptyState.Subtitle, __assign({ className: this.props.subtitleClass }, { children: (_b = this.props.subtitle) !== null && _b !== void 0 ? _b : ERROR_EMPTY_SCREEN.ONLY_FOR_SUPERADMIN }))] })));
|
|
1987
1998
|
};
|
|
1988
1999
|
return ErrorScreenNotAuthorized;
|
|
1989
2000
|
}(React.Component));
|
|
@@ -3879,7 +3890,8 @@ function showError(serverError, showToastOnUnknownError, hideAccessError) {
|
|
|
3879
3890
|
if (serverError instanceof ServerErrors && Array.isArray(serverError.errors)) {
|
|
3880
3891
|
serverError.errors.map(function (_a) {
|
|
3881
3892
|
var userMessage = _a.userMessage, internalMessage = _a.internalMessage;
|
|
3882
|
-
if (serverError.code === 403 &&
|
|
3893
|
+
if (serverError.code === 403 &&
|
|
3894
|
+
(userMessage === ERROR_EMPTY_SCREEN.UNAUTHORIZED || userMessage === ERROR_EMPTY_SCREEN.FORBIDDEN)) {
|
|
3883
3895
|
if (!hideAccessError) {
|
|
3884
3896
|
toastAccessDenied();
|
|
3885
3897
|
}
|
|
@@ -4063,25 +4075,6 @@ var Modal = function (_a) {
|
|
|
4063
4075
|
}, id: "popup", className: "".concat(rootClassName, " popup ").concat(modal ? 'modal' : ''), style: __assign({}, style) }, { children: children })), document.getElementById('visible-modal'));
|
|
4064
4076
|
};
|
|
4065
4077
|
|
|
4066
|
-
var _defs, _use;
|
|
4067
|
-
function _extends$9() { _extends$9 = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$9.apply(this, arguments); }
|
|
4068
|
-
var SvgIcClose = function SvgIcClose(props) {
|
|
4069
|
-
return /*#__PURE__*/React__namespace.createElement("svg", _extends$9({
|
|
4070
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
4071
|
-
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
4072
|
-
width: "1em",
|
|
4073
|
-
height: "1em",
|
|
4074
|
-
viewBox: "0 0 24 24"
|
|
4075
|
-
}, props), _defs || (_defs = /*#__PURE__*/React__namespace.createElement("defs", null, /*#__PURE__*/React__namespace.createElement("path", {
|
|
4076
|
-
id: "ic-close_svg__a",
|
|
4077
|
-
className: "ic-close_svg__stroke-color",
|
|
4078
|
-
d: "M18.295 5.705a.997.997 0 0 0-1.41 0L12 10.59 7.115 5.705a.997.997 0 1 0-1.41 1.41L10.59 12l-4.885 4.885a.997.997 0 1 0 1.41 1.41L12 13.41l4.885 4.885a.997.997 0 0 0 1.41-1.41L13.41 12l4.885-4.885a.997.997 0 0 0 0-1.41z"
|
|
4079
|
-
}))), _use || (_use = /*#__PURE__*/React__namespace.createElement("use", {
|
|
4080
|
-
fill: "#999",
|
|
4081
|
-
xlinkHref: "#ic-close_svg__a",
|
|
4082
|
-
fillRule: "evenodd"
|
|
4083
|
-
})));
|
|
4084
|
-
};
|
|
4085
4078
|
var close = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%20%20%20%20%3Cdefs%3E%20%20%20%20%20%20%20%20%3Cpath%20id%3D%22a%22%20class%3D%22stroke-color%22%20d%3D%22M18.295%205.705a.997.997%200%200%200-1.41%200L12%2010.59%207.115%205.705a.997.997%200%201%200-1.41%201.41L10.59%2012l-4.885%204.885a.997.997%200%201%200%201.41%201.41L12%2013.41l4.885%204.885a.997.997%200%200%200%201.41-1.41L13.41%2012l4.885-4.885a.997.997%200%200%200%200-1.41z%22%2F%3E%20%20%20%20%3C%2Fdefs%3E%20%20%20%20%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22%22%2F%3E%20%20%20%20%20%20%20%20%3Cuse%20fill%3D%22%23999%22%20xlink%3Ahref%3D%22%23a%22%2F%3E%20%20%20%20%3C%2Fg%3E%3C%2Fsvg%3E";
|
|
4086
4079
|
|
|
4087
4080
|
var OpaqueModal = /** @class */ (function (_super) {
|
|
@@ -8621,7 +8614,7 @@ var TagLabelValueSelector = function (_a) {
|
|
|
8621
8614
|
? !validationRules.propagateTagKey(selectedValue).isValid
|
|
8622
8615
|
: _tagData.value !== '';
|
|
8623
8616
|
}
|
|
8624
|
-
else if (selectedValue) {
|
|
8617
|
+
else if (selectedValue || isRequired) {
|
|
8625
8618
|
_tagData.isInvalidValue = !validationRules.propagateTagValue(selectedValue).isValid;
|
|
8626
8619
|
_tagData.isInvalidKey = !_tagData.key || _tagData.isInvalidKey;
|
|
8627
8620
|
}
|
|
@@ -8660,7 +8653,7 @@ var TagLabelValueSelector = function (_a) {
|
|
|
8660
8653
|
if (tagOptions === null || tagOptions === void 0 ? void 0 : tagOptions.length) {
|
|
8661
8654
|
var filteredTags = tagOptions.filter(function (tag) { return tag.value.indexOf(selectedValue) >= 0; });
|
|
8662
8655
|
if (filteredTags.length) {
|
|
8663
|
-
return (jsxRuntime.jsx("div", { children: filteredTags.map(function (tag, index) { return (jsxRuntime.jsx("div", __assign({ "data-key": tag.label, className: "dc__hover-n50 lh-20 fs-13 fw-
|
|
8656
|
+
return (jsxRuntime.jsx("div", { children: filteredTags.map(function (tag, index) { return (jsxRuntime.jsx("div", __assign({ "data-key": tag.label, className: "dc__hover-n50 lh-20 fs-13 fw-4 pt-6 pr-8 pb-6 pl-8 cursor", onClick: onSelectValue }, { children: tag.label }), "".concat(tag.value, "-").concat(index))); }) }));
|
|
8664
8657
|
}
|
|
8665
8658
|
}
|
|
8666
8659
|
return renderValidationsSuggestions();
|
|
@@ -8685,7 +8678,7 @@ var TagDetails = function (_a) {
|
|
|
8685
8678
|
_tagData.propagate = !_tagData.propagate;
|
|
8686
8679
|
setTagData(index, _tagData);
|
|
8687
8680
|
};
|
|
8688
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "flexbox mb-8" }, { children: [jsxRuntime.jsx("div", __assign({ className: "dc__border h-30 pl-4 pr-4 br-4 mr-8 pointer ".concat(tagData.propagate ? 'bcn-7' : ''), onClick: propagateTagToResource }, { children: jsxRuntime.jsx(SvgInjectTag, { className: "icon-dim-20 mt-4 ".concat(tagData.propagate ? 'scn-0' : '') }) })), jsxRuntime.jsx(TagLabelValueSelector, { selectedTagIndex: index, tagData: tagData, setTagData: setTagData, tagInputType: exports.KEY_VALUE.KEY, placeholder: "Enter key", tabIndex: tabIndex - 1, refVar: keyRef, dependentRef: valueRef, tagOptions: suggestedTagsOptions }), jsxRuntime.jsx(TagLabelValueSelector, { selectedTagIndex: index, tagData: tagData, setTagData: setTagData, tagInputType: exports.KEY_VALUE.VALUE, placeholder: "Enter value", tabIndex: tabIndex, refVar: valueRef, dependentRef: keyRef }), jsxRuntime.jsx("div", __assign({ className: "dc__border pl-4 pr-4 dc__right-radius-4 pointer flex top", onClick: deleteTag }, { children: jsxRuntime.jsx(
|
|
8681
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "flexbox mb-8" }, { children: [jsxRuntime.jsx("div", __assign({ className: "dc__border h-30 pl-4 pr-4 br-4 mr-8 pointer ".concat(tagData.propagate ? 'bcn-7' : ''), onClick: propagateTagToResource }, { children: jsxRuntime.jsx(SvgInjectTag, { className: "icon-dim-20 mt-4 ".concat(tagData.propagate ? 'scn-0' : '') }) })), jsxRuntime.jsx(TagLabelValueSelector, { selectedTagIndex: index, tagData: tagData, setTagData: setTagData, tagInputType: exports.KEY_VALUE.KEY, placeholder: "Enter key", tabIndex: tabIndex - 1, refVar: keyRef, dependentRef: valueRef, tagOptions: suggestedTagsOptions }), jsxRuntime.jsx(TagLabelValueSelector, { selectedTagIndex: index, tagData: tagData, setTagData: setTagData, tagInputType: exports.KEY_VALUE.VALUE, placeholder: "Enter value", tabIndex: tabIndex, refVar: valueRef, dependentRef: keyRef }), jsxRuntime.jsx("div", __assign({ className: "dc__border pl-4 pr-4 dc__right-radius-4 pointer flex top", onClick: deleteTag }, { children: jsxRuntime.jsx(SvgIcCross, { className: "icon-dim-20 mt-4" }) }))] })));
|
|
8689
8682
|
};
|
|
8690
8683
|
|
|
8691
8684
|
var _path$1;
|
package/package.json
CHANGED
package/src/Common/Constants.ts
CHANGED
|
@@ -8,31 +8,44 @@ export const DOCUMENTATION = {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const PATTERNS = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
KUBERNETES_KEY_PREFIX: /^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$/,
|
|
12
|
+
KUBERNETES_KEY_NAME: /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$/,
|
|
13
|
+
START_END_ALPHANUMERIC: /^([Az09].*[A-Za-z0-9])$|[A-Za-z0-9]$/,
|
|
14
|
+
ALPHANUMERIC_WITH_SPECIAL_CHAR: /^[A-Za-z0-9._-]+$/, // allow alphanumeric,(.) ,(-),(_)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const ROUTES = {
|
|
18
|
-
|
|
18
|
+
PROJECT_LIST_MIN: 'team/autocomplete',
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export enum KEY_VALUE {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
KEY = 'key',
|
|
23
|
+
VALUE = 'value',
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export const DEFAULT_TAG_DATA = {
|
|
26
|
+
export const DEFAULT_TAG_DATA = {
|
|
27
|
+
key: '',
|
|
28
|
+
value: '',
|
|
29
|
+
propagate: false,
|
|
30
|
+
isInvalidKey: false,
|
|
31
|
+
isInvalidValue: false,
|
|
32
|
+
isSuggested: true,
|
|
33
|
+
}
|
|
27
34
|
|
|
28
35
|
export const TOAST_ACCESS_DENIED = {
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
TITLE: 'Access denied',
|
|
37
|
+
SUBTITLE: 'You do not have required access to perform this action',
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
// Empty state messgaes
|
|
34
41
|
export const ERROR_EMPTY_SCREEN = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
PAGE_NOT_FOUND: 'We could not find this page',
|
|
43
|
+
PAGE_NOT_EXIST: 'This page doesn’t exist or was removed. We suggest you go back to home',
|
|
44
|
+
TAKE_BACK_HOME: 'Take me home',
|
|
45
|
+
ONLY_FOR_SUPERADMIN: 'Information on this page is available only to superadmin users.',
|
|
46
|
+
NOT_AUTHORIZED: 'Not authorized',
|
|
47
|
+
UNAUTHORIZED:'unauthorized',
|
|
48
|
+
FORBIDDEN:'forbidden',
|
|
49
|
+
REQUIRED_MANAGER_ACCESS:
|
|
50
|
+
'Looks like you don’t have access to information on this page. Please contact your manager to request access.',
|
|
51
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useRef } from 'react'
|
|
2
|
-
import { ReactComponent as DeleteCross } from '../../Assets/Icon/ic-
|
|
2
|
+
import { ReactComponent as DeleteCross } from '../../Assets/Icon/ic-cross.svg'
|
|
3
3
|
import { ReactComponent as InjectTag } from '../../Assets/Icon/inject-tag.svg'
|
|
4
4
|
import { TagLabelValueSelector } from './TagLabelValueSelector'
|
|
5
5
|
import { KEY_VALUE } from '../Constants'
|
|
@@ -46,7 +46,7 @@ export const TagLabelValueSelector = ({
|
|
|
46
46
|
_tagData.isInvalidKey = selectedValue
|
|
47
47
|
? !validationRules.propagateTagKey(selectedValue).isValid
|
|
48
48
|
: _tagData.value !== ''
|
|
49
|
-
} else if (selectedValue) {
|
|
49
|
+
} else if (selectedValue || isRequired) {
|
|
50
50
|
_tagData.isInvalidValue = !validationRules.propagateTagValue(selectedValue).isValid
|
|
51
51
|
_tagData.isInvalidKey = !_tagData.key || _tagData.isInvalidKey
|
|
52
52
|
} else {
|
|
@@ -112,7 +112,7 @@ export const TagLabelValueSelector = ({
|
|
|
112
112
|
<div
|
|
113
113
|
key={`${tag.value}-${index}`}
|
|
114
114
|
data-key={tag.label}
|
|
115
|
-
className="dc__hover-n50 lh-20 fs-13 fw-
|
|
115
|
+
className="dc__hover-n50 lh-20 fs-13 fw-4 pt-6 pr-8 pb-6 pl-8 cursor"
|
|
116
116
|
onClick={onSelectValue}
|
|
117
117
|
>
|
|
118
118
|
{tag.label}
|
|
@@ -2,9 +2,9 @@ import React from 'react'
|
|
|
2
2
|
import './emptyState.scss';
|
|
3
3
|
import { ReactComponent as Progressing } from '../../Assets/Icon/ic-progressing.svg';
|
|
4
4
|
|
|
5
|
-
function EmptyState({ children }) {
|
|
5
|
+
function EmptyState({ children, className = '' }) {
|
|
6
6
|
return (
|
|
7
|
-
<div className=
|
|
7
|
+
<div className={`flex column empty-state ${className}`} w-100 h-100>
|
|
8
8
|
{children}
|
|
9
9
|
</div>
|
|
10
10
|
)
|
|
@@ -18,8 +18,8 @@ function Title({ children }) {
|
|
|
18
18
|
return children
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function Subtitle({ children, className }:{children: any
|
|
22
|
-
return <p className={`subtitle ${className}`}>{children}</p>
|
|
21
|
+
function Subtitle({ children, className }: { children: any; className?: string }) {
|
|
22
|
+
return <p className={`subtitle ${className || ''}`}>{children}</p>
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function Button({ children }) {
|
package/src/Common/Error.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import EmptyState from './EmptyState/EmptyState'
|
|
|
3
3
|
import notAuthorized from '../Assets/Img/ic-not-authorized.svg'
|
|
4
4
|
import Reload from './Reload'
|
|
5
5
|
import ErrorScreenNotFound from './ErrorScreenNotFound'
|
|
6
|
+
import { ERROR_EMPTY_SCREEN } from './Constants'
|
|
6
7
|
|
|
7
8
|
export class ErrorScreenManager extends Component<{
|
|
8
9
|
code?: number
|
|
@@ -18,9 +19,7 @@ export class ErrorScreenManager extends Component<{
|
|
|
18
19
|
case 401:
|
|
19
20
|
return 'Unauthorized'
|
|
20
21
|
case 403:
|
|
21
|
-
return
|
|
22
|
-
<ErrorScreenNotAuthorized subtitle={this.props.subtitle} subtitleClass={this.props.subtitleClass} />
|
|
23
|
-
)
|
|
22
|
+
return <ErrorScreenNotAuthorized subtitle={this.props.subtitle} subtitleClass={this.props.subtitleClass}/>
|
|
24
23
|
case 404:
|
|
25
24
|
return <ErrorScreenNotFound />
|
|
26
25
|
case 500:
|
|
@@ -43,22 +42,24 @@ export class ErrorScreenManager extends Component<{
|
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
export class ErrorScreenNotAuthorized extends Component<{
|
|
45
|
+
export class ErrorScreenNotAuthorized extends Component<{
|
|
46
|
+
subtitle?: React.ReactChild
|
|
47
|
+
title?: string
|
|
48
|
+
subtitleClass?: string
|
|
49
|
+
}> {
|
|
47
50
|
render() {
|
|
48
51
|
return (
|
|
49
|
-
<EmptyState>
|
|
52
|
+
<EmptyState className="dc__align-reload-center">
|
|
50
53
|
<EmptyState.Image>
|
|
51
54
|
<img src={notAuthorized} alt="Not Authorized" />
|
|
52
55
|
</EmptyState.Image>
|
|
53
56
|
<EmptyState.Title>
|
|
54
|
-
<h3 className="title">
|
|
57
|
+
<h3 className="title">{this.props.title ?? ERROR_EMPTY_SCREEN.NOT_AUTHORIZED}</h3>
|
|
55
58
|
</EmptyState.Title>
|
|
56
59
|
<EmptyState.Subtitle className={this.props.subtitleClass}>
|
|
57
|
-
{this.props.subtitle
|
|
58
|
-
? this.props.subtitle
|
|
59
|
-
: "Looks like you don't have access to information on this page. Please contact your manager to request access."}
|
|
60
|
+
{this.props.subtitle ?? ERROR_EMPTY_SCREEN.ONLY_FOR_SUPERADMIN}
|
|
60
61
|
</EmptyState.Subtitle>
|
|
61
62
|
</EmptyState>
|
|
62
63
|
)
|
|
63
64
|
}
|
|
64
|
-
}
|
|
65
|
+
}
|
package/src/Common/Helper.tsx
CHANGED
|
@@ -3,31 +3,35 @@ import { toast } from 'react-toastify'
|
|
|
3
3
|
import * as Sentry from '@sentry/browser'
|
|
4
4
|
import { toastAccessDenied } from './ToastBody'
|
|
5
5
|
import { useEffect, useRef } from 'react'
|
|
6
|
+
import { ERROR_EMPTY_SCREEN } from './Constants'
|
|
6
7
|
|
|
7
8
|
export function showError(serverError, showToastOnUnknownError = true, hideAccessError = false) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
if (serverError instanceof ServerErrors && Array.isArray(serverError.errors)) {
|
|
10
|
+
serverError.errors.map(({ userMessage, internalMessage }) => {
|
|
11
|
+
if (
|
|
12
|
+
serverError.code === 403 &&
|
|
13
|
+
(userMessage === ERROR_EMPTY_SCREEN.UNAUTHORIZED || userMessage === ERROR_EMPTY_SCREEN.FORBIDDEN)
|
|
14
|
+
) {
|
|
15
|
+
if (!hideAccessError) {
|
|
16
|
+
toastAccessDenied()
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
toast.error(userMessage || internalMessage)
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
} else {
|
|
23
|
+
if (serverError.code !== 403 && serverError.code !== 408) {
|
|
24
|
+
Sentry.captureException(serverError)
|
|
25
|
+
}
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
if (showToastOnUnknownError) {
|
|
28
|
+
if (serverError.message) {
|
|
29
|
+
toast.error(serverError.message)
|
|
30
|
+
} else {
|
|
31
|
+
toast.error('Some Error Occurred')
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
interface ConditionalWrapper<T> {
|