@devtron-labs/devtron-fe-common-lib 0.0.6-beta-25 → 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.
@@ -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,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { ResizableTagTextAreaProps } from '../Types';
2
+ import { ResizableTagTextAreaProps } from './Types';
3
3
  export declare function ResizableTagTextArea({ className, minHeight, maxHeight, value, onChange, onBlur, onFocus, placeholder, tabIndex, refVar, dependentRef, }: ResizableTagTextAreaProps): JSX.Element;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { TagDetailType } from '../Types';
3
- export default function TagDetails({ index, tagData, setTagData, removeTag, tabIndex, suggestedTagsOptions, }: TagDetailType): JSX.Element;
2
+ import { TagDetailType } from './Types';
3
+ export declare const TagDetails: ({ index, tagData, setTagData, removeTag, tabIndex, suggestedTagsOptions, }: TagDetailType) => JSX.Element;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { TagLabelSelectType } from '../Types';
3
- export declare const TagLabelSelect: ({ isCreateApp, labelTags, setLabelTags, tabIndex, suggestedTagsOptions, }: TagLabelSelectType) => JSX.Element;
2
+ import { TagLabelSelectType } from './Types';
3
+ export declare const TagLabelSelect: ({ isCreateApp, labelTags, setLabelTags, tabIndex }: TagLabelSelectType) => JSX.Element;
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { TagLabelValueSelectorType } from '../Types';
2
+ import { TagLabelValueSelectorType } from './Types';
3
3
  export declare const TagLabelValueSelector: ({ selectedTagIndex, tagData, setTagData, tagOptions, isRequired, tagInputType, placeholder, tabIndex, refVar, dependentRef, }: TagLabelValueSelectorType) => JSX.Element;
@@ -0,0 +1,59 @@
1
+ /// <reference types="react" />
2
+ import { KEY_VALUE } from '../Constants';
3
+ import { OptionType } from '../Types';
4
+ export interface TagType {
5
+ id?: number;
6
+ key: string;
7
+ value?: string;
8
+ description?: string;
9
+ propagate: boolean;
10
+ mandatoryProjectIdsCsv?: string;
11
+ isInvalidKey?: boolean;
12
+ isInvalidValue?: boolean;
13
+ isSuggested?: boolean;
14
+ }
15
+ export interface TagErrorType {
16
+ isValid: boolean;
17
+ messages: string[];
18
+ }
19
+ export interface TagLabelSelectType {
20
+ isCreateApp?: boolean;
21
+ labelTags: TagType[];
22
+ setLabelTags: (tagList: TagType[]) => void;
23
+ tabIndex?: number;
24
+ selectedProjectId?: number;
25
+ suggestedTagsOptions?: OptionType[];
26
+ }
27
+ export interface TagDetailType {
28
+ index: number;
29
+ tagData: TagType;
30
+ setTagData: (index: number, tagData: TagType) => void;
31
+ removeTag?: (index: number) => void;
32
+ tabIndex?: number;
33
+ suggestedTagsOptions?: OptionType[];
34
+ }
35
+ export interface TagLabelValueSelectorType {
36
+ selectedTagIndex: number;
37
+ tagData: TagType;
38
+ setTagData: (index: number, tagData: TagType) => void;
39
+ tagOptions?: OptionType[];
40
+ isRequired?: boolean;
41
+ tagInputType?: KEY_VALUE;
42
+ placeholder?: string;
43
+ tabIndex?: number;
44
+ refVar?: React.MutableRefObject<HTMLTextAreaElement>;
45
+ dependentRef?: React.MutableRefObject<HTMLTextAreaElement>;
46
+ }
47
+ export interface ResizableTagTextAreaProps {
48
+ className?: string;
49
+ minHeight?: number;
50
+ maxHeight?: number;
51
+ value?: string;
52
+ onChange?: (e: any) => void;
53
+ onBlur?: (e: any) => void;
54
+ onFocus?: (e: any) => void;
55
+ placeholder?: string;
56
+ tabIndex?: number;
57
+ refVar?: React.MutableRefObject<HTMLTextAreaElement>;
58
+ dependentRef?: React.MutableRefObject<HTMLTextAreaElement>;
59
+ }
@@ -1,3 +1,6 @@
1
+ export { default as PropagateTagInfo } from './PropagateTagInfo';
2
+ export * from './TagDetails';
1
3
  export * from './TagLabelSelect';
