@devtron-labs/devtron-fe-common-lib 0.0.7-beta-36 → 0.0.7-beta-38

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.
@@ -43,3 +43,8 @@ export declare const ERROR_EMPTY_SCREEN: {
43
43
  FORBIDDEN: string;
44
44
  REQUIRED_MANAGER_ACCESS: string;
45
45
  };
46
+ export declare const TOKEN_COOKIE_NAME = "argocd.token";
47
+ export declare const TriggerTypeMap: {
48
+ automatic: string;
49
+ manual: string;
50
+ };
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  export declare function showError(serverError: any, showToastOnUnknownError?: boolean, hideAccessError?: boolean): void;
3
3
  interface ConditionalWrapper<T> {
4
4
  condition: boolean;
@@ -9,4 +9,12 @@ export declare const ConditionalWrap: React.FC<ConditionalWrapper<any>>;
9
9
  export declare function sortCallback(key: string, a: any, b: any, isCaseSensitive?: boolean): 1 | -1 | 0;
10
10
  export declare const stopPropagation: (event: any) => void;
11
11
  export declare function useThrottledEffect(callback: any, delay: any, deps?: any[]): void;
12
+ export declare function getRandomColor(email: string): string;
13
+ export declare const getAlphabetIcon: (str: string) => JSX.Element;
14
+ export declare const getEmptyArrayOfLength: (length: number) => unknown[];
15
+ export declare function noop(...args: any[]): any;
16
+ export declare function not(e: any): boolean;
17
+ export declare function useEffectAfterMount(cb: any, dependencies: any): void;
18
+ export declare function getCookie(sKey: any): string;
19
+ export declare function getLoginInfo(): any;
12
20
  export {};
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import './radioGroup.scss';
3
+ interface RadioGroupInterface {
4
+ name: string;
5
+ onChange: any;
6
+ className?: string;
7
+ initialTab: string;
8
+ disabled: boolean;
9
+ showTippy?: boolean;
10
+ tippyContent?: any;
11
+ dataTestId?: string;
12
+ }
13
+ interface RadioGroupComposition {
14
+ Radio?: React.FC<any>;
15
+ }
16
+ declare const RadioGroup: React.FC<RadioGroupInterface> & RadioGroupComposition;
17
+ export default RadioGroup;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { ScanVulnerabilitiesTableProps } from '../Types';
3
+ import './scanVulnerabilities.css';
4
+ export default function ScanVulnerabilitiesTable({ vulnerabilities }: ScanVulnerabilitiesTableProps): JSX.Element;
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import './Toggle.scss';
3
+ declare const Toggle: ({ selected, onSelect, color, rootClassName, disabled, dataTestId, ...props }: {
4
+ [x: string]: any;
5
+ selected?: boolean;
6
+ onSelect?: any;
7
+ color?: string;
8
+ rootClassName?: string;
9
+ disabled?: boolean;
10
+ dataTestId?: string;
11
+ }) => JSX.Element;
12
+ export default Toggle;
@@ -158,3 +158,134 @@ export interface ModalType {
158
158
  preventWheelDisable?: boolean;
159
159
  noBackDrop?: boolean;
160
160
  }
161
+ export type CDModalTabType = 'SECURITY' | 'CHANGES';
162
+ export declare const CDModalTab: {
163
+ Security: CDModalTabType;
164
+ Changes: CDModalTabType;
165
+ };
166
+ export declare enum DeploymentNodeType {
167
+ PRECD = "PRECD",
168
+ CD = "CD",
169
+ POSTCD = "POSTCD",
170
+ APPROVAL = "APPROVAL"
171
+ }
172
+ export interface UserApprovalConfigType {
173
+ requiredCount: number;
174
+ }
175
+ interface ApprovalUserDataType {
176
+ dataId: number;
177
+ userActionTime: string;
178
+ userComment: string;
179
+ userEmail: string;
180
+ userId: number;
181
+ userResponse: number;
182
+ }
183
+ export interface UserApprovalMetadataType {
184
+ approvalRequestId: number;
185
+ approvalRuntimeState: number;
186
+ approvedUsersData: ApprovalUserDataType[];
187
+ requestedUserData: ApprovalUserDataType;
188
+ }
189
+ export interface CommonNodeAttr {
190
+ connectingCiPipelineId?: number;
191
+ parents: string | number[] | string[];
192
+ x: number;
193
+ y: number;
194
+ title: string;
195
+ description?: string;
196
+ triggerType?: string;
197
+ id: string;
198
+ icon?: string;
199
+ status?: string;
200
+ isSource: boolean;
201
+ isGitSource: boolean;
202
+ isRoot: boolean;
203
+ downstreams: string[];
204
+ type: 'CI' | 'GIT' | 'PRECD' | 'CD' | 'POSTCD' | 'WEBHOOK';
205
+ parentCiPipeline?: number;
206
+ parentAppId?: number;
207
+ url?: string;
208
+ branch?: string;
209
+ sourceType?: string;
210
+ colorCode?: string;
211
+ isExternalCI?: boolean;
212
+ isLinkedCI?: boolean;
213
+ environmentName?: string;
214
+ environmentId?: number;
215
+ inputMaterialList?: any[];
216
+ rollbackMaterialList?: any[];
217
+ linkedCount?: number;
218
+ deploymentStrategy?: string;
219
+ height: number;
220
+ width: number;
221
+ preNode?: CommonNodeAttr;
222
+ postNode?: CommonNodeAttr;
223
+ stageIndex?: number;
224
+ sourceNodes?: Array<CommonNodeAttr>;
225
+ downstreamNodes?: Array<CommonNodeAttr>;
226
+ parentPipelineId?: string;
227
+ parentPipelineType?: string;
228
+ parentEnvironmentName?: string;
229
+ isRegex?: boolean;
230
+ regex?: string;
231
+ primaryBranchAfterRegex?: string;
232
+ storageConfigured?: boolean;
233
+ deploymentAppDeleteRequest?: boolean;
234
+ approvalUsers?: string[];
235
+ userApprovalConfig?: UserApprovalConfigType;
236
+ requestedUserId?: number;
237
+ }
238
+ export interface VulnerabilityType {
239
+ name: string;
240
+ severity: "CRITICAL" | "MODERATE" | "LOW";
241
+ package: string;
242
+ version: string;
243
+ fixedVersion: string;
244
+ policy: string;
245
+ url?: string;
246
+ }
247
+ export interface ScanVulnerabilitiesTableProps {
248
+ vulnerabilities: VulnerabilityType[];
249
+ }
250
+ export interface MaterialInfo {
251
+ revision: string;
252
+ modifiedTime: string | Date;
253
+ author: string;
254
+ message: string;
255
+ commitLink: string;
256
+ tag: string;
257
+ webhookData: string;
258
+ branch: string;
259
+ url?: string;
260
+ type?: string;
261
+ }
262
+ export interface CDMaterialType {
263
+ index: number;
264
+ id: string;
265
+ materialInfo: MaterialInfo[];
266
+ tab: CDModalTabType;
267
+ scanEnabled: boolean;
268
+ scanned: boolean;
269
+ vulnerabilitiesLoading: boolean;
270
+ lastExecution: string;
271
+ vulnerabilities: VulnerabilityType[];
272
+ vulnerable: boolean;
273
+ deployedTime: string;
274
+ deployedBy?: string;
275
+ wfrId?: number;
276
+ buildTime: string;
277
+ image: string;
278
+ isSelected: boolean;
279
+ showSourceInfo: boolean;
280
+ latest: boolean;
281
+ runningOnParentCd?: boolean;
282
+ userApprovalMetadata?: UserApprovalMetadataType;
283
+ triggeredBy?: number;
284
+ }
285
+ export interface CDMaterialResponseType {
286
+ approvalUsers: string[];
287
+ materials: any[];
288
+ userApprovalConfig: UserApprovalConfigType;
289
+ requestedUserId: number;
290
+ }
291
+ export {};
@@ -26,3 +26,6 @@ export * from './Common.service';
26
26
  export * from './Checkbox';
27
27
  export { default as EmptyState } from './EmptyState/EmptyState';
28
28
  export { default as GenericEmptyState } from './EmptyState/GenericEmptyState';
29
+ export { default as Toggle } from './Toggle/Toggle';
30
+ export { default as ScanVulnerabilitiesTable } from './Security/ScanVulnerabilitiesTable';
31
+ export * as StyledRadioGroup from './RadioGroup/RadioGroup';
package/dist/index.js CHANGED
@@ -70,6 +70,11 @@ var ERROR_EMPTY_SCREEN = {
70
70
  UNAUTHORIZED: 'unauthorized',
71
71
  FORBIDDEN: 'forbidden',
72
72
  REQUIRED_MANAGER_ACCESS: 'Looks like you don’t have access to information on this page. Please contact your manager to request access.',
73
+ };
74
+ var TOKEN_COOKIE_NAME = 'argocd.token';
75
+ var TriggerTypeMap = {
76
+ automatic: 'Auto',
77
+ manual: 'Manual',
73
78
  };
74
79
 
75
80
  /******************************************************************************
@@ -232,7 +237,18 @@ exports.ImageType = void 0;
232
237
  (function (ImageType) {
233
238
  ImageType["Large"] = "large";
234
239
  ImageType["Medium"] = "medium";
235
- })(exports.ImageType || (exports.ImageType = {}));
240
+ })(exports.ImageType || (exports.ImageType = {}));
241
+ var CDModalTab = {
242
+ Security: 'SECURITY',
243
+ Changes: 'CHANGES',
244
+ };
245
+ exports.DeploymentNodeType = void 0;
246
+ (function (DeploymentNodeType) {
247
+ DeploymentNodeType["PRECD"] = "PRECD";
248
+ DeploymentNodeType["CD"] = "CD";
249
+ DeploymentNodeType["POSTCD"] = "POSTCD";
250
+ DeploymentNodeType["APPROVAL"] = "APPROVAL";
251
+ })(exports.DeploymentNodeType || (exports.DeploymentNodeType = {}));
236
252
 
237
253
  var responseMessages = {
238
254
  100: 'Continue',
@@ -484,8 +500,8 @@ function styleInject(css, ref) {
484
500
  }
485
501
  }
486
502
 
487
- var css_248z$3 = ".empty-state {\n height: 100%;\n}\n.empty-state img {\n height: 40%;\n max-height: 200px;\n width: auto;\n max-width: 250px;\n}\n.empty-state svg {\n height: 40%;\n max-height: 200px;\n width: auto;\n}\n.empty-state h1,\n.empty-state h2,\n.empty-state h3,\n.empty-state h4,\n.empty-state h5,\n.empty-state h6 {\n color: var(--N900);\n}\n.empty-state .subtitle {\n font-size: 13px;\n width: 300px;\n font-weight: 400;\n text-align: center;\n line-height: 1.5;\n margin-bottom: 20px;\n}\n.empty-state .cta {\n height: 36px;\n}\n.empty-state p {\n width: 300px;\n text-align: center;\n font-size: 13px;\n color: var(--N700);\n}\n.empty-state strong {\n font-size: 16px;\n margin-bottom: 4px;\n color: var(--N900);\n font-weight: normal;\n}\n.empty-state .select-popup {\n height: min-content;\n max-height: 250px;\n overflow: auto;\n padding: 8px 0;\n}\n.empty-state .empty-state__loader {\n width: 34px;\n height: 34px;\n margin-bottom: 16px;\n}\n.empty-state .empty-state__loading-text {\n font-size: 12px;\n width: 200px;\n font-weight: normal;\n font-stretch: normal;\n font-style: normal;\n line-height: 1.5;\n letter-spacing: normal;\n text-align: center;\n color: var(--N900);\n}\n.empty-state .button__icon {\n width: 16px;\n height: 16px;\n margin-left: 8px;\n}";
488
- styleInject(css_248z$3);
503
+ var css_248z$6 = ".empty-state {\n height: 100%;\n}\n.empty-state img {\n height: 40%;\n max-height: 200px;\n width: auto;\n max-width: 250px;\n}\n.empty-state svg {\n height: 40%;\n max-height: 200px;\n width: auto;\n}\n.empty-state h1,\n.empty-state h2,\n.empty-state h3,\n.empty-state h4,\n.empty-state h5,\n.empty-state h6 {\n color: var(--N900);\n}\n.empty-state .subtitle {\n font-size: 13px;\n width: 300px;\n font-weight: 400;\n text-align: center;\n line-height: 1.5;\n margin-bottom: 20px;\n}\n.empty-state .cta {\n height: 36px;\n}\n.empty-state p {\n width: 300px;\n text-align: center;\n font-size: 13px;\n color: var(--N700);\n}\n.empty-state strong {\n font-size: 16px;\n margin-bottom: 4px;\n color: var(--N900);\n font-weight: normal;\n}\n.empty-state .select-popup {\n height: min-content;\n max-height: 250px;\n overflow: auto;\n padding: 8px 0;\n}\n.empty-state .empty-state__loader {\n width: 34px;\n height: 34px;\n margin-bottom: 16px;\n}\n.empty-state .empty-state__loading-text {\n font-size: 12px;\n width: 200px;\n font-weight: normal;\n font-stretch: normal;\n font-style: normal;\n line-height: 1.5;\n letter-spacing: normal;\n text-align: center;\n color: var(--N900);\n}\n.empty-state .button__icon {\n width: 16px;\n height: 16px;\n margin-left: 8px;\n}";
504
+ styleInject(css_248z$6);
489
505
 
490
506
  var _g$2;
491
507
  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); }
@@ -3989,6 +4005,66 @@ function useThrottledEffect(callback, delay, deps) {
3989
4005
  clearTimeout(handler);
3990
4006
  };
3991
4007
  }, __spreadArray([delay], __read(deps), false));
4008
+ }
4009
+ var colors$1 = [
4010
+ '#FFB900',
4011
+ '#D83B01',
4012
+ '#B50E0E',
4013
+ '#E81123',
4014
+ '#B4009E',
4015
+ '#5C2D91',
4016
+ '#0078D7',
4017
+ '#00B4FF',
4018
+ '#008272',
4019
+ '#107C10',
4020
+ ];
4021
+ function getRandomColor(email) {
4022
+ var sum = 0;
4023
+ for (var i = 0; i < email.length; i++) {
4024
+ sum += email.charCodeAt(i);
4025
+ }
4026
+ return colors$1[sum % colors$1.length];
4027
+ }
4028
+ var getAlphabetIcon = function (str) {
4029
+ if (!str)
4030
+ return null;
4031
+ return (jsxRuntime.jsx("span", __assign({ className: "alphabet-icon__initial fs-13 icon-dim-20 flex cn-0 mr-8", style: { backgroundColor: getRandomColor(str) } }, { children: str[0] })));
4032
+ };
4033
+ var getEmptyArrayOfLength = function (length) {
4034
+ return Array.from({ length: length });
4035
+ };
4036
+ function noop$1() {
4037
+ }
4038
+ function not(e) {
4039
+ return !e;
4040
+ }
4041
+ function useEffectAfterMount(cb, dependencies) {
4042
+ var justMounted = React.useRef(true);
4043
+ React.useEffect(function () {
4044
+ if (!justMounted.current) {
4045
+ return cb();
4046
+ }
4047
+ justMounted.current = false;
4048
+ }, dependencies);
4049
+ }
4050
+ function getCookie(sKey) {
4051
+ if (!sKey) {
4052
+ return null;
4053
+ }
4054
+ return (document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + sKey.replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1') || null);
4055
+ }
4056
+ function getLoginInfo() {
4057
+ var argocdToken = getCookie(TOKEN_COOKIE_NAME);
4058
+ if (argocdToken) {
4059
+ var jwts = argocdToken.split('.');
4060
+ try {
4061
+ return JSON.parse(atob(jwts[1]));
4062
+ }
4063
+ catch (err) {
4064
+ console.error('error in setting user ', err);
4065
+ return null;
4066
+ }
4067
+ }
3992
4068
  }
3993
4069
 
3994
4070
  function Progressing(_a) {
@@ -4041,8 +4117,8 @@ var VisibleModal = /** @class */ (function (_super) {
4041
4117
  return VisibleModal;
4042
4118
  }(React.Component));
4043
4119
 
4044
- var css_248z$2 = ".drawer {\n position: absolute;\n overflow: hidden;\n}\n.drawer.left, .drawer.right {\n top: 0;\n bottom: 0;\n width: 0;\n transition: width 200ms;\n}\n.drawer.left.show, .drawer.right.show {\n min-width: var(--minWidth);\n width: var(--width);\n max-width: var(--maxWidth);\n}\n.drawer.top, .drawer.bottom {\n left: 0;\n right: 0;\n height: 0;\n transition: height 200ms;\n}\n.drawer.top.show, .drawer.bottom.show {\n height: var(--height);\n}\n.drawer.right {\n right: 0;\n}\n.drawer.left {\n left: 0;\n}\n.drawer.top {\n top: 0;\n}\n.drawer.bottom {\n bottom: 0;\n}";
4045
- styleInject(css_248z$2);
4120
+ var css_248z$5 = ".drawer {\n position: absolute;\n overflow: hidden;\n}\n.drawer.left, .drawer.right {\n top: 0;\n bottom: 0;\n width: 0;\n transition: width 200ms;\n}\n.drawer.left.show, .drawer.right.show {\n min-width: var(--minWidth);\n width: var(--width);\n max-width: var(--maxWidth);\n}\n.drawer.top, .drawer.bottom {\n left: 0;\n right: 0;\n height: 0;\n transition: height 200ms;\n}\n.drawer.top.show, .drawer.bottom.show {\n height: var(--height);\n}\n.drawer.right {\n right: 0;\n}\n.drawer.left {\n left: 0;\n}\n.drawer.top {\n top: 0;\n}\n.drawer.bottom {\n bottom: 0;\n}";
4121
+ styleInject(css_248z$5);
4046
4122
 
4047
4123
  var Drawer = function (_a) {
4048
4124
  var children = _a.children, position = _a.position, height = _a.height, width = _a.width, minWidth = _a.minWidth, maxWidth = _a.maxWidth, parentClassName = _a.parentClassName, onEscape = _a.onEscape;
@@ -4280,7 +4356,7 @@ var RadioGroupItem = /** @class */ (function (_super) {
4280
4356
  };
4281
4357
  return RadioGroupItem;
4282
4358
  }(React.Component));
4283
- var RadioGroup = /** @class */ (function (_super) {
4359
+ var RadioGroup$2 = /** @class */ (function (_super) {
4284
4360
  __extends(RadioGroup, _super);
4285
4361
  function RadioGroup() {
4286
4362
  return _super !== null && _super.apply(this, arguments) || this;
@@ -8424,8 +8500,8 @@ var index = /*#__PURE__*/forwardRef( /*#__PURE__*/TippyGenerator(tippy));
8424
8500
 
8425
8501
  var Tippy = index;
8426
8502
 
8427
- var css_248z$1 = ".tippy-box[data-animation=shift-toward-subtle][data-state=hidden]{opacity:0}.tippy-box[data-animation=shift-toward-subtle][data-state=hidden][data-placement^=top][data-state=hidden]{transform:translateY(-5px)}.tippy-box[data-animation=shift-toward-subtle][data-state=hidden][data-placement^=bottom][data-state=hidden]{transform:translateY(5px)}.tippy-box[data-animation=shift-toward-subtle][data-state=hidden][data-placement^=left][data-state=hidden]{transform:translateX(-5px)}.tippy-box[data-animation=shift-toward-subtle][data-state=hidden][data-placement^=right][data-state=hidden]{transform:translateX(5px)}";
8428
- styleInject(css_248z$1);
8503
+ var css_248z$4 = ".tippy-box[data-animation=shift-toward-subtle][data-state=hidden]{opacity:0}.tippy-box[data-animation=shift-toward-subtle][data-state=hidden][data-placement^=top][data-state=hidden]{transform:translateY(-5px)}.tippy-box[data-animation=shift-toward-subtle][data-state=hidden][data-placement^=bottom][data-state=hidden]{transform:translateY(5px)}.tippy-box[data-animation=shift-toward-subtle][data-state=hidden][data-placement^=left][data-state=hidden]{transform:translateX(-5px)}.tippy-box[data-animation=shift-toward-subtle][data-state=hidden][data-placement^=right][data-state=hidden]{transform:translateX(5px)}";
8504
+ styleInject(css_248z$4);
8429
8505
 
8430
8506
  // This component will handle some of the new tippy designs and interactions
8431
8507
  // So this can be updated to support further for new features or interactions
@@ -16366,8 +16442,8 @@ var CustomSelect = function (props) {
16366
16442
  return jsxRuntime.jsx(Select, __assign({}, props));
16367
16443
  };
16368
16444
 
16369
- 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}";
16370
- styleInject(css_248z);
16445
+ var css_248z$3 = ".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}";
16446
+ styleInject(css_248z$3);
16371
16447
 
16372
16448
  function InfoColourBar(_a) {
16373
16449
  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;
@@ -16427,8 +16503,89 @@ var Checkbox = /** @class */ (function (_super) {
16427
16503
  return Checkbox;
16428
16504
  }(React.Component));
16429
16505
 
16506
+ var css_248z$2 = ".toggle__switch {\n position: relative;\n display: inline-block;\n width: 100%;\n height: 100%;\n}\n.toggle__switch.disabled {\n cursor: not-allowed;\n}\n.toggle__switch.disabled .toggle__slider {\n cursor: not-allowed;\n}\n\n/* Hide default HTML checkbox */\n.toggle__switch input {\n opacity: 0;\n width: 0;\n height: 0;\n}\n\n/* The slider */\n.toggle__slider {\n position: absolute;\n cursor: pointer;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #ccc;\n transition: all 0.4s ease;\n}\n\n.toggle__slider:before {\n position: absolute;\n content: \"\";\n height: calc(100% - 8px);\n width: calc(50% - 4px);\n left: 4px;\n bottom: 4px;\n background-color: white;\n transition: all 0.4s ease;\n}\n\ninput:checked + .toggle__slider {\n background-color: var(--color);\n}\n\ninput:focus + .toggle__slider {\n box-shadow: 0 0 1px var(--color);\n}\n\ninput:checked + .toggle__slider:before {\n transform: translateX(100%);\n}\n\n/* Rounded sliders */\n.toggle__slider.round {\n border-radius: 34px;\n}\n\n.toggle__slider.round:before {\n border-radius: 50%;\n}";
16507
+ styleInject(css_248z$2);
16508
+
16509
+ var Toggle = function (_a) {
16510
+ var _b;
16511
+ var _c = _a.selected, selected = _c === void 0 ? false : _c, _d = _a.onSelect, onSelect = _d === void 0 ? null : _d, _e = _a.color, color = _e === void 0 ? "#36b37e" : _e, _f = _a.rootClassName, rootClassName = _f === void 0 ? "" : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.dataTestId, dataTestId = _h === void 0 ? "handle-toggle-button" : _h, props = __rest(_a, ["selected", "onSelect", "color", "rootClassName", "disabled", "dataTestId"]);
16512
+ var _j = __read(React.useState(selected), 2), active = _j[0], setActive = _j[1];
16513
+ useEffectAfterMount(function () {
16514
+ if (typeof onSelect === 'function') {
16515
+ if (active !== selected) {
16516
+ onSelect(active);
16517
+ }
16518
+ }
16519
+ }, [active]);
16520
+ useEffectAfterMount(function () {
16521
+ setActive(selected);
16522
+ }, [selected]);
16523
+ function handleClick(e) {
16524
+ if (!disabled) {
16525
+ setActive(function (active) { return !active; });
16526
+ }
16527
+ }
16528
+ return (jsxRuntime.jsxs("label", __assign({}, props, { className: "".concat(rootClassName, " toggle__switch ").concat(disabled ? 'disabled' : ''), style: (_b = {}, _b['--color'] = color, _b) }, { children: [jsxRuntime.jsx("input", { type: "checkbox", checked: !!active, onChange: handleClick, className: "toggle__input" }), jsxRuntime.jsx("span", { className: "toggle__slider round", "data-testid": dataTestId })] })));
16529
+ };
16530
+
16531
+ var css_248z$1 = ".modal-body--scan-details {\n position: fixed;\n top: 0;\n right: 0;\n background: var(--N000);\n width: 800px;\n}\n\n.security-tab__table {\n width: 100%;\n}\n\n.security-tab__table-header {\n border-bottom: solid 1px var(--N200);\n}\n\n.security-cell-header {\n font-size: 12px;\n font-weight: 600;\n line-height: 1.5;\n letter-spacing: normal;\n text-transform: uppercase;\n color: var(--N500);\n}\n\n.dc__security-tab__table-row {\n font-size: 13px;\n font-weight: normal;\n line-height: 1.54;\n letter-spacing: normal;\n color: var(--N900);\n box-shadow: inset 0 -1px 0 0 #f5f5f5;\n}\n\n.security-tab__cell-cve,\n.security-tab__cell-severity,\n.security-tab__cell-package,\n.security-tab__cell-current-ver,\n.security-tab__cell-fixed-ver,\n.security-tab__cell-policy {\n padding: 10px;\n}\n\n.security-tab__cell-cve {\n padding-left: 0px;\n text-align: left;\n width: 20%;\n}\n\n.security-tab__cell-policy {\n padding-right: 0px;\n}\n\n.security-tab__cell-policy--whitelist,\n.security-tab__cell-policy--whitelisted {\n color: var(--G500);\n text-transform: capitalize;\n}\n\n.security-tab__cell-policy--block {\n color: var(--R500);\n text-transform: capitalize;\n}\n\n.scanned-object__results {\n margin: 0 20px;\n}";
16532
+ styleInject(css_248z$1);
16533
+
16534
+ function ScanVulnerabilitiesTable(_a) {
16535
+ var vulnerabilities = _a.vulnerabilities;
16536
+ var renderRow = function (vulnerability) {
16537
+ var _a, _b, _c;
16538
+ return (jsxRuntime.jsxs("tr", __assign({ className: "dc__security-tab__table-row cursor", onClick: function (e) {
16539
+ window.open("https://cve.mitre.org/cgi-bin/cvename.cgi?name=".concat(vulnerability.name), '_blank');
16540
+ } }, { children: [jsxRuntime.jsx("td", __assign({ className: "security-tab__cell-cve dc__cve-cell" }, { children: jsxRuntime.jsx("a", __assign({ href: "https://cve.mitre.org/cgi-bin/cvename.cgi?name=".concat(vulnerability.name), rel: "noopener noreferrer", target: "_blank" }, { children: vulnerability.name })) })), jsxRuntime.jsx("td", __assign({ className: "security-tab__cell-severity" }, { children: jsxRuntime.jsx("span", __assign({ className: "fill-".concat((_a = vulnerability.severity) === null || _a === void 0 ? void 0 : _a.toLowerCase()) }, { children: vulnerability.severity })) })), jsxRuntime.jsx("td", __assign({ className: "security-tab__cell-package" }, { children: vulnerability.package })), jsxRuntime.jsx("td", __assign({ className: "security-tab__cell-current-ver" }, { children: vulnerability.version })), jsxRuntime.jsx("td", __assign({ className: "security-tab__cell-fixed-ver" }, { children: vulnerability.fixedVersion })), jsxRuntime.jsx("td", __assign({ className: "security-tab__cell-policy security-tab__cell-policy--".concat((_b = vulnerability.policy) === null || _b === void 0 ? void 0 : _b.toLowerCase()) }, { children: (_c = vulnerability.policy) === null || _c === void 0 ? void 0 : _c.toLowerCase() }))] })));
16541
+ };
16542
+ return (jsxRuntime.jsx("table", __assign({ className: "security-tab__table" }, { children: jsxRuntime.jsxs("tbody", { children: [jsxRuntime.jsxs("tr", __assign({ className: "security-tab__table-header" }, { children: [jsxRuntime.jsx("th", __assign({ className: "security-cell-header security-tab__cell-cve" }, { children: "CVE" })), jsxRuntime.jsx("th", __assign({ className: "security-cell-header security-tab__cell-severity" }, { children: "Severity" })), jsxRuntime.jsx("th", __assign({ className: "security-cell-header security-tab__cell-package" }, { children: "Package" })), jsxRuntime.jsx("th", __assign({ className: "security-cell-header security-tab__cell-current-ver" }, { children: "Current Version" })), jsxRuntime.jsx("th", __assign({ className: "security-cell-header security-tab__cell-fixed-ver" }, { children: "Fixed In Version" })), jsxRuntime.jsx("th", __assign({ className: "security-cell-header security-tab__cell-policy" }, { children: "Policy" }))] })), vulnerabilities.map(function (vulnerability) {
16543
+ return renderRow(vulnerability);
16544
+ })] }) })));
16545
+ }
16546
+
16547
+ var css_248z = ".radio-group {\n height: 30px;\n background: white;\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 4px;\n border-radius: 4px;\n}\n.radio-group .label,\n.radio-group .radio,\n.radio-group .checkbox {\n margin: 0;\n}\n.radio-group .radio {\n height: 100%;\n width: auto;\n color: var(--N400);\n display: flex;\n align-items: center;\n}\n.radio-group .radio + .radio {\n margin-top: 0;\n}\n.radio-group input[type=checkbox] {\n display: contents;\n overflow: hidden;\n max-width: 0px;\n height: 0;\n opacity: 0;\n margin: unset;\n}\n.radio-group input + .radio__item-label {\n padding: 4px 6px;\n height: 100%;\n width: 100%;\n display: flex;\n align-items: center;\n transition: all 0.5s;\n cursor: pointer;\n}\n.radio-group input[type=checkbox]:checked + .radio__item-label {\n background: #2c3354;\n color: white;\n border-radius: 4px;\n}";
16548
+ styleInject(css_248z);
16549
+
16550
+ var RadioContext = React.createContext(null);
16551
+ function useRadioContext() {
16552
+ var context = React.useContext(RadioContext);
16553
+ if (!context) {
16554
+ throw new Error("Radio compound components cannot be rendered outside the Toggle component");
16555
+ }
16556
+ return context;
16557
+ }
16558
+ var RadioGroup = React.memo(function RadioGroup(_a) {
16559
+ var name = _a.name, onChange = _a.onChange, children = _a.children, _b = _a.className, className = _b === void 0 ? '' : _b, initialTab = _a.initialTab, _c = _a.disabled, disabled = _c === void 0 ? false : _c; _a.dataTestId;
16560
+ var _d = __read(React.useState(null), 2), selected = _d[0], select = _d[1];
16561
+ React.useEffect(function () {
16562
+ if (initialTab === selected)
16563
+ return;
16564
+ select(initialTab);
16565
+ }, [initialTab]);
16566
+ return (jsxRuntime.jsx(RadioContext.Provider, __assign({ value: { name: name, selected: selected, select: select, disabled: disabled, onChange: onChange } }, { children: jsxRuntime.jsx("div", __assign({ className: "".concat(className, " radio-group") }, { children: children })) })));
16567
+ });
16568
+ function Radio(_a) {
16569
+ var value = _a.value, children = _a.children, _b = _a.className, className = _b === void 0 ? '' : _b, _c = _a.showTippy, showTippy = _c === void 0 ? false : _c, _d = _a.tippyContent, tippyContent = _d === void 0 ? '' : _d, _e = _a.canSelect, canSelect = _e === void 0 ? true : _e, _f = _a.isDisabled, isDisabled = _f === void 0 ? false : _f, _g = _a.tippyClass, tippyClass = _g === void 0 ? '' : _g, dataTestId = _a.dataTestId;
16570
+ var _h = useRadioContext(), name = _h.name, selected = _h.selected, select = _h.select, disabled = _h.disabled, onChange = _h.onChange;
16571
+ return (jsxRuntime.jsx(ConditionalWrap, __assign({ condition: showTippy, wrap: function (children) { return (jsxRuntime.jsx(Tippy, __assign({ className: "default-tt w-250 ".concat(tippyClass), arrow: false, placement: "bottom", content: tippyContent }, { children: children }))); } }, { children: jsxRuntime.jsxs("label", __assign({ className: "".concat(className, " radio ").concat((isDisabled || disabled) ? 'disabled' : '') }, { children: [jsxRuntime.jsx("input", { type: "checkbox", value: value, name: name, checked: value === selected, onChange: function (e) {
16572
+ e.persist();
16573
+ if (canSelect) {
16574
+ select(e.target.value);
16575
+ }
16576
+ onChange(e);
16577
+ }, disabled: isDisabled || disabled }), jsxRuntime.jsx("span", __assign({ className: "radio__item-label", "data-testid": dataTestId }, { children: children }))] })) })));
16578
+ }
16579
+ RadioGroup.Radio = Radio;
16580
+
16581
+ var RadioGroup$1 = /*#__PURE__*/Object.freeze({
16582
+ __proto__: null,
16583
+ default: RadioGroup
16584
+ });
16585
+
16430
16586
  exports.BreadCrumb = BreadCrumb;
16431
16587
  exports.BreadcrumbStore = Store;
16588
+ exports.CDModalTab = CDModalTab;
16432
16589
  exports.Checkbox = Checkbox;
16433
16590
  exports.ClearIndicator = ClearIndicator;
16434
16591
  exports.ConditionalWrap = ConditionalWrap;
@@ -16461,15 +16618,18 @@ exports.PopupMenu = PopupMenu;
16461
16618
  exports.Progressing = Progressing;
16462
16619
  exports.PropagateTagInfo = PropagateTagInfo;
16463
16620
  exports.ROUTES = ROUTES;
16464
- exports.RadioGroup = RadioGroup;
16621
+ exports.RadioGroup = RadioGroup$2;
16465
16622
  exports.RadioGroupItem = RadioGroupItem;
16466
16623
  exports.Reload = Reload;
16467
16624
  exports.RequestTimeout = RequestTimeout;
16468
16625
  exports.ResizableTagTextArea = ResizableTagTextArea;
16626
+ exports.ScanVulnerabilitiesTable = ScanVulnerabilitiesTable;
16469
16627
  exports.ServerError = ServerError;
16470
16628
  exports.ServerErrors = ServerErrors;
16471
16629
  exports.SingleSelectOption = SingleSelectOption;
16630
+ exports.StyledRadioGroup = RadioGroup$1;
16472
16631
  exports.TOAST_ACCESS_DENIED = TOAST_ACCESS_DENIED;
16632
+ exports.TOKEN_COOKIE_NAME = TOKEN_COOKIE_NAME;
16473
16633
  exports.TagDetails = TagDetails;
16474
16634
  exports.TagLabelSelect = TagLabelSelect;
16475
16635
  exports.TagLabelValueSelector = TagLabelValueSelector;
@@ -16477,12 +16637,21 @@ exports.TippyCustomized = TippyCustomized;
16477
16637
  exports.ToastBody = ToastBody;
16478
16638
  exports.ToastBody3 = ToastBody3;
16479
16639
  exports.ToastBodyWithButton = ToastBodyWithButton;
16640
+ exports.Toggle = Toggle;
16641
+ exports.TriggerTypeMap = TriggerTypeMap;
16480
16642
  exports.URLS = URLS;
16481
16643
  exports.VisibleModal = VisibleModal;
16482
16644
  exports.VisibleModal2 = VisibleModal2;
16483
16645
  exports.get = get;
16646
+ exports.getAlphabetIcon = getAlphabetIcon;
16647
+ exports.getCookie = getCookie;
16648
+ exports.getEmptyArrayOfLength = getEmptyArrayOfLength;
16649
+ exports.getLoginInfo = getLoginInfo;
16650
+ exports.getRandomColor = getRandomColor;
16484
16651
  exports.getTeamListMin = getTeamListMin;
16485
16652
  exports.multiSelectStyles = multiSelectStyles;
16653
+ exports.noop = noop$1;
16654
+ exports.not = not;
16486
16655
  exports.post = post;
16487
16656
  exports.put = put;
16488
16657
  exports.showError = showError;
@@ -16491,4 +16660,5 @@ exports.stopPropagation = stopPropagation;
16491
16660
  exports.toastAccessDenied = toastAccessDenied;
16492
16661
  exports.trash = trash;
16493
16662
  exports.useBreadcrumb = useBreadcrumb;
16663
+ exports.useEffectAfterMount = useEffectAfterMount;
16494
16664
  exports.useThrottledEffect = useThrottledEffect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.7-beta-36",
3
+ "version": "0.0.7-beta-38",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -53,3 +53,8 @@ export const ERROR_EMPTY_SCREEN = {
53
53
  REQUIRED_MANAGER_ACCESS:
54
54
  'Looks like you don’t have access to information on this page. Please contact your manager to request access.',
55
55
  }
56
+ export const TOKEN_COOKIE_NAME = 'argocd.token'
57
+ export const TriggerTypeMap = {
58
+ automatic: 'Auto',
59
+ manual: 'Manual',
60
+ }
@@ -1,9 +1,9 @@
1
+ import React, { useEffect, useRef } from 'react'
1
2
  import { ServerErrors } from './ServerError'
2
3
  import { toast } from 'react-toastify'
3
4
  import * as Sentry from '@sentry/browser'
4
5
  import { toastAccessDenied } from './ToastBody'
5
- import { useEffect, useRef } from 'react'
6
- import { ERROR_EMPTY_SCREEN } from './Constants'
6
+ import { ERROR_EMPTY_SCREEN, TOKEN_COOKIE_NAME } from './Constants'
7
7
 
8
8
  toast.configure({
9
9
  autoClose: 3000,
@@ -90,3 +90,81 @@ export function useThrottledEffect(callback, delay, deps = []) {
90
90
  }
91
91
  }, [delay, ...deps])
92
92
  }
93
+
94
+ const colors = [
95
+ '#FFB900',
96
+ '#D83B01',
97
+ '#B50E0E',
98
+ '#E81123',
99
+ '#B4009E',
100
+ '#5C2D91',
101
+ '#0078D7',
102
+ '#00B4FF',
103
+ '#008272',
104
+ '#107C10',
105
+ ]
106
+
107
+ export function getRandomColor(email: string): string {
108
+ let sum = 0
109
+ for (let i = 0; i < email.length; i++) {
110
+ sum += email.charCodeAt(i)
111
+ }
112
+ return colors[sum % colors.length]
113
+ }
114
+
115
+ export const getAlphabetIcon = (str: string) => {
116
+ if (!str) return null
117
+ return (
118
+ <span
119
+ className="alphabet-icon__initial fs-13 icon-dim-20 flex cn-0 mr-8"
120
+ style={{ backgroundColor: getRandomColor(str) }}
121
+ >
122
+ {str[0]}
123
+ </span>
124
+ )
125
+ }
126
+
127
+ export const getEmptyArrayOfLength = (length: number) => {
128
+ return Array.from({ length })
129
+ }
130
+
131
+ export function noop(...args): any {}
132
+
133
+ export function not(e) {
134
+ return !e
135
+ }
136
+
137
+ export function useEffectAfterMount(cb, dependencies) {
138
+ const justMounted = React.useRef(true)
139
+ React.useEffect(() => {
140
+ if (!justMounted.current) {
141
+ return cb()
142
+ }
143
+ justMounted.current = false
144
+ }, dependencies)
145
+ }
146
+
147
+ export function getCookie(sKey) {
148
+ if (!sKey) {
149
+ return null
150
+ }
151
+ return (
152
+ document.cookie.replace(
153
+ new RegExp('(?:(?:^|.*;)\\s*' + sKey.replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'),
154
+ '$1',
155
+ ) || null
156
+ )
157
+ }
158
+
159
+ export function getLoginInfo() {
160
+ const argocdToken = getCookie(TOKEN_COOKIE_NAME)
161
+ if (argocdToken) {
162
+ const jwts = argocdToken.split('.')
163
+ try {
164
+ return JSON.parse(atob(jwts[1]))
165
+ } catch (err) {
166
+ console.error('error in setting user ', err)
167
+ return null
168
+ }
169
+ }
170
+ }
@@ -0,0 +1,88 @@
1
+ import Tippy from '@tippyjs/react'
2
+ import React, { useState, useEffect } from 'react'
3
+ import { ConditionalWrap } from '../Helper'
4
+ import './radioGroup.scss'
5
+
6
+ const RadioContext = React.createContext(null)
7
+
8
+ function useRadioContext() {
9
+ const context = React.useContext(RadioContext)
10
+ if (!context) {
11
+ throw new Error(`Radio compound components cannot be rendered outside the Toggle component`)
12
+ }
13
+ return context
14
+ }
15
+
16
+ interface RadioGroupInterface {
17
+ name: string
18
+ onChange: any
19
+ className?: string
20
+ initialTab: string
21
+ disabled: boolean
22
+ showTippy?: boolean
23
+ tippyContent?: any
24
+ dataTestId?: string
25
+ }
26
+
27
+ interface RadioGroupComposition {
28
+ Radio?: React.FC<any>
29
+ }
30
+
31
+ const RadioGroup: React.FC<RadioGroupInterface> & RadioGroupComposition = React.memo(function RadioGroup({
32
+ name,
33
+ onChange,
34
+ children,
35
+ className = '',
36
+ initialTab,
37
+ disabled = false,
38
+ dataTestId
39
+ }) {
40
+ const [selected, select] = useState(null)
41
+
42
+ useEffect(() => {
43
+ if (initialTab === selected) return
44
+ select(initialTab)
45
+ }, [initialTab])
46
+
47
+ return (
48
+ <RadioContext.Provider value={{ name, selected, select, disabled, onChange }}>
49
+ <div className={`${className} radio-group`}>{children}</div>
50
+ </RadioContext.Provider>
51
+ )
52
+ })
53
+
54
+ function Radio({ value, children, className = '', showTippy = false, tippyContent = '', canSelect = true, isDisabled = false, tippyClass = '', dataTestId }) {
55
+ const { name, selected, select, disabled, onChange } = useRadioContext()
56
+ return (
57
+ <ConditionalWrap
58
+ condition={showTippy}
59
+ wrap={(children) => (
60
+ <Tippy className={`default-tt w-250 ${tippyClass}`} arrow={false} placement="bottom" content={tippyContent}>
61
+ {children}
62
+ </Tippy>
63
+ )}
64
+ >
65
+ <label className={`${className} radio ${(isDisabled || disabled)? 'disabled': ''}`}>
66
+ <input
67
+ type="checkbox"
68
+ value={value}
69
+ name={name}
70
+
71
+ checked={value === selected}
72
+ onChange={(e) => {
73
+ e.persist()
74
+ if (canSelect) {
75
+ select(e.target.value)
76
+ }
77
+ onChange(e)
78
+ }}
79
+ disabled={isDisabled || disabled}
80
+ />
81
+ <span className="radio__item-label" data-testid={dataTestId}>{children}</span>
82
+ </label>
83
+ </ConditionalWrap>
84
+ )
85
+ }
86
+
87
+ RadioGroup.Radio = Radio
88
+ export default RadioGroup
@@ -0,0 +1,46 @@
1
+ .radio-group {
2
+ .label,
3
+ .radio,
4
+ .checkbox {
5
+ margin: 0;
6
+ }
7
+ height: 30px;
8
+ background: white;
9
+ display: flex;
10
+ justify-content: center;
11
+ align-items: center;
12
+ padding: 4px;
13
+ border-radius: 4px;
14
+ .radio {
15
+ height: 100%;
16
+ width: auto;
17
+ color: var(--N400);
18
+ display: flex;
19
+ align-items: center;
20
+ }
21
+ .radio+.radio {
22
+ margin-top: 0;
23
+ }
24
+ input[type=checkbox] {
25
+ display: contents;
26
+ overflow: hidden;
27
+ max-width: 0px;
28
+ height: 0;
29
+ opacity: 0;
30
+ margin: unset;
31
+ }
32
+ input+.radio__item-label {
33
+ padding: 4px 6px;
34
+ height: 100%;
35
+ width: 100%;
36
+ display: flex;
37
+ align-items: center;
38
+ transition: all 0.5s;
39
+ cursor: pointer;
40
+ }
41
+ input[type=checkbox]:checked+.radio__item-label {
42
+ background: #2c3354;
43
+ color: white;
44
+ border-radius: 4px;
45
+ }
46
+ }
@@ -0,0 +1,55 @@
1
+ import React from 'react'
2
+ import { ScanVulnerabilitiesTableProps, VulnerabilityType } from '../Types'
3
+ import './scanVulnerabilities.css'
4
+
5
+ export default function ScanVulnerabilitiesTable({ vulnerabilities }: ScanVulnerabilitiesTableProps) {
6
+ const renderRow = (vulnerability: VulnerabilityType) => {
7
+ return (
8
+ <tr
9
+ className="dc__security-tab__table-row cursor"
10
+ onClick={(e) => {
11
+ window.open(`https://cve.mitre.org/cgi-bin/cvename.cgi?name=${vulnerability.name}`, '_blank')
12
+ }}
13
+ >
14
+ <td className="security-tab__cell-cve dc__cve-cell">
15
+ <a
16
+ href={`https://cve.mitre.org/cgi-bin/cvename.cgi?name=${vulnerability.name}`}
17
+ rel="noopener noreferrer"
18
+ target="_blank"
19
+ >
20
+ {vulnerability.name}
21
+ </a>
22
+ </td>
23
+ <td className="security-tab__cell-severity">
24
+ <span className={`fill-${vulnerability.severity?.toLowerCase()}`}>{vulnerability.severity}</span>
25
+ </td>
26
+ <td className="security-tab__cell-package">{vulnerability.package}</td>
27
+ <td className="security-tab__cell-current-ver">{vulnerability.version}</td>
28
+ <td className="security-tab__cell-fixed-ver">{vulnerability.fixedVersion}</td>
29
+ <td
30
+ className={`security-tab__cell-policy security-tab__cell-policy--${vulnerability.policy?.toLowerCase()}`}
31
+ >
32
+ {vulnerability.policy?.toLowerCase()}
33
+ </td>
34
+ </tr>
35
+ )
36
+ }
37
+
38
+ return (
39
+ <table className="security-tab__table">
40
+ <tbody>
41
+ <tr className="security-tab__table-header">
42
+ <th className="security-cell-header security-tab__cell-cve">CVE</th>
43
+ <th className="security-cell-header security-tab__cell-severity">Severity</th>
44
+ <th className="security-cell-header security-tab__cell-package">Package</th>
45
+ <th className="security-cell-header security-tab__cell-current-ver">Current Version</th>
46
+ <th className="security-cell-header security-tab__cell-fixed-ver">Fixed In Version</th>
47
+ <th className="security-cell-header security-tab__cell-policy">Policy</th>
48
+ </tr>
49
+ {vulnerabilities.map((vulnerability) => {
50
+ return renderRow(vulnerability)
51
+ })}
52
+ </tbody>
53
+ </table>
54
+ )
55
+ }
@@ -0,0 +1,67 @@
1
+ .modal-body--scan-details {
2
+ position: fixed;
3
+ top: 0;
4
+ right: 0;
5
+ background: var(--N000);
6
+ width: 800px;
7
+ }
8
+
9
+ .security-tab__table {
10
+ width: 100%;
11
+ }
12
+
13
+ .security-tab__table-header {
14
+ border-bottom: solid 1px var(--N200);
15
+ }
16
+
17
+ .security-cell-header {
18
+ font-size: 12px;
19
+ font-weight: 600;
20
+ line-height: 1.5;
21
+ letter-spacing: normal;
22
+ text-transform: uppercase;
23
+ color: var(--N500);
24
+ }
25
+
26
+ .dc__security-tab__table-row {
27
+ font-size: 13px;
28
+ font-weight: normal;
29
+ line-height: 1.54;
30
+ letter-spacing: normal;
31
+ color: var(--N900);
32
+ box-shadow: inset 0 -1px 0 0 #f5f5f5;
33
+ }
34
+
35
+ .security-tab__cell-cve,
36
+ .security-tab__cell-severity,
37
+ .security-tab__cell-package,
38
+ .security-tab__cell-current-ver,
39
+ .security-tab__cell-fixed-ver,
40
+ .security-tab__cell-policy {
41
+ padding: 10px;
42
+ }
43
+
44
+ .security-tab__cell-cve {
45
+ padding-left: 0px;
46
+ text-align: left;
47
+ width: 20%;
48
+ }
49
+
50
+ .security-tab__cell-policy {
51
+ padding-right: 0px;
52
+ }
53
+
54
+ .security-tab__cell-policy--whitelist,
55
+ .security-tab__cell-policy--whitelisted {
56
+ color: var(--G500);
57
+ text-transform: capitalize;
58
+ }
59
+
60
+ .security-tab__cell-policy--block {
61
+ color: var(--R500);
62
+ text-transform: capitalize;
63
+ }
64
+
65
+ .scanned-object__results {
66
+ margin: 0 20px;
67
+ }
@@ -0,0 +1,70 @@
1
+ .toggle__switch {
2
+ position: relative;
3
+ display: inline-block;
4
+ width: 100%;
5
+ height: 100%;
6
+
7
+ &.disabled{
8
+ cursor: not-allowed;
9
+ .toggle__slider{
10
+ cursor: not-allowed;
11
+ }
12
+ }
13
+ }
14
+
15
+
16
+ /* Hide default HTML checkbox */
17
+
18
+ .toggle__switch input {
19
+ opacity: 0;
20
+ width: 0;
21
+ height: 0;
22
+ }
23
+
24
+
25
+ /* The slider */
26
+
27
+ .toggle__slider {
28
+ position: absolute;
29
+ cursor: pointer;
30
+ top: 0;
31
+ left: 0;
32
+ right: 0;
33
+ bottom: 0;
34
+ background-color: #ccc;
35
+ transition: all .4s ease;
36
+ }
37
+
38
+ .toggle__slider:before {
39
+ position: absolute;
40
+ content: "";
41
+ height: calc( 100% - 8px);
42
+ width: calc( 50% - 4px);
43
+ left: 4px;
44
+ bottom: 4px;
45
+ background-color: white;
46
+ transition: all 0.4s ease;
47
+ }
48
+
49
+ input:checked+.toggle__slider {
50
+ background-color: var(--color);
51
+ }
52
+
53
+ input:focus+.toggle__slider {
54
+ box-shadow: 0 0 1px var(--color);
55
+ }
56
+
57
+ input:checked+.toggle__slider:before {
58
+ transform: translateX(calc( 100%));
59
+ }
60
+
61
+
62
+ /* Rounded sliders */
63
+
64
+ .toggle__slider.round {
65
+ border-radius: 34px;
66
+ }
67
+
68
+ .toggle__slider.round:before {
69
+ border-radius: 50%;
70
+ }
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { useEffectAfterMount } from '../Helper';
3
+ import './Toggle.scss'
4
+
5
+ const Toggle = ({selected=false, onSelect=null, color="#36b37e", rootClassName="", disabled=false, dataTestId="handle-toggle-button", ...props})=>{
6
+ const [active, setActive] = React.useState(selected);
7
+
8
+ useEffectAfterMount(()=>{
9
+ if(typeof onSelect === 'function'){
10
+ if(active !== selected){
11
+ onSelect(active)
12
+ }
13
+ }
14
+ },[active])
15
+
16
+ useEffectAfterMount(() => {
17
+ setActive(selected)
18
+ }, [selected])
19
+
20
+ function handleClick(e){
21
+ if(!disabled){
22
+ setActive(active=>!active)
23
+ }
24
+ }
25
+
26
+ return (
27
+ <label
28
+ {...props}
29
+ className={`${rootClassName} toggle__switch ${disabled ? 'disabled' : ''}`}
30
+ style={{ ['--color' as any]: color }}
31
+ >
32
+ <input type="checkbox" checked={!!active} onChange={handleClick} className="toggle__input" />
33
+ <span className="toggle__slider round" data-testid={dataTestId}></span>
34
+ </label>
35
+ )
36
+ }
37
+
38
+ export default Toggle
@@ -174,3 +174,146 @@ export interface ModalType {
174
174
  preventWheelDisable?: boolean
175
175
  noBackDrop?: boolean
176
176
  }
177
+
178
+ export type CDModalTabType = 'SECURITY' | 'CHANGES'
179
+
180
+ export const CDModalTab = {
181
+ Security: <CDModalTabType>'SECURITY',
182
+ Changes: <CDModalTabType>'CHANGES',
183
+ }
184
+
185
+ export enum DeploymentNodeType {
186
+ PRECD = 'PRECD',
187
+ CD = 'CD',
188
+ POSTCD = 'POSTCD',
189
+ APPROVAL = 'APPROVAL'
190
+ }
191
+
192
+ export interface UserApprovalConfigType {
193
+ requiredCount: number
194
+ }
195
+
196
+ interface ApprovalUserDataType {
197
+ dataId: number
198
+ userActionTime: string
199
+ userComment: string
200
+ userEmail: string
201
+ userId: number
202
+ userResponse: number
203
+ }
204
+
205
+ export interface UserApprovalMetadataType {
206
+ approvalRequestId: number
207
+ approvalRuntimeState: number
208
+ approvedUsersData: ApprovalUserDataType[]
209
+ requestedUserData: ApprovalUserDataType
210
+ }
211
+
212
+ export interface CommonNodeAttr {
213
+ connectingCiPipelineId?: number
214
+ parents: string | number[] | string[]
215
+ x: number
216
+ y: number
217
+ title: string
218
+ description?: string
219
+ triggerType?: string
220
+ id: string
221
+ icon?: string
222
+ status?: string
223
+ isSource: boolean
224
+ isGitSource: boolean
225
+ isRoot: boolean
226
+ downstreams: string[]
227
+ type: 'CI' | 'GIT' | 'PRECD' | 'CD' | 'POSTCD' | 'WEBHOOK'
228
+ parentCiPipeline?: number
229
+ parentAppId?: number
230
+ url?: string
231
+ branch?: string
232
+ sourceType?: string
233
+ colorCode?: string
234
+ isExternalCI?: boolean
235
+ isLinkedCI?: boolean
236
+ environmentName?: string //used for CDs
237
+ environmentId?: number
238
+ inputMaterialList?: any[]
239
+ rollbackMaterialList?: any[] //used for CDs
240
+ linkedCount?: number //used for CI
241
+ deploymentStrategy?: string
242
+ height: number
243
+ width: number
244
+ preNode?: CommonNodeAttr //used for CDs
245
+ postNode?: CommonNodeAttr //used for CDs
246
+ stageIndex?: number //used for CDs
247
+ sourceNodes?: Array<CommonNodeAttr> //used for CI
248
+ downstreamNodes?: Array<CommonNodeAttr>
249
+ parentPipelineId?: string
250
+ parentPipelineType?: string
251
+ parentEnvironmentName?: string
252
+ isRegex?: boolean
253
+ regex?: string
254
+ primaryBranchAfterRegex?: string
255
+ storageConfigured?: boolean
256
+ deploymentAppDeleteRequest?: boolean
257
+ approvalUsers?: string[]
258
+ userApprovalConfig?: UserApprovalConfigType
259
+ requestedUserId?: number
260
+ }
261
+
262
+
263
+ export interface VulnerabilityType {
264
+ name: string;
265
+ severity: "CRITICAL" | "MODERATE" | "LOW";
266
+ package: string;
267
+ version: string;
268
+ fixedVersion: string;
269
+ policy: string;
270
+ url?: string;
271
+ }
272
+
273
+ export interface ScanVulnerabilitiesTableProps {
274
+ vulnerabilities: VulnerabilityType[];
275
+ }
276
+
277
+ export interface MaterialInfo {
278
+ revision: string
279
+ modifiedTime: string | Date
280
+ author: string
281
+ message: string
282
+ commitLink: string
283
+ tag: string
284
+ webhookData: string
285
+ branch: string
286
+ url?: string
287
+ type?: string
288
+ }
289
+
290
+ export interface CDMaterialType {
291
+ index: number
292
+ id: string
293
+ materialInfo: MaterialInfo[]
294
+ tab: CDModalTabType
295
+ scanEnabled: boolean
296
+ scanned: boolean
297
+ vulnerabilitiesLoading: boolean
298
+ lastExecution: string //timestamp
299
+ vulnerabilities: VulnerabilityType[]
300
+ vulnerable: boolean
301
+ deployedTime: string
302
+ deployedBy?: string
303
+ wfrId?: number
304
+ buildTime: string
305
+ image: string
306
+ isSelected: boolean
307
+ showSourceInfo: boolean
308
+ latest: boolean
309
+ runningOnParentCd?: boolean
310
+ userApprovalMetadata?: UserApprovalMetadataType
311
+ triggeredBy?: number
312
+ }
313
+
314
+ export interface CDMaterialResponseType {
315
+ approvalUsers: string[]
316
+ materials: any[]
317
+ userApprovalConfig: UserApprovalConfigType
318
+ requestedUserId: number
319
+ }
@@ -26,4 +26,6 @@ export * from './Common.service'
26
26
  export * from './Checkbox'
27
27
  export { default as EmptyState } from './EmptyState/EmptyState'
28
28
  export { default as GenericEmptyState } from './EmptyState/GenericEmptyState'
29
-
29
+ export { default as Toggle } from './Toggle/Toggle'
30
+ export { default as ScanVulnerabilitiesTable } from './Security/ScanVulnerabilitiesTable'
31
+ export * as StyledRadioGroup from './RadioGroup/RadioGroup'