@devtron-labs/devtron-fe-common-lib 0.0.17 → 0.0.18-beta-2

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.
@@ -1,4 +1,4 @@
1
- import { TeamList, ResponseType } from './Types';
1
+ import { TeamList, ResponseType, DeploymentNodeType } from './Types';
2
2
  export declare const getTeamListMin: () => Promise<TeamList>;
3
3
  interface UserRole extends ResponseType {
4
4
  result?: {
@@ -6,6 +6,14 @@ interface UserRole extends ResponseType {
6
6
  superAdmin: boolean;
7
7
  };
8
8
  }
9
+ export declare const SourceTypeMap: {
10
+ BranchFixed: string;
11
+ WEBHOOK: string;
12
+ BranchRegex: string;
13
+ };
9
14
  export declare function getUserRole(appName?: string): Promise<UserRole>;
10
15
  export declare function setImageTags(request: any, pipelineId: number, artifactId: number): Promise<ResponseType>;
16
+ export declare const getCDMaterials: (cdMaterialId: any, stageType: DeploymentNodeType, abortSignal: AbortSignal, isApprovalNode?: boolean, imageTag?: string) => Promise<any>;
17
+ export declare function extractImage(image: string): string;
18
+ export declare function createGitCommitUrl(url: string, revision: string): string;
11
19
  export {};
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { UseSearchString } from './Types';
2
3
  export declare function showError(serverError: any, showToastOnUnknownError?: boolean, hideAccessError?: boolean): void;
3
4
  interface ConditionalWrapper<T> {
4
5
  condition: boolean;
@@ -40,4 +41,5 @@ export declare function CustomInput({ name, value, error, onChange, onBlur, onFo
40
41
  dataTestid?: string;
41
42
  }): JSX.Element;
42
43
  export declare function handleUTCTime(ts: string, isRelativeTime?: boolean): string;
44
+ export declare function useSearchString(): UseSearchString;
43
45
  export {};
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import './Toggle.scss';
3
- declare const Toggle: ({ selected, onSelect, color, rootClassName, disabled, dataTestId, ...props }: {
3
+ declare const Toggle: ({ selected, onSelect, color, rootClassName, disabled, dataTestId, Icon, iconClass, ...props }: {
4
4
  [x: string]: any;
5
5
  selected?: boolean;
6
6
  onSelect?: any;
@@ -8,5 +8,7 @@ declare const Toggle: ({ selected, onSelect, color, rootClassName, disabled, dat
8
8
  rootClassName?: string;
9
9
  disabled?: boolean;
10
10
  dataTestId?: string;
11
+ Icon?: any;
12
+ iconClass?: string;
11
13
  }) => JSX.Element;
12
14
  export default Toggle;
@@ -332,4 +332,10 @@ export interface RegistryTypeDetailType {
332
332
  id: InputDetailType;
333
333
  password: InputDetailType;
334
334
  }
335
+ export interface UseSearchString {
336
+ queryParams: URLSearchParams;
337
+ searchParams: {
338
+ [key: string]: string;
339
+ };
340
+ }
335
341
  export {};
package/dist/index.js CHANGED
@@ -2162,7 +2162,6 @@ var AppNotDeployed = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAGQCAYA
2162
2162
 
2163
2163
  function GenericEmptyState(_a) {
2164
2164
  var title = _a.title, image = _a.image, subTitle = _a.subTitle, isButtonAvailable = _a.isButtonAvailable, classname = _a.classname, styles = _a.styles, heightToDeduct = _a.heightToDeduct, imageType = _a.imageType, renderButton = _a.renderButton, imageClassName = _a.imageClassName, children = _a.children, SvgImage = _a.SvgImage, noImage = _a.noImage;
2165
- console.log(image);
2166
2165
  return (jsxRuntime.jsxs("div", __assign({ className: "flex column empty-state ".concat(classname ? classname : ''), style: styles, "data-testid": "generic-empty-state" }, (heightToDeduct >= 0 && { style: __assign(__assign({}, styles), { height: "calc(100vh - ".concat(heightToDeduct, "px)") }) }), { children: [!SvgImage ? !noImage && jsxRuntime.jsx("img", { className: imageClassName ? imageClassName : '', src: image || AppNotDeployed, width: imageType === exports.ImageType.Medium ? '200' : '250', height: imageType === exports.ImageType.Medium ? '160' : '200', alt: "empty-state" }) : jsxRuntime.jsx(SvgImage, {}), jsxRuntime.jsx("h4", __assign({ className: "title fw-6 cn-9 mb-8" }, { children: title })), subTitle && jsxRuntime.jsx("p", __assign({ className: "subtitle" }, { children: subTitle })), isButtonAvailable && renderButton(), children] })));
2167
2166
  }
2168
2167
 
@@ -10079,6 +10078,22 @@ function handleUTCTime(ts, isRelativeTime) {
10079
10078
  console.error("Error Parsing Date:", ts);
10080
10079
  }
10081
10080
  return timestamp;
10081
+ }
10082
+ function useSearchString() {
10083
+ var location = reactRouterDom.useLocation();
10084
+ var queryParams = React.useMemo(function () {
10085
+ var queryParams = new URLSearchParams(location.search);
10086
+ return queryParams;
10087
+ }, [location]);
10088
+ // const searchParams={}
10089
+ // for (let [key, value] of queryParams.entries()){
10090
+ // searchParams[key]=value
10091
+ // }
10092
+ var searchParams = Array.from(queryParams.entries()).reduce(function (agg, curr, idx) {
10093
+ agg[curr[0]] = curr[1];
10094
+ return agg;
10095
+ }, {});
10096
+ return { queryParams: queryParams, searchParams: searchParams };
10082
10097
  }
10083
10098
 
10084
10099
  function Progressing(_a) {
@@ -22524,11 +22539,118 @@ var getTeamListMin = function () {
22524
22539
  };
22525
22540
  });
22526
22541
  };
22542
+ var stageMap = {
22543
+ PRECD: 'PRE',
22544
+ CD: 'DEPLOY',
22545
+ POSTCD: 'POST',
22546
+ APPROVAL: 'APPROVAL',
22547
+ };
22548
+ var SourceTypeMap = {
22549
+ BranchFixed: 'SOURCE_TYPE_BRANCH_FIXED',
22550
+ WEBHOOK: 'WEBHOOK',
22551
+ BranchRegex: 'SOURCE_TYPE_BRANCH_REGEX',
22552
+ };
22527
22553
  function getUserRole(appName) {
22528
22554
  return get("".concat(ROUTES.USER_CHECK_ROLE).concat(appName ? "?appName=".concat(appName) : ''));
22529
22555
  }
22530
22556
  function setImageTags(request, pipelineId, artifactId) {
22531
22557
  return post("".concat(ROUTES.IMAGE_TAGGING, "/").concat(pipelineId, "/").concat(artifactId), request);
22558
+ }
22559
+ var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalNode, imageTag) {
22560
+ var URL = (!imageTag) ? "app/cd-pipeline/".concat(cdMaterialId, "/material?stage=").concat(stageMap[stageType]) : "app/cd-pipeline/".concat(cdMaterialId, "/material?stage=").concat(stageMap[stageType], "&search=").concat(imageTag);
22561
+ return get(URL, {
22562
+ signal: abortSignal,
22563
+ }).then(function (response) {
22564
+ var _a;
22565
+ var artifacts = (_a = response.result.ci_artifacts) !== null && _a !== void 0 ? _a : [];
22566
+ if (!response.result) {
22567
+ return {
22568
+ materials: [],
22569
+ };
22570
+ }
22571
+ else {
22572
+ var materials = artifacts.map(function (material, index) {
22573
+ var artifactStatusValue = '';
22574
+ return {
22575
+ index: index,
22576
+ id: material.id,
22577
+ deployedTime: material.deployed_time
22578
+ ? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
22579
+ : 'Not Deployed',
22580
+ deployedBy: material.deployedBy,
22581
+ wfrId: material.wfrId,
22582
+ image: extractImage(material.image),
22583
+ showChanges: false,
22584
+ vulnerabilities: [],
22585
+ buildTime: material.build_time || '',
22586
+ tab: CDModalTab.Changes,
22587
+ showSourceInfo: false,
22588
+ deployed: material.deployed || false,
22589
+ latest: material.latest || false,
22590
+ vulnerabilitiesLoading: true,
22591
+ scanned: material.scanned,
22592
+ scanEnabled: material.scanEnabled,
22593
+ isSelected: !material.vulnerable && index === 0,
22594
+ vulnerable: material.vulnerable,
22595
+ runningOnParentCd: material.runningOnParentCd,
22596
+ artifactStatus: artifactStatusValue,
22597
+ userApprovalMetadata: material.userApprovalMetadata,
22598
+ triggeredBy: material.triggeredBy,
22599
+ isVirtualEnvironment: material.isVirtualEnvironment,
22600
+ imageComment: material.imageComment,
22601
+ imageReleaseTags: material.imageReleaseTags,
22602
+ materialInfo: material.material_info
22603
+ ? material.material_info.map(function (mat) {
22604
+ return {
22605
+ modifiedTime: mat.modifiedTime ? moment(mat.modifiedTime).format("ddd, DD MMM YYYY, hh:mm A") : '',
22606
+ commitLink: createGitCommitUrl(mat.url, mat.revision),
22607
+ author: mat.author || '',
22608
+ message: mat.message || '',
22609
+ revision: mat.revision || '',
22610
+ tag: mat.tag || '',
22611
+ webhookData: mat.webhookData || '',
22612
+ url: mat.url || '',
22613
+ branch: (material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
22614
+ ? material.ciConfigureSourceValue
22615
+ : mat.branch) || '',
22616
+ type: material.ciConfigureSourceType || '',
22617
+ };
22618
+ })
22619
+ : [],
22620
+ };
22621
+ });
22622
+ return {
22623
+ materials: materials
22624
+ };
22625
+ }
22626
+ });
22627
+ };
22628
+ function extractImage(image) {
22629
+ return image ? image.split(':').pop() : '';
22630
+ }
22631
+ function createGitCommitUrl(url, revision) {
22632
+ if (!url || !revision) {
22633
+ return "NA";
22634
+ }
22635
+ if (url.indexOf("gitlab") > 0 || url.indexOf("github") > 0 || url.indexOf("azure") > 0) {
22636
+ var urlpart = url.split("@");
22637
+ if (urlpart.length > 1) {
22638
+ return "https://" + urlpart[1].split(".git")[0] + "/commit/" + revision;
22639
+ }
22640
+ if (urlpart.length == 1) {
22641
+ return urlpart[0].split(".git")[0] + "/commit/" + revision;
22642
+ }
22643
+ }
22644
+ if (url.indexOf("bitbucket") > 0) {
22645
+ var urlpart = url.split("@");
22646
+ if (urlpart.length > 1) {
22647
+ return "https://" + urlpart[1].split(".git")[0] + "/commits/" + revision;
22648
+ }
22649
+ if (urlpart.length == 1) {
22650
+ return urlpart[0].split(".git")[0] + "/commits/" + revision;
22651
+ }
22652
+ }
22653
+ return "NA";
22532
22654
  }
22533
22655
 
22534
22656
  /*
@@ -22553,13 +22675,13 @@ var Checkbox = /** @class */ (function (_super) {
22553
22675
  return Checkbox;
22554
22676
  }(React.Component));
22555
22677
 
22556
- 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}";
22678
+ 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.toggle__slider.round {\n border-radius: 34px;\n}\n.toggle__slider.round:before {\n border-radius: 50%;\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.toggle__slider.with-icon {\n background-color: var(--N000) !important;\n}\n.toggle__slider.with-icon svg {\n position: absolute;\n content: \"\";\n top: -1px;\n left: -1px;\n background-color: var(--N300);\n transition: all 0.4s ease;\n}\n\ninput:checked + .toggle__slider {\n background-color: var(--color);\n}\ninput:checked + .toggle__slider:before {\n transform: translateX(100%);\n}\ninput:checked + .toggle__slider.with-icon svg {\n transform: translateX(100%);\n background-color: var(--color);\n}\n\ninput:focus + .toggle__slider {\n box-shadow: 0 0 1px var(--color);\n}";
22557
22679
  styleInject(css_248z$2);
22558
22680
 
22559
22681
  var Toggle = function (_a) {
22560
22682
  var _b;
22561
- 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"]);
22562
- var _j = __read(React.useState(selected), 2), active = _j[0], setActive = _j[1];
22683
+ 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, _j = _a.Icon, Icon = _j === void 0 ? null : _j, _k = _a.iconClass, iconClass = _k === void 0 ? '' : _k, props = __rest(_a, ["selected", "onSelect", "color", "rootClassName", "disabled", "dataTestId", "Icon", "iconClass"]);
22684
+ var _l = __read(React.useState(selected), 2), active = _l[0], setActive = _l[1];
22563
22685
  useEffectAfterMount(function () {
22564
22686
  if (typeof onSelect === 'function') {
22565
22687
  if (active !== selected) {
@@ -22575,7 +22697,7 @@ var Toggle = function (_a) {
22575
22697
  setActive(function (active) { return !active; });
22576
22698
  }
22577
22699
  }
22578
- 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 })] })));
22700
+ 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", __assign({ className: "toggle__slider ".concat(Icon ? 'with-icon br-4 dc__border' : 'round'), "data-testid": dataTestId }, { children: Icon && jsxRuntime.jsx(Icon, { className: "icon-dim-20 br-4 p-2 ".concat(iconClass) }) }))] })));
22579
22701
  };