2
4
  export * from './TagLabelValueSelector';
3
5
  export * from './ResizableTagTextArea';
6
+ export * from './Types';
@@ -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 }: {
@@ -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: React.ReactChild;
13
+ subtitle?: React.ReactChild;
14
+ title?: string;
14
15
  subtitleClass?: string;
15
16
  }> {
16
17
  render(): JSX.Element;
@@ -1,5 +1,3 @@
1
- /// <reference types="react" />
2
- import { KEY_VALUE } from './Constants';
3
1
  export interface ResponseType {
4
2
  code: number;
5
3
  status: string;
@@ -19,61 +17,6 @@ export declare enum TippyTheme {
19
17
  black = "black",
20
18
  white = "white"
21
19
  }
22
- export interface TagType {
23
- id?: number;
24
- key: string;
25
- value?: string;
26
- description?: string;
27
- propagate: boolean;
28
- mandatoryProjectIdsCsv?: string;
29
- isInvalidKey?: boolean;
30
- isInvalidValue?: boolean;
31
- }
32
- export interface TagErrorType {
33
- isValid: boolean;
34
- messages: string[];
35
- }
36
- export interface TagLabelSelectType {
37
- isCreateApp?: boolean;
38
- labelTags: TagType[];
39
- setLabelTags: (tagList: TagType[]) => void;
40
- tabIndex?: number;
41
- selectedProjectId?: number;
42
- suggestedTagsOptions?: OptionType[];
43
- }
44
- export interface TagDetailType {
45
- index: number;
46
- tagData: TagType;
47
- setTagData: (index: number, tagData: TagType) => void;
48
- removeTag?: (index: number) => void;
49
- tabIndex?: number;
50
- suggestedTagsOptions?: OptionType[];
51
- }
52
- export interface TagLabelValueSelectorType {
53
- selectedTagIndex: number;
54
- tagData: TagType;
55
- setTagData: (index: number, tagData: TagType) => void;
56
- tagOptions?: OptionType[];
57
- isRequired?: boolean;
58
- tagInputType?: KEY_VALUE;
59
- placeholder?: string;
60
- tabIndex?: number;
61
- refVar?: React.MutableRefObject<HTMLTextAreaElement>;
62
- dependentRef?: React.MutableRefObject<HTMLTextAreaElement>;
63
- }
64
- export interface ResizableTagTextAreaProps {
65
- className?: string;
66
- minHeight?: number;
67
- maxHeight?: number;
68
- value?: string;
69
- onChange?: (e: any) => void;
70
- onBlur?: (e: any) => void;
71
- onFocus?: (e: any) => void;
72
- placeholder?: string;
73
- tabIndex?: number;
74
- refVar?: React.MutableRefObject<HTMLTextAreaElement>;
75
- dependentRef?: React.MutableRefObject<HTMLTextAreaElement>;
76
- }
77
20
  export interface TeamList extends ResponseType {
78
21
  result: Teams[];
79
22
  }
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
- 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]; }
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 = { key: '', value: '', propagate: false, isInvalidKey: false, isInvalidValue: false };
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$b() { _extends$b = 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$b.apply(this, arguments); }
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$b({
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", style: { width: '100%', height: '100%' } }, { children: children })));
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$a() {
517
- _extends$a = Object.assign || function (target) {
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$a.apply(this, arguments);
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$a({}, userStyle, {
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$a({}, style, {
1546
+ var containerStyle = !toastList.length ? _extends$9({}, style, {
1535
1547
  pointerEvents: 'none'
1536
- }) : _extends$a({}, style);
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$a({}, options, {
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$a({
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$a({}, options, pending));
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$a({
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$a({}, baseParams, params));
1718
+ toast.update(id, _extends$9({}, baseParams, params));
1707
1719
  } else {
1708
1720
  // using toast.promise without loading
1709
- toast(params.render, _extends$a({}, baseParams, params));
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$a({
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$a({}, oldOptions, options, {
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 (jsxRuntime.jsx(ErrorScreenNotAuthorized, { subtitle: this.props.subtitle, subtitleClass: this.props.subtitleClass }));
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
- return (jsxRuntime.jsxs(EmptyState, { 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: "Not authorized" })) }), jsxRuntime.jsx(EmptyState.Subtitle, __assign({ className: this.props.subtitleClass }, { children: this.props.subtitle
1985
- ? this.props.subtitle
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 && userMessage === 'unauthorized') {
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) {
@@ -8480,21 +8473,6 @@ function PropagateTagInfo(_a) {
8480
8473
  return (jsxRuntime.jsx(TippyCustomized, __assign({ theme: exports.TippyTheme.white, className: "w-300", placement: "top", Icon: SvgInjectTag, heading: 'Propagate tags to K8s resources', infoText: "", additionalContent: additionalInfo(), showCloseButton: true, trigger: "click", interactive: true, documentationLink: isCreateApp ? DOCUMENTATION.APP_TAGS : DOCUMENTATION.APP_OVERVIEW_TAGS, documentationLinkText: "View Documentation" }, { children: jsxRuntime.jsxs("div", __assign({ className: "flexbox cursor" }, { children: [jsxRuntime.jsx(SvgInjectTag, { className: "icon-dim-16 mt-2 mr-4" }), jsxRuntime.jsx("span", { children: "Propagate tags" }), jsxRuntime.jsx(SvgIcHelpOutline, { className: "icon-dim-16 mt-2 ml-4" })] })) })));
8481
8474
  }
8482
8475
 
8483
- var _path$2;
8484
- function _extends$5() { _extends$5 = 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$5.apply(this, arguments); }
8485
- var SvgIcAdd = function SvgIcAdd(props) {
8486
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$5({
8487
- xmlns: "http://www.w3.org/2000/svg",
8488
- width: "1em",
8489
- height: "1em",
8490
- viewBox: "0 0 24 24"
8491
- }, props), _path$2 || (_path$2 = /*#__PURE__*/React__namespace.createElement("path", {
8492
- className: "ic-add_svg__fill-color",
8493
- fill: "#999",
8494
- d: "M18 13h-5v5a1 1 0 0 1-2 0v-5H6a1 1 0 0 1 0-2h5V6a1 1 0 0 1 2 0v5h5a1 1 0 0 1 0 2z"
8495
- })));
8496
- };
8497
-
8498
8476
  var validateTagValue = function (value) {
8499
8477
  var errorList = [];
8500
8478
  if (value.length > 63) {
@@ -8555,15 +8533,15 @@ var ValidationRules = /** @class */ (function () {
8555
8533
  return ValidationRules;
8556
8534
  }());
8557
8535
 
8558
- var _path$1;
8559
- function _extends$4() { _extends$4 = 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$4.apply(this, arguments); }
8536
+ var _path$2;
8537
+ function _extends$5() { _extends$5 = 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$5.apply(this, arguments); }
8560
8538
  var SvgIcInfoOutlined = function SvgIcInfoOutlined(props) {
8561
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$4({
8539
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$5({
8562
8540
  xmlns: "http://www.w3.org/2000/svg",
8563
8541
  width: "1em",
8564
8542
  height: "1em",
8565
8543
  viewBox: "0 0 20 20"
8566
- }, props), _path$1 || (_path$1 = /*#__PURE__*/React__namespace.createElement("path", {
8544
+ }, props), _path$2 || (_path$2 = /*#__PURE__*/React__namespace.createElement("path", {
8567
8545
  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",
8568
8546
  fill: "#06C",
8569
8547
  fillRule: "evenodd"
@@ -8636,7 +8614,7 @@ var TagLabelValueSelector = function (_a) {
8636
8614
  ? !validationRules.propagateTagKey(selectedValue).isValid
8637
8615
  : _tagData.value !== '';
8638
8616
  }
8639
- else if (selectedValue) {
8617
+ else if (selectedValue || isRequired) {
8640
8618
  _tagData.isInvalidValue = !validationRules.propagateTagValue(selectedValue).isValid;
8641
8619
  _tagData.isInvalidKey = !_tagData.key || _tagData.isInvalidKey;
8642
8620
  }
@@ -8675,7 +8653,7 @@ var TagLabelValueSelector = function (_a) {
8675
8653
  if (tagOptions === null || tagOptions === void 0 ? void 0 : tagOptions.length) {
8676
8654
  var filteredTags = tagOptions.filter(function (tag) { return tag.value.indexOf(selectedValue) >= 0; });
8677
8655
  if (filteredTags.length) {
8678
- return (jsxRuntime.jsx("div", __assign({ className: "p-8" }, { children: filteredTags.map(function (tag, index) { return (jsxRuntime.jsx("div", __assign({ "data-key": tag.label, className: "cursor", onClick: onSelectValue }, { children: tag.label }), "".concat(tag.value, "-").concat(index))); }) })));
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))); }) }));
8679
8657
  }
8680
8658
  }
8681
8659
  return renderValidationsSuggestions();
@@ -8687,7 +8665,7 @@ var TagLabelValueSelector = function (_a) {
8687
8665
  : ''), value: selectedValue, onChange: handleInputChange, onBlur: handleOnBlur, onFocus: handleOnFocus, placeholder: placeholder, tabIndex: tabIndex, refVar: refVar, dependentRef: dependentRef }) })), jsxRuntime.jsx(PopupMenu.Body, __assign({ rootClassName: "tag-".concat(selectedTagIndex, "-class"), autoWidth: true, preventWheelDisable: true }, { children: activeElement === "tag-".concat(tagInputType, "-").concat(selectedTagIndex) && renderSuggestions() }))] })));
8688
8666
  };
8689
8667
 
8690
- function TagDetails(_a) {
8668
+ var TagDetails = function (_a) {
8691
8669
  var index = _a.index, tagData = _a.tagData, setTagData = _a.setTagData, removeTag = _a.removeTag, _b = _a.tabIndex, tabIndex = _b === void 0 ? 1 : _b, suggestedTagsOptions = _a.suggestedTagsOptions;
8692
8670
  var keyRef = React.useRef(null);
8693
8671
  var valueRef = React.useRef(null);
@@ -8700,11 +8678,26 @@ function TagDetails(_a) {
8700
8678
  _tagData.propagate = !_tagData.propagate;
8701
8679
  setTagData(index, _tagData);
8702
8680
  };
8703
- 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(SvgIcClose, { className: "icon-dim-20 mt-4" }) }))] })));
8704
- }
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" }) }))] })));
8682
+ };
8683
+
8684
+ var _path$1;
8685
+ function _extends$4() { _extends$4 = 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$4.apply(this, arguments); }
8686
+ var SvgIcAdd = function SvgIcAdd(props) {
8687
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$4({
8688
+ xmlns: "http://www.w3.org/2000/svg",
8689
+ width: "1em",
8690
+ height: "1em",
8691
+ viewBox: "0 0 24 24"
8692
+ }, props), _path$1 || (_path$1 = /*#__PURE__*/React__namespace.createElement("path", {
8693
+ className: "ic-add_svg__fill-color",
8694
+ fill: "#999",
8695
+ d: "M18 13h-5v5a1 1 0 0 1-2 0v-5H6a1 1 0 0 1 0-2h5V6a1 1 0 0 1 2 0v5h5a1 1 0 0 1 0 2z"
8696
+ })));
8697
+ };
8705
8698
 
