@devtron-labs/devtron-fe-common-lib 0.0.6-beta-18 → 0.0.6-beta-20
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/Common.service.d.ts +2 -0
- package/dist/Common/Constants.d.ts +3 -0
- package/dist/Common/Helper.d.ts +1 -0
- package/dist/Common/Types.d.ts +8 -0
- package/dist/Common/index.d.ts +2 -1
- package/dist/index.js +86 -18
- package/package.json +1 -1
- package/rollup.config.js +1 -1
- package/src/Common/Common.service.ts +23 -0
- package/src/Common/Constants.ts +4 -0
- package/src/Common/CustomTagSelector/TagLabelValueSelector.tsx +2 -2
- package/src/Common/Helper.tsx +44 -29
- package/src/Common/Types.ts +10 -0
- package/src/Common/index.ts +2 -1
package/dist/Common/Helper.d.ts
CHANGED
package/dist/Common/Types.d.ts
CHANGED
package/dist/Common/index.d.ts
CHANGED
|
@@ -21,4 +21,5 @@ export * from './TippyCustomized';
|
|
|
21
21
|
export * from './CustomTagSelector';
|
|
22
22
|
export * from './Dialogs';
|
|
23
23
|
export * from './MultiSelectCustomization';
|
|
24
|
-
export
|
|
24
|
+
export { default as InfoColourBar } from './InfoColorBar/InfoColourbar';
|
|
25
|
+
export * from './Common.service';
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,9 @@ var PATTERNS = {
|
|
|
31
31
|
KUBERNETES_KEY_NAME: /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$/,
|
|
32
32
|
START_END_ALPHANUMERIC: /^([Az09].*[A-Za-z0-9])$|[A-Za-z0-9]$/,
|
|
33
33
|
ALPHANUMERIC_WITH_SPECIAL_CHAR: /^[A-Za-z0-9._-]+$/, // allow alphanumeric,(.) ,(-),(_)
|
|
34
|
+
};
|
|
35
|
+
var ROUTES = {
|
|
36
|
+
PROJECT_LIST_MIN: 'team/autocomplete',
|
|
34
37
|
};
|
|
35
38
|
|
|
36
39
|
/******************************************************************************
|
|
@@ -438,7 +441,9 @@ function _extends$a() { _extends$a = Object.assign ? Object.assign.bind() : func
|
|
|
438
441
|
var SvgIcProgressing = function SvgIcProgressing(props) {
|
|
439
442
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends$a({
|
|
440
443
|
xmlns: "http://www.w3.org/2000/svg",
|
|
441
|
-
viewBox: "0 0 24 24"
|
|
444
|
+
viewBox: "0 0 24 24",
|
|
445
|
+
width: "1em",
|
|
446
|
+
height: "1em"
|
|
442
447
|
}, props), _g$2 || (_g$2 = /*#__PURE__*/React__namespace.createElement("g", {
|
|
443
448
|
fill: "none"
|
|
444
449
|
}, /*#__PURE__*/React__namespace.createElement("animateTransform", {
|
|
@@ -3869,7 +3874,22 @@ function showError(serverError, showToastOnUnknownError, hideAccessError) {
|
|
|
3869
3874
|
var ConditionalWrap = function (_a) {
|
|
3870
3875
|
var condition = _a.condition, wrap = _a.wrap, children = _a.children;
|
|
3871
3876
|
return condition ? wrap(children) : jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
|
|
3872
|
-
};
|
|
3877
|
+
};
|
|
3878
|
+
function sortCallback(key, a, b, isCaseSensitive) {
|
|
3879
|
+
var x = a[key];
|
|
3880
|
+
var y = b[key];
|
|
3881
|
+
if (isCaseSensitive) {
|
|
3882
|
+
x = x.toLowerCase();
|
|
3883
|
+
y = y.toLowerCase();
|
|
3884
|
+
}
|
|
3885
|
+
if (x < y) {
|
|
3886
|
+
return -1;
|
|
3887
|
+
}
|
|
3888
|
+
if (x > y) {
|
|
3889
|
+
return 1;
|
|
3890
|
+
}
|
|
3891
|
+
return 0;
|
|
3892
|
+
}
|
|
3873
3893
|
|
|
3874
3894
|
function Progressing(_a) {
|
|
3875
3895
|
var pageLoader = _a.pageLoader, size = _a.size, theme = _a.theme, styles = _a.styles;
|
|
@@ -3993,8 +4013,9 @@ var SvgIcClose = function SvgIcClose(props) {
|
|
|
3993
4013
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends$8({
|
|
3994
4014
|
xmlns: "http://www.w3.org/2000/svg",
|
|
3995
4015
|
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
3996
|
-
width:
|
|
3997
|
-
height:
|
|
4016
|
+
width: "1em",
|
|
4017
|
+
height: "1em",
|
|
4018
|
+
viewBox: "0 0 24 24"
|
|
3998
4019
|
}, props), _defs || (_defs = /*#__PURE__*/React__namespace.createElement("defs", null, /*#__PURE__*/React__namespace.createElement("path", {
|
|
3999
4020
|
id: "ic-close_svg__a",
|
|
4000
4021
|
className: "ic-close_svg__stroke-color",
|
|
@@ -8323,8 +8344,9 @@ var _path$4, _circle, _path2;
|
|
|
8323
8344
|
function _extends$7() { _extends$7 = 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$7.apply(this, arguments); }
|
|
8324
8345
|
var SvgInjectTag = function SvgInjectTag(props) {
|
|
8325
8346
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends$7({
|
|
8326
|
-
width:
|
|
8327
|
-
height:
|
|
8347
|
+
width: "1em",
|
|
8348
|
+
height: "1em",
|
|
8349
|
+
viewBox: "0 0 20 20",
|
|
8328
8350
|
fill: "none",
|
|
8329
8351
|
xmlns: "http://www.w3.org/2000/svg"
|
|
8330
8352
|
}, props), _path$4 || (_path$4 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
@@ -8352,7 +8374,9 @@ function _extends$6() { _extends$6 = Object.assign ? Object.assign.bind() : func
|
|
|
8352
8374
|
var SvgIcHelpOutline = function SvgIcHelpOutline(props) {
|
|
8353
8375
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends$6({
|
|
8354
8376
|
xmlns: "http://www.w3.org/2000/svg",
|
|
8355
|
-
viewBox: "0 0 17 16"
|
|
8377
|
+
viewBox: "0 0 17 16",
|
|
8378
|
+
width: "1em",
|
|
8379
|
+
height: "1em"
|
|
8356
8380
|
}, props), _path$3 || (_path$3 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
8357
8381
|
fill: "#767D84",
|
|
8358
8382
|
fillRule: "evenodd",
|
|
@@ -8372,8 +8396,9 @@ function _extends$5() { _extends$5 = Object.assign ? Object.assign.bind() : func
|
|
|
8372
8396
|
var SvgIcAdd = function SvgIcAdd(props) {
|
|
8373
8397
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends$5({
|
|
8374
8398
|
xmlns: "http://www.w3.org/2000/svg",
|
|
8375
|
-
width:
|
|
8376
|
-
height:
|
|
8399
|
+
width: "1em",
|
|
8400
|
+
height: "1em",
|
|
8401
|
+
viewBox: "0 0 24 24"
|
|
8377
8402
|
}, props), _path$2 || (_path$2 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
8378
8403
|
className: "ic-add_svg__fill-color",
|
|
8379
8404
|
fill: "#999",
|
|
@@ -8446,8 +8471,9 @@ function _extends$4() { _extends$4 = Object.assign ? Object.assign.bind() : func
|
|
|
8446
8471
|
var SvgIcInfoOutlined = function SvgIcInfoOutlined(props) {
|
|
8447
8472
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends$4({
|
|
8448
8473
|
xmlns: "http://www.w3.org/2000/svg",
|
|
8449
|
-
width:
|
|
8450
|
-
height:
|
|
8474
|
+
width: "1em",
|
|
8475
|
+
height: "1em",
|
|
8476
|
+
viewBox: "0 0 20 20"
|
|
8451
8477
|
}, props), _path$1 || (_path$1 = /*#__PURE__*/React__namespace.createElement("path", {
|
|
8452
8478
|
d: "M10 1.667c4.6 0 8.333 3.733 8.333 8.333S14.6 18.333 10 18.333 1.667 14.6 1.667 10 5.4 1.667 10 1.667zm0 1.666A6.67 6.67 0 0 0 3.333 10 6.67 6.67 0 0 0 10 16.667 6.67 6.67 0 0 0 16.667 10 6.67 6.67 0 0 0 10 3.333zm0 5.834c.46 0 .833.373.833.833v3.333a.834.834 0 1 1-1.666 0V10c0-.46.373-.833.833-.833zm0-3.334A.833.833 0 1 1 10 7.5a.833.833 0 0 1 0-1.667z",
|
|
8453
8479
|
fill: "#06C",
|
|
@@ -8504,7 +8530,7 @@ var TagLabelValueSelector = function (_a) {
|
|
|
8504
8530
|
field = validationRules.propagateTagValue(selectedValue);
|
|
8505
8531
|
}
|
|
8506
8532
|
if (!field.isValid) {
|
|
8507
|
-
return (jsxRuntime.jsxs("div", __assign({ className: "p-4" }, { children: [field.messages.map(function (error) { return (jsxRuntime.jsxs("div", __assign({ className: "flexbox p-4" }, { children: [jsxRuntime.jsx("span", { children: jsxRuntime.jsx(SvgIcClose, { className: "fcr-5 mr-4" }) }), jsxRuntime.jsx("span", { children: error })] }), error)); }), type === 'key' && (jsxRuntime.jsxs("div", __assign({ className: "flexbox p-4" }, { children: [jsxRuntime.jsx("span", { children: jsxRuntime.jsx(SvgIcInfoOutlined, { className: "mr-4" }) }), jsxRuntime.jsx("span", __assign({ className: "dc__italic-font-style" }, { children: "Key format: prefix/name or name" }))] })))] })));
|
|
8533
|
+
return (jsxRuntime.jsxs("div", __assign({ className: "p-4" }, { children: [field.messages.map(function (error) { return (jsxRuntime.jsxs("div", __assign({ className: "flexbox p-4" }, { children: [jsxRuntime.jsx("span", { children: jsxRuntime.jsx(SvgIcClose, { className: "icon-dim-16 fcr-5 mt-3 mr-4" }) }), jsxRuntime.jsx("span", { children: error })] }), error)); }), type === 'key' && (jsxRuntime.jsxs("div", __assign({ className: "flexbox p-4" }, { children: [jsxRuntime.jsx("span", { children: jsxRuntime.jsx(SvgIcInfoOutlined, { className: "icon-dim-16 mt-3 mr-4" }) }), jsxRuntime.jsx("span", __assign({ className: "dc__italic-font-style" }, { children: "Key format: prefix/name or name" }))] })))] })));
|
|
8508
8534
|
}
|
|
8509
8535
|
return null;
|
|
8510
8536
|
};
|
|
@@ -16023,8 +16049,8 @@ var SvgIcAppstatusCancelled = function SvgIcAppstatusCancelled(props) {
|
|
|
16023
16049
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends$2({
|
|
16024
16050
|
xmlns: "http://www.w3.org/2000/svg",
|
|
16025
16051
|
viewBox: "0 0 28 28",
|
|
16026
|
-
width:
|
|
16027
|
-
height:
|
|
16052
|
+
width: "1em",
|
|
16053
|
+
height: "1em"
|
|
16028
16054
|
}, props), _g$1 || (_g$1 = /*#__PURE__*/React__namespace.createElement("g", {
|
|
16029
16055
|
fill: "none",
|
|
16030
16056
|
fillRule: "evenodd",
|
|
@@ -16046,8 +16072,9 @@ function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : func
|
|
|
16046
16072
|
var SvgIcCheck = function SvgIcCheck(props) {
|
|
16047
16073
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends$1({
|
|
16048
16074
|
xmlns: "http://www.w3.org/2000/svg",
|
|
16049
|
-
width:
|
|
16050
|
-
height:
|
|
16075
|
+
width: "1em",
|
|
16076
|
+
height: "1em",
|
|
16077
|
+
viewBox: "0 0 24 24"
|
|
16051
16078
|
}, props), _path || (_path = /*#__PURE__*/React__namespace.createElement("path", {
|
|
16052
16079
|
stroke: "#06C",
|
|
16053
16080
|
strokeLinecap: "round",
|
|
@@ -16064,8 +16091,9 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
16064
16091
|
var SvgIcErrorMedium = function SvgIcErrorMedium(props) {
|
|
16065
16092
|
return /*#__PURE__*/React__namespace.createElement("svg", _extends({
|
|
16066
16093
|
xmlns: "http://www.w3.org/2000/svg",
|
|
16067
|
-
width:
|
|
16068
|
-
height:
|
|
16094
|
+
width: "1em",
|
|
16095
|
+
height: "1em",
|
|
16096
|
+
viewBox: "0 0 20 21"
|
|
16069
16097
|
}, props), _g || (_g = /*#__PURE__*/React__namespace.createElement("g", {
|
|
16070
16098
|
fill: "none",
|
|
16071
16099
|
fillRule: "evenodd"
|
|
@@ -16129,6 +16157,42 @@ var CustomSelect = function (props) {
|
|
|
16129
16157
|
var css_248z = ".info-bar-container .info_text .success {\n background-color: var(--G100);\n}\n.info-bar-container .warn {\n background: var(--Y100);\n border: solid var(--Y200);\n}\n.info-bar-container .warn .warning-icon path:nth-child(2) {\n fill: var(--Y700);\n}\n.info-bar-container .info_bar {\n background-color: var(--B100);\n border: 1px solid var(--B200);\n}\n.info-bar-container .error_bar {\n background-color: var(--R100);\n border: 1px solid var(--R200);\n}\n.info-bar-container .question-bar {\n background-color: var(--V100);\n border: 1px solid var(--V200);\n}";
|
|
16130
16158
|
styleInject(css_248z);
|
|
16131
16159
|
|
|
16160
|
+
function InfoColourBar(_a) {
|
|
16161
|
+
var message = _a.message, classname = _a.classname, Icon = _a.Icon, iconClass = _a.iconClass, iconSize = _a.iconSize, renderActionButton = _a.renderActionButton, linkText = _a.linkText, redirectLink = _a.redirectLink, linkOnClick = _a.linkOnClick, linkClass = _a.linkClass, internalLink = _a.internalLink, styles = _a.styles;
|
|
16162
|
+
var renderLink = function () {
|
|
16163
|
+
if (!linkText) {
|
|
16164
|
+
return null;
|
|
16165
|
+
}
|
|
16166
|
+
else if (redirectLink) {
|
|
16167
|
+
if (internalLink) {
|
|
16168
|
+
return (jsxRuntime.jsx(reactRouterDom.Link, __assign({ to: redirectLink, onClick: linkOnClick, className: "cursor dc__link dc__underline-onhover mr-5" }, { children: linkText })));
|
|
16169
|
+
}
|
|
16170
|
+
return (jsxRuntime.jsx("a", __assign({ href: redirectLink, target: "_blank", onClick: linkOnClick, className: "cursor dc__link dc__underline-onhover mr-5" }, { children: linkText })));
|
|
16171
|
+
}
|
|
16172
|
+
return (linkOnClick && (jsxRuntime.jsx("div", __assign({ onClick: linkOnClick, className: "cursor dc__link dc__underline-onhover" }, { children: linkText }))));
|
|
16173
|
+
};
|
|
16174
|
+
return (jsxRuntime.jsx("div", __assign({ className: "info-bar-container" }, { children: jsxRuntime.jsxs("div", __assign({ className: "".concat(classname, " info_text flex dc__content-space pt-8 pb-8 pl-16 pr-16 br-4 top fs-13 fw-4"), style: styles }, { children: [jsxRuntime.jsxs("div", __assign({ className: "flex top ".concat(typeof renderActionButton === 'function' ? 'mr-5' : '') }, { children: [jsxRuntime.jsx("div", __assign({ className: "icon-dim-".concat(iconSize !== null && iconSize !== void 0 ? iconSize : '20', " mr-10") }, { children: jsxRuntime.jsx(Icon, { className: "icon-dim-".concat(iconSize !== null && iconSize !== void 0 ? iconSize : '20', " ").concat(iconClass || '', " mr-8") }) })), jsxRuntime.jsxs("div", __assign({ className: "info-bar-message-wrapper ".concat(linkClass || '') }, { children: [jsxRuntime.jsx("span", __assign({ className: linkText && redirectLink ? 'mr-5' : '' }, { children: message })), renderLink()] }))] })), typeof renderActionButton === 'function' && renderActionButton()] })) })));
|
|
16175
|
+
}
|
|
16176
|
+
|
|
16177
|
+
var getTeamListMin = function () {
|
|
16178
|
+
// ignore active field
|
|
16179
|
+
var URL = "".concat(ROUTES.PROJECT_LIST_MIN);
|
|
16180
|
+
return get(URL).then(function (response) {
|
|
16181
|
+
var list = [];
|
|
16182
|
+
if (response && response.result && Array.isArray(response.result)) {
|
|
16183
|
+
list = response.result;
|
|
16184
|
+
}
|
|
16185
|
+
list = list.sort(function (a, b) {
|
|
16186
|
+
return sortCallback('name', a, b);
|
|
16187
|
+
});
|
|
16188
|
+
return {
|
|
16189
|
+
code: response.code,
|
|
16190
|
+
status: response.status,
|
|
16191
|
+
result: list,
|
|
16192
|
+
};
|
|
16193
|
+
});
|
|
16194
|
+
};
|
|
16195
|
+
|
|
16132
16196
|
exports.BreadCrumb = BreadCrumb;
|
|
16133
16197
|
exports.BreadcrumbStore = Store;
|
|
16134
16198
|
exports.ClearIndicator = ClearIndicator;
|
|
@@ -16144,6 +16208,7 @@ exports.ErrorScreenManager = ErrorScreenManager;
|
|
|
16144
16208
|
exports.ErrorScreenNotAuthorized = ErrorScreenNotAuthorized;
|
|
16145
16209
|
exports.ForceDeleteDialog = ForceDeleteDialog;
|
|
16146
16210
|
exports.Host = Host;
|
|
16211
|
+
exports.InfoColourBar = InfoColourBar;
|
|
16147
16212
|
exports.Modal = Modal;
|
|
16148
16213
|
exports.MultiValueChipContainer = MultiValueChipContainer;
|
|
16149
16214
|
exports.MultiValueContainer = MultiValueContainer;
|
|
@@ -16153,6 +16218,7 @@ exports.Option = Option;
|
|
|
16153
16218
|
exports.PATTERNS = PATTERNS;
|
|
16154
16219
|
exports.PopupMenu = PopupMenu;
|
|
16155
16220
|
exports.Progressing = Progressing;
|
|
16221
|
+
exports.ROUTES = ROUTES;
|
|
16156
16222
|
exports.RadioGroup = RadioGroup;
|
|
16157
16223
|
exports.RadioGroupItem = RadioGroupItem;
|
|
16158
16224
|
exports.RequestTimeout = RequestTimeout;
|
|
@@ -16168,10 +16234,12 @@ exports.ToastBodyWithButton = ToastBodyWithButton;
|
|
|
16168
16234
|
exports.VisibleModal = VisibleModal;
|
|
16169
16235
|
exports.VisibleModal2 = VisibleModal2;
|
|
16170
16236
|
exports.get = get;
|
|
16237
|
+
exports.getTeamListMin = getTeamListMin;
|
|
16171
16238
|
exports.multiSelectStyles = multiSelectStyles;
|
|
16172
16239
|
exports.post = post;
|
|
16173
16240
|
exports.put = put;
|
|
16174
16241
|
exports.showError = showError;
|
|
16242
|
+
exports.sortCallback = sortCallback;
|
|
16175
16243
|
exports.toastAccessDenied = toastAccessDenied;
|
|
16176
16244
|
exports.trash = trash;
|
|
16177
16245
|
exports.useBreadcrumb = useBreadcrumb;
|
package/package.json
CHANGED
package/rollup.config.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { get } from './Api';
|
|
2
|
+
import { ROUTES } from './Constants'
|
|
3
|
+
import { sortCallback } from './Helper';
|
|
4
|
+
import { TeamList } from './Types';
|
|
5
|
+
|
|
6
|
+
export const getTeamListMin = (): Promise<TeamList> => {
|
|
7
|
+
// ignore active field
|
|
8
|
+
const URL = `${ROUTES.PROJECT_LIST_MIN}`;
|
|
9
|
+
return get(URL).then(response => {
|
|
10
|
+
let list = [];
|
|
11
|
+
if (response && response.result && Array.isArray(response.result)) {
|
|
12
|
+
list = response.result;
|
|
13
|
+
}
|
|
14
|
+
list = list.sort((a, b) => {
|
|
15
|
+
return sortCallback('name', a, b);
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
code: response.code,
|
|
19
|
+
status: response.status,
|
|
20
|
+
result: list,
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
};
|
package/src/Common/Constants.ts
CHANGED
|
@@ -6,4 +6,8 @@ export const PATTERNS = {
|
|
|
6
6
|
KUBERNETES_KEY_NAME: /^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$/,
|
|
7
7
|
START_END_ALPHANUMERIC: /^([Az09].*[A-Za-z0-9])$|[A-Za-z0-9]$/,
|
|
8
8
|
ALPHANUMERIC_WITH_SPECIAL_CHAR: /^[A-Za-z0-9._-]+$/, // allow alphanumeric,(.) ,(-),(_)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const ROUTES = {
|
|
12
|
+
PROJECT_LIST_MIN: 'team/autocomplete',
|
|
9
13
|
}
|
|
@@ -71,7 +71,7 @@ export const TagLabelValueSelector = ({
|
|
|
71
71
|
{field.messages.map((error) => (
|
|
72
72
|
<div key={error} className="flexbox p-4">
|
|
73
73
|
<span>
|
|
74
|
-
<ErrorCross className="fcr-5 mr-4" />
|
|
74
|
+
<ErrorCross className="icon-dim-16 fcr-5 mt-3 mr-4" />
|
|
75
75
|
</span>
|
|
76
76
|
<span>{error}</span>
|
|
77
77
|
</div>
|
|
@@ -79,7 +79,7 @@ export const TagLabelValueSelector = ({
|
|
|
79
79
|
{type === 'key' && (
|
|
80
80
|
<div className="flexbox p-4">
|
|
81
81
|
<span>
|
|
82
|
-
<Info className="mr-4" />
|
|
82
|
+
<Info className="icon-dim-16 mt-3 mr-4" />
|
|
83
83
|
</span>
|
|
84
84
|
<span className="dc__italic-font-style">Key format: prefix/name or name</span>
|
|
85
85
|
</div>
|
package/src/Common/Helper.tsx
CHANGED
|
@@ -1,39 +1,54 @@
|
|
|
1
|
-
import { ServerErrors } from
|
|
1
|
+
import { ServerErrors } from './ServerError'
|
|
2
2
|
import { toast } from 'react-toastify'
|
|
3
3
|
import * as Sentry from '@sentry/browser'
|
|
4
|
-
import { toastAccessDenied } from
|
|
5
|
-
|
|
4
|
+
import { toastAccessDenied } from './ToastBody'
|
|
6
5
|
|
|
7
6
|
export function showError(serverError, showToastOnUnknownError = true, hideAccessError = false) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
if (serverError instanceof ServerErrors && Array.isArray(serverError.errors)) {
|
|
8
|
+
serverError.errors.map(({ userMessage, internalMessage }) => {
|
|
9
|
+
if (serverError.code === 403 && userMessage === 'unauthorized') {
|
|
10
|
+
if (!hideAccessError) {
|
|
11
|
+
toastAccessDenied()
|
|
12
|
+
}
|
|
13
|
+
} else {
|
|
14
|
+
toast.error(userMessage || internalMessage)
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
} else {
|
|
18
|
+
if (serverError.code !== 403 && serverError.code !== 408) {
|
|
19
|
+
Sentry.captureException(serverError)
|
|
20
|
+
}
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
if (showToastOnUnknownError) {
|
|
23
|
+
if (serverError.message) {
|
|
24
|
+
toast.error(serverError.message)
|
|
25
|
+
} else {
|
|
26
|
+
toast.error('Some Error Occurred')
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
interface ConditionalWrapper<T> {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
condition: boolean
|
|
34
|
+
wrap: (children: T) => T
|
|
35
|
+
children: T
|
|
37
36
|
}
|
|
38
37
|
export const ConditionalWrap: React.FC<ConditionalWrapper<any>> = ({ condition, wrap, children }) =>
|
|
39
|
-
|
|
38
|
+
condition ? wrap(children) : <>{children}</>
|
|
39
|
+
|
|
40
|
+
export function sortCallback(key: string, a: any, b: any, isCaseSensitive?: boolean) {
|
|
41
|
+
let x = a[key]
|
|
42
|
+
let y = b[key]
|
|
43
|
+
if (isCaseSensitive) {
|
|
44
|
+
x = x.toLowerCase()
|
|
45
|
+
y = y.toLowerCase()
|
|
46
|
+
}
|
|
47
|
+
if (x < y) {
|
|
48
|
+
return -1
|
|
49
|
+
}
|
|
50
|
+
if (x > y) {
|
|
51
|
+
return 1
|
|
52
|
+
}
|
|
53
|
+
return 0
|
|
54
|
+
}
|
package/src/Common/Types.ts
CHANGED
|
@@ -53,4 +53,14 @@ export interface TagLabelValueSelectorType {
|
|
|
53
53
|
isRequired?: boolean
|
|
54
54
|
type?: string
|
|
55
55
|
placeholder?: string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface TeamList extends ResponseType {
|
|
59
|
+
result: Teams[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface Teams {
|
|
63
|
+
id: number;
|
|
64
|
+
name: string;
|
|
65
|
+
active: boolean;
|
|
56
66
|
}
|
package/src/Common/index.ts
CHANGED
|
@@ -21,4 +21,5 @@ export * from './TippyCustomized'
|
|
|
21
21
|
export * from './CustomTagSelector'
|
|
22
22
|
export * from './Dialogs'
|
|
23
23
|
export * from './MultiSelectCustomization'
|
|
24
|
-
export
|
|
24
|
+
export {default as InfoColourBar} from './InfoColorBar/InfoColourbar'
|
|
25
|
+
export * from './Common.service'
|