22580
22702
 
22581
22703
  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}";
@@ -23130,7 +23252,7 @@ var ImageTagsContainer = function (_a) {
23130
23252
  }
23131
23253
  handleSave(tagsToBeCreated);
23132
23254
  };
23133
- return (jsxRuntime.jsx("div", __assign({ className: "mt-8" }, { children: isEditing && tagsEditable ? (jsxRuntime.jsxs("div", __assign({ className: "bcn-0 dc__border-top-n1 " }, { children: [jsxRuntime.jsxs("div", __assign({ className: "cn-7 mt-12 flex left" }, { children: [jsxRuntime.jsx("div", { children: "Release tags (eg. v1.0)" }), renderInfoCard()] })), jsxRuntime.jsxs("div", __assign({ className: "mt-6 dc__position-rel-imp", "data-testid": "add-tag-text-area" }, { children: [jsxRuntime.jsx("input", { className: "form__input", value: textInput, onChange: setInputValue, placeholder: "Type a tag and press enter", onKeyDown: handleKeydown, onBlur: setInputValue, ref: creatableRef }), textInput.length > 0 && (jsxRuntime.jsxs("div", __assign({ onClick: enterTagCreate, className: "dc__position-abs bcn-0 flex cursor pt-2 pb-2 pr-4 pl-4 br-2 cn-7 dc__border dc__border-bottom-2", style: {
23255
+ return (jsxRuntime.jsx("div", __assign({ className: "mt-8" }, { children: isEditing && tagsEditable ? (jsxRuntime.jsxs("div", __assign({ className: "bcn-0 dc__border-top-n1 " }, { children: [jsxRuntime.jsxs("div", __assign({ className: "cn-7 mt-12 flex left" }, { children: [jsxRuntime.jsx("div", { children: "Release tags (eg. v1.0)" }), renderInfoCard()] })), jsxRuntime.jsxs("div", __assign({ className: "mt-6 dc__position-rel-imp", "data-testid": "add-tag-text-area" }, { children: [jsxRuntime.jsx("input", { className: "form__input fs-13", value: textInput, onChange: setInputValue, placeholder: "Type a tag and press enter", onKeyDown: handleKeydown, onBlur: setInputValue, ref: creatableRef }), textInput.length > 0 && (jsxRuntime.jsxs("div", __assign({ onClick: enterTagCreate, className: "dc__position-abs bcn-0 flex cursor pt-2 pb-2 pr-4 pl-4 br-2 cn-7 dc__border dc__border-bottom-2", style: {
23134
23256
  top: '50%',
23135
23257
  fontFamily: 'monospace',
23136
23258
  right: '8px',
@@ -23141,7 +23263,7 @@ var ImageTagsContainer = function (_a) {
23141
23263
  }, onHardDeleteClick: function (e) {
23142
23264
  stopPropagation(e);
23143
23265
  handleTagHardDelete(index);
23144
- }, tagId: tag.id, softDeleteTags: softDeleteTags, isSuperAdmin: isSuperAdmin, duplicateTag: tag === null || tag === void 0 ? void 0 : tag.duplicateTag, hideHardDelete: hideHardDelete }, tag.id)); }) })), showTagsWarning && (jsxRuntime.jsxs("div", __assign({ className: "cn-7 mb-8 flex left" }, { children: [jsxRuntime.jsx(SvgIcInfoFilled, { className: "form__icon--info icon-dim-16 mr-2" }), "Tags cannot be edited/removed later"] }))), jsxRuntime.jsx("div", __assign({ className: "cn-7 mt-12" }, { children: "Comment" })), jsxRuntime.jsx("div", __assign({ className: "flex left flex-wrap dc__gap-8 w-100 mt-6 mb-12", "data-testid": "add-image-comment-text-area" }, { children: jsxRuntime.jsx("textarea", { value: newDescription, onChange: handleDescriptionChange, className: "flex left flex-wrap dc__gap-8 dc__description-textarea", style: { height: '90px !important' } }) })), descriptionValidationMessage !== '' && (jsxRuntime.jsxs("div", __assign({ className: "flex left" }, { children: [jsxRuntime.jsx(SvgIcWarning, { className: "form__icon form__icon--error" }), jsxRuntime.jsx("div", __assign({ className: "form__error" }, { children: descriptionValidationMessage }))] }))), jsxRuntime.jsxs("div", __assign({ className: "w-100 flex right mt-12" }, { children: [jsxRuntime.jsx("button", __assign({ className: "cta flex cancel h-32 lh-32-imp", type: "button", onClick: function (e) {
23266
+ }, tagId: tag.id, softDeleteTags: softDeleteTags, isSuperAdmin: isSuperAdmin, duplicateTag: tag === null || tag === void 0 ? void 0 : tag.duplicateTag, hideHardDelete: hideHardDelete }, tag.id)); }) })), showTagsWarning && (jsxRuntime.jsxs("div", __assign({ className: "cn-7 mb-8 flex left" }, { children: [jsxRuntime.jsx(SvgIcInfoFilled, { className: "form__icon--info icon-dim-16 mr-2" }), "Tags cannot be edited/removed later"] }))), jsxRuntime.jsx("div", __assign({ className: "cn-7 mt-12" }, { children: "Comment" })), jsxRuntime.jsx("div", __assign({ className: "flex left flex-wrap dc__gap-8 w-100 mt-6 mb-12", "data-testid": "add-image-comment-text-area" }, { children: jsxRuntime.jsx("textarea", { value: newDescription, onChange: handleDescriptionChange, className: "flex left flex-wrap dc__gap-8 dc__description-textarea fs-13", style: { height: '90px !important' } }) })), descriptionValidationMessage !== '' && (jsxRuntime.jsxs("div", __assign({ className: "flex left" }, { children: [jsxRuntime.jsx(SvgIcWarning, { className: "form__icon form__icon--error" }), jsxRuntime.jsx("div", __assign({ className: "form__error" }, { children: descriptionValidationMessage }))] }))), jsxRuntime.jsxs("div", __assign({ className: "w-100 flex right mt-12" }, { children: [jsxRuntime.jsx("button", __assign({ className: "cta flex cancel h-32 lh-32-imp", type: "button", onClick: function (e) {
23145
23267
  stopPropagation(e);
23146
23268
  handleCancel();
23147
23269
  } }, { children: "Cancel" })), jsxRuntime.jsx("button", __assign({ className: "cta flex h-32 lh-32-imp ml-12", "data-testid": "save-tags-button", type: "button", onClick: function (e) {
@@ -23235,6 +23357,7 @@ exports.ScanVulnerabilitiesTable = ScanVulnerabilitiesTable;
23235
23357
  exports.ServerError = ServerError;
23236
23358
  exports.ServerErrors = ServerErrors;
23237
23359
  exports.SingleSelectOption = SingleSelectOption;
23360
+ exports.SourceTypeMap = SourceTypeMap;
23238
23361
  exports.StyledRadioGroup = RadioGroup;
23239
23362
  exports.TOAST_ACCESS_DENIED = TOAST_ACCESS_DENIED;
23240
23363
  exports.TOKEN_COOKIE_NAME = TOKEN_COOKIE_NAME;
@@ -23250,8 +23373,11 @@ exports.TriggerTypeMap = TriggerTypeMap;
23250
23373
  exports.URLS = URLS;
23251
23374
  exports.VisibleModal = VisibleModal;
23252
23375
  exports.VisibleModal2 = VisibleModal2;
23376
+ exports.createGitCommitUrl = createGitCommitUrl;
23377
+ exports.extractImage = extractImage;
23253
23378
  exports.get = get;
23254
23379
  exports.getAlphabetIcon = getAlphabetIcon;
23380
+ exports.getCDMaterials = getCDMaterials;
23255
23381
  exports.getCookie = getCookie;
23256
23382
  exports.getEmptyArrayOfLength = getEmptyArrayOfLength;
23257
23383
  exports.getLoginInfo = getLoginInfo;
@@ -23273,4 +23399,5 @@ exports.trash = trash;
23273
23399
  exports.useBreadcrumb = useBreadcrumb;
23274
23400
  exports.useEffectAfterMount = useEffectAfterMount;
23275
23401
  exports.useForm = useForm;
23402
+ exports.useSearchString = useSearchString;
23276
23403
  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.17",
3
+ "version": "0.0.18-beta-2",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,7 +1,8 @@
1
+ import moment from 'moment';
1
2
  import {get, post} from './Api';
2
3
  import { ROUTES } from './Constants'
3
4
  import { sortCallback } from './Helper';
4
- import { TeamList ,ResponseType } from './Types';
5
+ import { TeamList ,ResponseType, DeploymentNodeType, CDModalTab } from './Types';
5
6
 
6
7
  export const getTeamListMin = (): Promise<TeamList> => {
7
8
  // ignore active field
@@ -29,10 +30,128 @@ interface UserRole extends ResponseType {
29
30
  }
30
31
  }
31
32
 
33
+ let stageMap = {
34
+ PRECD: 'PRE',
35
+ CD: 'DEPLOY',
36
+ POSTCD: 'POST',
37
+ APPROVAL: 'APPROVAL',
38
+ }
39
+
40
+ export const SourceTypeMap = {
41
+ BranchFixed: 'SOURCE_TYPE_BRANCH_FIXED',
42
+ WEBHOOK: 'WEBHOOK',
43
+ BranchRegex: 'SOURCE_TYPE_BRANCH_REGEX',
44
+ }
45
+
32
46
  export function getUserRole(appName?: string): Promise<UserRole> {
33
47
  return get(`${ROUTES.USER_CHECK_ROLE}${appName ? `?appName=${appName}` : ''}`)
34
48
  }
35
49
 
36
50
  export function setImageTags(request, pipelineId: number, artifactId: number){
37
51
  return post(`${ROUTES.IMAGE_TAGGING}/${pipelineId}/${artifactId}`,request )
38
- }
52
+ }
53
+
54
+ export const getCDMaterials = (
55
+ cdMaterialId,
56
+ stageType: DeploymentNodeType,
57
+ abortSignal: AbortSignal,
58
+ isApprovalNode?: boolean,
59
+ imageTag?: string): Promise<any> => {
60
+ const URL = (!imageTag) ? `app/cd-pipeline/${cdMaterialId}/material?stage=${stageMap[stageType]}` : `app/cd-pipeline/${cdMaterialId}/material?stage=${stageMap[stageType]}&search=${imageTag}`
61
+
62
+ return get(URL, {
63
+ signal: abortSignal,
64
+ }).then((response) => {
65
+ let artifacts = response.result.ci_artifacts ?? []
66
+ if (!response.result) {
67
+ return {
68
+ materials: [],
69
+ }
70
+ }
71
+ else {
72
+ const materials = artifacts.map((material, index) => {
73
+ let artifactStatusValue = ''
74
+ return {
75
+ index,
76
+ id: material.id,
77
+ deployedTime: material.deployed_time
78
+ ? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
79
+ : 'Not Deployed',
80
+ deployedBy: material.deployedBy,
81
+ wfrId: material.wfrId,
82
+ image: extractImage(material.image),
83
+ showChanges: false,
84
+ vulnerabilities: [],
85
+ buildTime: material.build_time || '',
86
+ tab: CDModalTab.Changes,
87
+ showSourceInfo: false,
88
+ deployed: material.deployed || false,
89
+ latest: material.latest || false,
90
+ vulnerabilitiesLoading: true,
91
+ scanned: material.scanned,
92
+ scanEnabled: material.scanEnabled,
93
+ isSelected: !material.vulnerable && index === 0,
94
+ vulnerable: material.vulnerable,
95
+ runningOnParentCd: material.runningOnParentCd,
96
+ artifactStatus: artifactStatusValue,
97
+ userApprovalMetadata: material.userApprovalMetadata,
98
+ triggeredBy: material.triggeredBy,
99
+ isVirtualEnvironment: material.isVirtualEnvironment,
100
+ imageComment: material.imageComment,
101
+ imageReleaseTags: material.imageReleaseTags,
102
+ materialInfo: material.material_info
103
+ ? material.material_info.map((mat) => {
104
+ return {
105
+ modifiedTime: mat.modifiedTime ? moment(mat.modifiedTime).format("ddd, DD MMM YYYY, hh:mm A") : '',
106
+ commitLink: createGitCommitUrl(mat.url, mat.revision),
107
+ author: mat.author || '',
108
+ message: mat.message || '',
109
+ revision: mat.revision || '',
110
+ tag: mat.tag || '',
111
+ webhookData: mat.webhookData || '',
112
+ url: mat.url || '',
113
+ branch:
114
+ (material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
115
+ ? material.ciConfigureSourceValue
116
+ : mat.branch) || '',
117
+ type: material.ciConfigureSourceType || '',
118
+ }
119
+ })
120
+ : [],
121
+ }
122
+ })
123
+ return {
124
+ materials: materials
125
+ }
126
+ }
127
+ })
128
+ }
129
+
130
+ export function extractImage(image: string): string {
131
+ return image ? image.split(':').pop() : ''
132
+ }
133
+
134
+ export function createGitCommitUrl(url: string, revision: string): string {
135
+ if (!url || !revision) {
136
+ return "NA"
137
+ }
138
+ if (url.indexOf("gitlab") > 0 || url.indexOf("github") > 0 || url.indexOf("azure") > 0) {
139
+ let urlpart = url.split("@")
140
+ if (urlpart.length > 1) {
141
+ return "https://" + urlpart[1].split(".git")[0] + "/commit/" + revision
142
+ }
143
+ if (urlpart.length == 1) {
144
+ return urlpart[0].split(".git")[0] + "/commit/" + revision
145
+ }
146
+ }
147
+ if (url.indexOf("bitbucket") > 0) {
148
+ let urlpart = url.split("@")
149
+ if (urlpart.length > 1) {
150
+ return "https://" + urlpart[1].split(".git")[0] + "/commits/" + revision
151
+ }
152
+ if (urlpart.length == 1) {
153
+ return urlpart[0].split(".git")[0] + "/commits/" + revision
154
+ }
155
+ }
156
+ return "NA"
157
+ }
@@ -19,7 +19,6 @@ function GenericEmptyState({
19
19
  SvgImage,
20
20
  noImage
21
21
  }: GenericEmptyStateType): JSX.Element {
22
- console.log(image);
23
22
 
24
23
  return (
25
24
  <div
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect, useRef, useState } from 'react'
1
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
2
2
  import { ServerErrors } from './ServerError'
3
3
  import { toast } from 'react-toastify'
4
4
  import * as Sentry from '@sentry/browser'
@@ -6,6 +6,8 @@ import { toastAccessDenied } from './ToastBody'
6
6
  import { ERROR_EMPTY_SCREEN, TOKEN_COOKIE_NAME } from './Constants'
7
7
  import { ReactComponent as FormError } from '../Assets/Icon/ic-warning.svg'
8
8
  import moment from 'moment';
9
+ import { UseSearchString } from './Types'
10
+ import { useLocation } from 'react-router-dom'
9
11
 
10
12
  toast.configure({
11
13
  autoClose: 3000,
@@ -346,3 +348,24 @@ export function handleUTCTime(ts: string, isRelativeTime = false) {
346
348
  }
347
349
  return timestamp;
348
350
  }
351
+
352
+ export function useSearchString(): UseSearchString {
353
+ const location = useLocation()
354
+ const queryParams: URLSearchParams = useMemo(() => {
355
+ const queryParams = new URLSearchParams(location.search)
356
+ return queryParams
357
+ }, [location])
358
+
359
+ // const searchParams={}
360
+ // for (let [key, value] of queryParams.entries()){
361
+ // searchParams[key]=value
362
+ // }
363
+ const searchParams = Array.from(queryParams.entries()).reduce((agg, curr, idx) => {
364
+ agg[curr[0]] = curr[1]
365
+ return agg
366
+ }, {})
367
+
368
+ return { queryParams, searchParams }
369
+ }
370
+
371
+
@@ -352,7 +352,7 @@ export const ImageTagsContainer = ({
352
352
  </div>
353
353
  <div className="mt-6 dc__position-rel-imp" data-testid="add-tag-text-area">
354
354
  <input
355
- className="form__input"
355
+ className="form__input fs-13"
356
356
  value={textInput}
357
357
  onChange={setInputValue}
358
358
  placeholder="Type a tag and press enter"
@@ -420,7 +420,7 @@ export const ImageTagsContainer = ({
420
420
  <textarea
421
421
  value={newDescription}
422
422
  onChange={handleDescriptionChange}
423
- className="flex left flex-wrap dc__gap-8 dc__description-textarea"
423
+ className="flex left flex-wrap dc__gap-8 dc__description-textarea fs-13"
424
424
  style={{ height: '90px !important' }}
425
425
  />
426
426
  </div>
@@ -4,15 +4,14 @@
4
4
  width: 100%;
5
5
  height: 100%;
6
6
 
7
- &.disabled{
7
+ &.disabled {
8
8
  cursor: not-allowed;
9
- .toggle__slider{
9
+ .toggle__slider {
10
10
  cursor: not-allowed;
11
11
  }
12
12
  }
13
13
  }
14
14
 
15
-
16
15
  /* Hide default HTML checkbox */
17
16
 
18
17
  .toggle__switch input {
@@ -21,7 +20,6 @@
21
20
  height: 0;
22
21
  }
23
22
 
24
-
25
23
  /* The slider */
26
24
 
27
25
  .toggle__slider {
@@ -32,39 +30,49 @@
32
30
  right: 0;
33
31
  bottom: 0;
34
32
  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
33
  transition: all 0.4s ease;
34
+ &.round {
35
+ border-radius: 34px;
36
+ &:before {
37
+ border-radius: 50%;
38
+ }
39
+ }
40
+ &:before {
41
+ position: absolute;
42
+ content: '';
43
+ height: calc(100% - 8px);
44
+ width: calc(50% - 4px);
45
+ left: 4px;
46
+ bottom: 4px;
47
+ background-color: white;
48
+ transition: all 0.4s ease;
49
+ }
50
+ &.with-icon {
51
+ background-color: var(--N000) !important;
52
+ svg {
53
+ position: absolute;
54
+ content: '';
55
+ top: -1px;
56
+ left: -1px;
57
+ background-color: var(--N300);
58
+ transition: all 0.4s ease;
59
+ }
60
+ }
47
61
  }
48
62
 
49
- input:checked+.toggle__slider {
63
+ input:checked + .toggle__slider {
50
64
  background-color: var(--color);
65
+ &:before {
66
+ transform: translateX(calc(100%));
67
+ }
68
+ &.with-icon {
69
+ svg {
70
+ transform: translateX(calc(100%));
71
+ background-color: var(--color);
72
+ }
73
+ }
51
74
  }
52
75
 
53
- input:focus+.toggle__slider {
76
+ input:focus + .toggle__slider {
54
77
  box-shadow: 0 0 1px var(--color);
55
78
  }
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
- }
@@ -1,25 +1,35 @@
1
- import React from 'react';
2
- import { useEffectAfterMount } from '../Helper';
1
+ import React from 'react'
2
+ import { useEffectAfterMount } from '../Helper'
3
3
  import './Toggle.scss'
4
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);
5
+ const Toggle = ({
6
+ selected = false,
7
+ onSelect = null,
8
+ color = '#36b37e',
9
+ rootClassName = '',
10
+ disabled = false,
11
+ dataTestId = 'handle-toggle-button',
12
+ Icon = null,
13
+ iconClass= '',
14
+ ...props
15
+ }) => {
16
+ const [active, setActive] = React.useState(selected)
7
17
 
8
- useEffectAfterMount(()=>{
9
- if(typeof onSelect === 'function'){
10
- if(active !== selected){
18
+ useEffectAfterMount(() => {
19
+ if (typeof onSelect === 'function') {
20
+ if (active !== selected) {
11
21
  onSelect(active)
12
22
  }
13
23
  }
14
- },[active])
24
+ }, [active])
15
25
 
16
26
  useEffectAfterMount(() => {
17
27
  setActive(selected)
18
28
  }, [selected])
19
29
 
20
- function handleClick(e){
21
- if(!disabled){
22
- setActive(active=>!active)
30
+ function handleClick(e) {
31
+ if (!disabled) {
32
+ setActive((active) => !active)
23
33
  }
24
34
  }
25
35
 
@@ -30,9 +40,11 @@ const Toggle = ({selected=false, onSelect=null, color="#36b37e", rootClassName="
30
40
  style={{ ['--color' as any]: color }}
31
41
  >
32
42
  <input type="checkbox" checked={!!active} onChange={handleClick} className="toggle__input" />
33
- <span className="toggle__slider round" data-testid={dataTestId}></span>
43
+ <span className={`toggle__slider ${Icon ? 'with-icon br-4 dc__border' : 'round'}`} data-testid={dataTestId}>
44
+ {Icon && <Icon className={`icon-dim-20 br-4 p-2 ${iconClass}`} />}
45
+ </span>
34
46
  </label>
35
47
  )
36
48
  }
37
49
 
38
- export default Toggle
50
+ export default Toggle
@@ -364,4 +364,11 @@ export interface RegistryTypeDetailType {
364
364
  registryURL: InputDetailType
365
365
  id: InputDetailType
366
366
  password: InputDetailType
367
+ }
368
+
369
+ export interface UseSearchString {
370
+ queryParams: URLSearchParams
371
+ searchParams: {
372
+ [key: string]: string
373
+ }
367
374
  }