8706
8699
  var TagLabelSelect = function (_a) {
8707
- var isCreateApp = _a.isCreateApp, labelTags = _a.labelTags, setLabelTags = _a.setLabelTags, _b = _a.tabIndex, tabIndex = _b === void 0 ? 0 : _b, suggestedTagsOptions = _a.suggestedTagsOptions;
8700
+ var isCreateApp = _a.isCreateApp, labelTags = _a.labelTags, setLabelTags = _a.setLabelTags, _b = _a.tabIndex, tabIndex = _b === void 0 ? 0 : _b;
8708
8701
  var setTagData = function (index, tagValue) {
8709
8702
  var _tags = __spreadArray([], __read(labelTags), false);
8710
8703
  _tags[index] = tagValue;
@@ -8720,7 +8713,7 @@ var TagLabelSelect = function (_a) {
8720
8713
  _tags.splice(index, 1);
8721
8714
  setLabelTags(_tags);
8722
8715
  };
8723
- return (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", __assign({ className: "flexbox dc__content-space mb-8" }, { children: [jsxRuntime.jsx("span", { children: "Tags" }), jsxRuntime.jsx(PropagateTagInfo, { isCreateApp: isCreateApp })] })), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", __assign({ className: "dc_width-max-content cb-5 fw-6 fs-13 flexbox mr-20 mb-8 cursor", onClick: addNewTag }, { children: [jsxRuntime.jsx(SvgIcAdd, { className: "icon-dim-20 fcb-5" }), " Add tag"] })), jsxRuntime.jsx("div", __assign({ className: "mb-8" }, { children: labelTags === null || labelTags === void 0 ? void 0 : labelTags.map(function (tagData, index) { return (jsxRuntime.jsx(TagDetails, { index: index, tagData: tagData, setTagData: setTagData, removeTag: removeTag, tabIndex: tabIndex + (index + 2), suggestedTagsOptions: suggestedTagsOptions }, "tag-".concat(index))); }) }))] })] }));
8716
+ return (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", __assign({ className: "flexbox dc__content-space mb-8" }, { children: [jsxRuntime.jsx("span", { children: "Tags" }), jsxRuntime.jsx(PropagateTagInfo, { isCreateApp: isCreateApp })] })), jsxRuntime.jsxs("div", { children: [jsxRuntime.jsxs("div", __assign({ className: "dc_width-max-content cb-5 fw-6 fs-13 flexbox mr-20 mb-8 cursor", onClick: addNewTag }, { children: [jsxRuntime.jsx(SvgIcAdd, { className: "icon-dim-20 fcb-5" }), " Add tag"] })), jsxRuntime.jsx("div", __assign({ className: "mb-8" }, { children: labelTags === null || labelTags === void 0 ? void 0 : labelTags.map(function (tagData, index) { return (jsxRuntime.jsx(TagDetails, { index: index, tagData: tagData, setTagData: setTagData, removeTag: removeTag, tabIndex: tabIndex + (index + 2) }, "tag-".concat(index))); }) }))] })] }));
8724
8717
  };
8725
8718
 
8726
8719
  function ConfirmationDialog(_a) {
@@ -16391,6 +16384,7 @@ exports.Option = Option;
16391
16384
  exports.PATTERNS = PATTERNS;
16392
16385
  exports.PopupMenu = PopupMenu;
16393
16386
  exports.Progressing = Progressing;
16387
+ exports.PropagateTagInfo = PropagateTagInfo;
16394
16388
  exports.ROUTES = ROUTES;
16395
16389
  exports.RadioGroup = RadioGroup;
16396
16390
  exports.RadioGroupItem = RadioGroupItem;
@@ -16400,6 +16394,7 @@ exports.ServerError = ServerError;
16400
16394
  exports.ServerErrors = ServerErrors;
16401
16395
  exports.SingleSelectOption = SingleSelectOption;
16402
16396
  exports.TOAST_ACCESS_DENIED = TOAST_ACCESS_DENIED;
16397
+ exports.TagDetails = TagDetails;
16403
16398
  exports.TagLabelSelect = TagLabelSelect;
16404
16399
  exports.TagLabelValueSelector = TagLabelValueSelector;
16405
16400
  exports.TippyCustomized = TippyCustomized;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.6-beta-25",
3
+ "version": "0.0.7-beta-1",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -8,31 +8,44 @@ export const DOCUMENTATION = {
8
8
  }
9
9
 
10
10
  export const PATTERNS = {
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,(.) ,(-),(_)
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
- PROJECT_LIST_MIN: 'team/autocomplete',
18
+ PROJECT_LIST_MIN: 'team/autocomplete',
19
19
  }
20
20
 
21
21
  export enum KEY_VALUE {
22
- KEY= 'key',
23
- VALUE= 'value'
22
+ KEY = 'key',
23
+ VALUE = 'value',
24
24
  }
25
25
 
26
- export const DEFAULT_TAG_DATA = { key: '', value: '', propagate: false, isInvalidKey: false, isInvalidValue: false }
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
- TITLE: 'Access denied',
30
- SUBTITLE: 'You do not have required access to perform this action',
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
- PAGE_NOT_FOUND: 'We could not find this page',
36
- PAGE_NOT_EXIST: 'This page doesn’t exist or was removed. We suggest you go back to home',
37
- TAKE_BACK_HOME: 'Take me home',
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,6 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
  import { useThrottledEffect } from '../Helper'
3
- import { ResizableTagTextAreaProps } from '../Types'
3
+ import { ResizableTagTextAreaProps } from './Types'
4
4
 
5
5
  export function ResizableTagTextArea({
6
6
  className,
@@ -1,19 +1,19 @@
1
1
  import React, { useRef } from 'react'
2
- import { ReactComponent as DeleteCross } from '../../Assets/Icon/ic-close.svg'
2
+ import { ReactComponent as DeleteCross } from '../../Assets/Icon/ic-cross.svg'
3
3
  import { ReactComponent as InjectTag } from '../../Assets/Icon/inject-tag.svg'
4
- import { TagDetailType } from '../Types'
5
4
  import { TagLabelValueSelector } from './TagLabelValueSelector'
6
5
  import { KEY_VALUE } from '../Constants'
7
6
  import { stopPropagation } from '../Helper'
7
+ import { TagDetailType } from './Types'
8
8
 
9
- export default function TagDetails({
9
+ export const TagDetails = ({
10
10
  index,
11
11
  tagData,
12
12
  setTagData,
13
13
  removeTag,
14
14
  tabIndex = 1,
15
15
  suggestedTagsOptions,
16
- }: TagDetailType) {
16
+ }: TagDetailType) => {
17
17
  const keyRef = useRef(null)
18
18
  const valueRef = useRef(null)
19
19
 
@@ -1,16 +1,15 @@
1
1
  import React from 'react'
2
2
  import PropagateTagInfo from './PropagateTagInfo'
3
3
  import { ReactComponent as Add } from '../../Assets/Icon/ic-add.svg'
4
- import TagDetails from './TagDetails'
5
- import { TagLabelSelectType } from '../Types'
6
4
  import { DEFAULT_TAG_DATA } from '../Constants'
5
+ import { TagLabelSelectType } from './Types'
6
+ import { TagDetails } from './TagDetails'
7
7
 
8
8
  export const TagLabelSelect = ({
9
9
  isCreateApp,
10
10
  labelTags,
11
11
  setLabelTags,
12
- tabIndex = 0,
13
- suggestedTagsOptions,
12
+ tabIndex = 0
14
13
  }: TagLabelSelectType) => {
15
14
  const setTagData = (index, tagValue): void => {
16
15
  const _tags = [...labelTags]
@@ -49,7 +48,6 @@ export const TagLabelSelect = ({
49
48
  setTagData={setTagData}
50
49
  removeTag={removeTag}
51
50
  tabIndex={tabIndex + (index + 2)}
52
- suggestedTagsOptions={suggestedTagsOptions}
53
51
  />
54
52
  ))}
55
53
  </div>
@@ -1,5 +1,4 @@
1
1
  import React, { useState, useEffect } from 'react'
2
- import { TagLabelValueSelectorType } from '../Types'
3
2
  import PopupMenu from '../PopupMenu'
4
3
  import { ValidationRules } from './ValidationRules'
5
4
  import { ReactComponent as ErrorCross } from '../../Assets/Icon/ic-cross.svg'
@@ -7,6 +6,7 @@ import { ReactComponent as Info } from '../../Assets/Icon/ic-info-outlined.svg'
7
6
  import { KEY_VALUE } from '../Constants'
8
7
  import { stopPropagation } from '../Helper'
9
8
  import { ResizableTagTextArea } from './ResizableTagTextArea'
9
+ import { TagLabelValueSelectorType } from './Types'
10
10
 
11
11
  export const TagLabelValueSelector = ({
12
12
  selectedTagIndex,
@@ -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 {
@@ -107,12 +107,12 @@ export const TagLabelValueSelector = ({
107
107
  const filteredTags = tagOptions.filter((tag) => tag.value.indexOf(selectedValue) >= 0)
108
108
  if (filteredTags.length) {
109
109
  return (
110
- <div className="p-8">
110
+ <div>
111
111
  {filteredTags.map((tag, index) => (
112
112
  <div
113
113
  key={`${tag.value}-${index}`}
114
114
  data-key={tag.label}
115
- className="cursor"
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}
@@ -0,0 +1,63 @@
1
+ import { KEY_VALUE } from '../Constants'
2
+ import { OptionType } from '../Types'
3
+
4
+ export interface TagType {
5
+ id?: number
6
+ key: string
7
+ value?: string
8
+ description?: string
9
+ propagate: boolean
10
+ mandatoryProjectIdsCsv?: string
11
+ isInvalidKey?: boolean
12
+ isInvalidValue?: boolean
13
+ isSuggested?: boolean
14
+ }
15
+
16
+ export interface TagErrorType {
17
+ isValid: boolean
18
+ messages: string[]
19
+ }
20
+ export interface TagLabelSelectType {
21
+ isCreateApp?: boolean
22
+ labelTags: TagType[]
23
+ setLabelTags: (tagList: TagType[]) => void
24
+ tabIndex?: number
25
+ selectedProjectId?: number
26
+ suggestedTagsOptions?: OptionType[]
27
+ }
28
+
29
+ export interface TagDetailType {
30
+ index: number
31
+ tagData: TagType
32
+ setTagData: (index: number, tagData: TagType) => void
33
+ removeTag?: (index: number) => void
34
+ tabIndex?: number
35
+ suggestedTagsOptions?: OptionType[]
36
+ }
37
+
38
+ export interface TagLabelValueSelectorType {
39
+ selectedTagIndex: number
40
+ tagData: TagType
41
+ setTagData: (index: number, tagData: TagType) => void
42
+ tagOptions?: OptionType[]
43
+ isRequired?: boolean
44
+ tagInputType?: KEY_VALUE
45
+ placeholder?: string
46
+ tabIndex?: number
47
+ refVar?: React.MutableRefObject<HTMLTextAreaElement>
48
+ dependentRef?: React.MutableRefObject<HTMLTextAreaElement>
49
+ }
50
+
51
+ export interface ResizableTagTextAreaProps {
52
+ className?: string
53
+ minHeight?: number
54
+ maxHeight?: number
55
+ value?: string
56
+ onChange?: (e) => void
57
+ onBlur?: (e) => void
58
+ onFocus?: (e) => void
59
+ placeholder?: string
60
+ tabIndex?: number
61
+ refVar?: React.MutableRefObject<HTMLTextAreaElement>
62
+ dependentRef?: React.MutableRefObject<HTMLTextAreaElement>
63
+ }
@@ -1,3 +1,6 @@
1
+ export {default as PropagateTagInfo} from './PropagateTagInfo'
2
+ export * from './TagDetails'
1
3
  export * from './TagLabelSelect'
2
4
  export * from './TagLabelValueSelector'
3
- export * from './ResizableTagTextArea'
5
+ export * from './ResizableTagTextArea'
6
+ export * from './Types'
@@ -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="flex column empty-state" style={{ width: '100%', height: '100%' }}>
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, className?: string}) {
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 }) {
@@ -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<{ subtitle: React.ReactChild; subtitleClass?: string }> {
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">Not authorized</h3>
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
+ }
@@ -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
- if (serverError instanceof ServerErrors && Array.isArray(serverError.errors)) {
9
- serverError.errors.map(({ userMessage, internalMessage }) => {
10
- if (serverError.code === 403 && userMessage === 'unauthorized') {
11
- if (!hideAccessError) {
12
- toastAccessDenied()
13
- }
14
- } else {
15
- toast.error(userMessage || internalMessage)
16
- }
17
- })
18
- } else {
19
- if (serverError.code !== 403 && serverError.code !== 408) {
20
- Sentry.captureException(serverError)
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
- if (showToastOnUnknownError) {
24
- if (serverError.message) {
25
- toast.error(serverError.message)
26
- } else {
27
- toast.error('Some Error Occurred')
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> {
@@ -1,5 +1,3 @@
1
- import { KEY_VALUE } from './Constants'
2
-
3
1
  export interface ResponseType {
4
2
  code: number
5
3
  status: string
@@ -22,67 +20,6 @@ export enum TippyTheme {
22
20
  black = 'black',
23
21
  white = 'white',
24
22
  }
25
-
26
- export interface TagType {
27
- id?: number
28
- key: string
29
- value?: string
30
- description?: string
31
- propagate: boolean
32
- mandatoryProjectIdsCsv?: string
33
- isInvalidKey?: boolean
34
- isInvalidValue?: boolean
35
- }
36
-
37
- export interface TagErrorType {
38
- isValid: boolean
39
- messages: string[]
40
- }
41
- export interface TagLabelSelectType {
42
- isCreateApp?: boolean
43
- labelTags: TagType[]
44
- setLabelTags: (tagList: TagType[]) => void
45
- tabIndex?: number
46
- selectedProjectId?: number
47
- suggestedTagsOptions?: OptionType[]
48
- }
49
-
50
- export interface TagDetailType {
51
- index: number
52
- tagData: TagType
53
- setTagData: (index: number, tagData: TagType) => void
54
- removeTag?: (index: number) => void
55
- tabIndex?: number
56
- suggestedTagsOptions?: OptionType[]
57
- }
58
-
59
- export interface TagLabelValueSelectorType {
60
- selectedTagIndex: number
61
- tagData: TagType
62
- setTagData: (index: number, tagData: TagType) => void
63
- tagOptions?: OptionType[]
64
- isRequired?: boolean
65
- tagInputType?: KEY_VALUE
66
- placeholder?: string
67
- tabIndex?: number
68
- refVar?: React.MutableRefObject<HTMLTextAreaElement>
69
- dependentRef?: React.MutableRefObject<HTMLTextAreaElement>
70
- }
71
-
72
- export interface ResizableTagTextAreaProps {
73
- className?: string
74
- minHeight?: number
75
- maxHeight?: number
76
- value?: string
77
- onChange?: (e) => void
78
- onBlur?: (e) => void
79
- onFocus?: (e) => void
80
- placeholder?: string
81
- tabIndex?: number
82
- refVar?: React.MutableRefObject<HTMLTextAreaElement>
83
- dependentRef?: React.MutableRefObject<HTMLTextAreaElement>
84
- }
85
-
86
23
  export interface TeamList extends ResponseType {
87
24
  result: Teams[]
88
25
  }