@devtron-labs/devtron-fe-common-lib 0.0.17-beta-12 → 0.0.17-beta-18

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, DeploymentNodeType } from './Types';
1
+ import { TeamList, ResponseType } from './Types';
2
2
  export declare const getTeamListMin: () => Promise<TeamList>;
3
3
  interface UserRole extends ResponseType {
4
4
  result?: {
@@ -6,14 +6,6 @@ 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
- };
14
9
  export declare function getUserRole(appName?: string): Promise<UserRole>;
15
10
  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;
19
11
  export {};
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import { UseSearchString } from './Types';
3
2
  export declare function showError(serverError: any, showToastOnUnknownError?: boolean, hideAccessError?: boolean): void;
4
3
  interface ConditionalWrapper<T> {
5
4
  condition: boolean;
@@ -41,5 +40,4 @@ export declare function CustomInput({ name, value, error, onChange, onBlur, onFo
41
40
  dataTestid?: string;
42
41
  }): JSX.Element;
43
42
  export declare function handleUTCTime(ts: string, isRelativeTime?: boolean): string;
44
- export declare function useSearchString(): UseSearchString;
45
43
  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, ...props }: {
4
4
  [x: string]: any;
5
5
  selected?: boolean;
6
6
  onSelect?: any;
@@ -8,5 +8,6 @@ declare const Toggle: ({ selected, onSelect, color, rootClassName, disabled, dat
8
8
  rootClassName?: string;
9
9
  disabled?: boolean;
10
10
  dataTestId?: string;
11
+ Icon?: any;
11
12
  }) => JSX.Element;
12
13
  export default Toggle;
@@ -332,10 +332,4 @@ 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
- }
341
335
  export {};
package/dist/index.js CHANGED
@@ -2162,6 +2162,7 @@ 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);
2165
2166
  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] })));
2166
2167
  }
2167
2168
 
@@ -10078,22 +10079,6 @@ function handleUTCTime(ts, isRelativeTime) {
10078
10079
  console.error("Error Parsing Date:", ts);
10079
10080
  }
10080
10081
  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 };
10097
10082
  }
10098
10083
 
10099
10084
  function Progressing(_a) {
@@ -22539,117 +22524,11 @@ var getTeamListMin = function () {
22539
22524
  };
22540
22525
  });
22541
22526
  };
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
- };
22553
22527
  function getUserRole(appName) {
22554
22528
  return get("".concat(ROUTES.USER_CHECK_ROLE).concat(appName ? "?appName=".concat(appName) : ''));
22555
22529
  }
22556
22530
  function setImageTags(request, pipelineId, artifactId) {
22557
22531
  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
- showSourceInfo: false,
22587
- deployed: material.deployed || false,
22588
- latest: material.latest || false,
22589
- vulnerabilitiesLoading: true,
22590
- scanned: material.scanned,
22591
- scanEnabled: material.scanEnabled,
22592
- isSelected: !material.vulnerable && index === 0,
22593
- vulnerable: material.vulnerable,
22594
- runningOnParentCd: material.runningOnParentCd,
22595
- artifactStatus: artifactStatusValue,
22596
- userApprovalMetadata: material.userApprovalMetadata,
22597
- triggeredBy: material.triggeredBy,
22598
- isVirtualEnvironment: material.isVirtualEnvironment,
22599
- imageComment: material.imageComment,
22600
- imageReleaseTags: material.imageReleaseTags,
22601
- materialInfo: material.material_info
22602
- ? material.material_info.map(function (mat) {
22603
- return {
22604
- modifiedTime: mat.modifiedTime ? moment(mat.modifiedTime).format("ddd, DD MMM YYYY, hh:mm A") : '',
22605
- commitLink: createGitCommitUrl(mat.url, mat.revision),
22606
- author: mat.author || '',
22607
- message: mat.message || '',
22608
- revision: mat.revision || '',
22609
- tag: mat.tag || '',
22610
- webhookData: mat.webhookData || '',
22611
- url: mat.url || '',
22612
- branch: (material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
22613
- ? material.ciConfigureSourceValue
22614
- : mat.branch) || '',
22615
- type: material.ciConfigureSourceType || '',
22616
- };
22617
- })
22618
- : [],
22619
- };
22620
- });
22621
- return {
22622
- materials: materials
22623
- };
22624
- }
22625
- });
22626
- };
22627
- function extractImage(image) {
22628
- return image ? image.split(':').pop() : '';
22629
- }
22630
- function createGitCommitUrl(url, revision) {
22631
- if (!url || !revision) {
22632
- return "NA";
22633
- }
22634
- if (url.indexOf("gitlab") > 0 || url.indexOf("github") > 0 || url.indexOf("azure") > 0) {
22635
- var urlpart = url.split("@");
22636
- if (urlpart.length > 1) {
22637
- return "https://" + urlpart[1].split(".git")[0] + "/commit/" + revision;
22638
- }
22639
- if (urlpart.length == 1) {
22640
- return urlpart[0].split(".git")[0] + "/commit/" + revision;
22641
- }
22642
- }
22643
- if (url.indexOf("bitbucket") > 0) {
22644
- var urlpart = url.split("@");
22645
- if (urlpart.length > 1) {
22646
- return "https://" + urlpart[1].split(".git")[0] + "/commits/" + revision;
22647
- }
22648
- if (urlpart.length == 1) {
22649
- return urlpart[0].split(".git")[0] + "/commits/" + revision;
22650
- }
22651
- }
22652
- return "NA";
22653
22532
  }
22654
22533
 
22655
22534
  /*
@@ -22674,13 +22553,13 @@ var Checkbox = /** @class */ (function (_super) {
22674
22553
  return Checkbox;
22675
22554
  }(React.Component));
22676
22555
 
22677
- 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}";
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.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}";
22678
22557
  styleInject(css_248z$2);
22679
22558
 
22680
22559
  var Toggle = function (_a) {
22681
22560
  var _b;
22682
- 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"]);
22683
- var _j = __read(React.useState(selected), 2), active = _j[0], setActive = _j[1];
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, _j = _a.Icon, Icon = _j === void 0 ? null : _j, props = __rest(_a, ["selected", "onSelect", "color", "rootClassName", "disabled", "dataTestId", "Icon"]);
22562
+ var _k = __read(React.useState(selected), 2), active = _k[0], setActive = _k[1];
22684
22563
  useEffectAfterMount(function () {
22685
22564
  if (typeof onSelect === 'function') {
22686
22565
  if (active !== selected) {
@@ -22696,7 +22575,7 @@ var Toggle = function (_a) {
22696
22575
  setActive(function (active) { return !active; });
22697
22576
  }
22698
22577
  }
22699
- 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 })] })));
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", __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" }) }))] })));
22700
22579
  };
22701
22580
 
22702
22581
  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}";
@@ -23251,7 +23130,7 @@ var ImageTagsContainer = function (_a) {
23251
23130
  }
23252
23131
  handleSave(tagsToBeCreated);
23253
23132
  };
23254
- 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: {
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
23134
  top: '50%',
23256
23135
  fontFamily: 'monospace',
23257
23136
  right: '8px',
@@ -23262,7 +23141,7 @@ var ImageTagsContainer = function (_a) {
23262
23141
  }, onHardDeleteClick: function (e) {
23263
23142
  stopPropagation(e);
23264
23143
  handleTagHardDelete(index);
23265
- }, 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) {
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
23145
  stopPropagation(e);
23267
23146
  handleCancel();
23268
23147
  } }, { 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) {
@@ -23356,7 +23235,6 @@ exports.ScanVulnerabilitiesTable = ScanVulnerabilitiesTable;
23356
23235
  exports.ServerError = ServerError;
23357
23236
  exports.ServerErrors = ServerErrors;
23358
23237
  exports.SingleSelectOption = SingleSelectOption;
23359
- exports.SourceTypeMap = SourceTypeMap;
23360
23238
  exports.StyledRadioGroup = RadioGroup;
23361
23239
  exports.TOAST_ACCESS_DENIED = TOAST_ACCESS_DENIED;
23362
23240
  exports.TOKEN_COOKIE_NAME = TOKEN_COOKIE_NAME;
@@ -23372,11 +23250,8 @@ exports.TriggerTypeMap = TriggerTypeMap;
23372
23250
  exports.URLS = URLS;
23373
23251
  exports.VisibleModal = VisibleModal;
23374
23252
  exports.VisibleModal2 = VisibleModal2;
23375
- exports.createGitCommitUrl = createGitCommitUrl;
23376
- exports.extractImage = extractImage;
23377
23253
  exports.get = get;
23378
23254
  exports.getAlphabetIcon = getAlphabetIcon;
23379
- exports.getCDMaterials = getCDMaterials;
23380
23255
  exports.getCookie = getCookie;
23381
23256
  exports.getEmptyArrayOfLength = getEmptyArrayOfLength;
23382
23257
  exports.getLoginInfo = getLoginInfo;
@@ -23398,5 +23273,4 @@ exports.trash = trash;
23398
23273
  exports.useBreadcrumb = useBreadcrumb;
23399
23274
  exports.useEffectAfterMount = useEffectAfterMount;
23400
23275
  exports.useForm = useForm;
23401
- exports.useSearchString = useSearchString;
23402
23276
  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-beta-12",
3
+ "version": "v0.0.17-beta-18",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,8 +1,7 @@
1
- import moment from 'moment';
2
1
  import {get, post} from './Api';
3
2
  import { ROUTES } from './Constants'
4
3
  import { sortCallback } from './Helper';
5
- import { TeamList ,ResponseType, DeploymentNodeType } from './Types';
4
+ import { TeamList ,ResponseType } from './Types';
6
5
 
7
6
  export const getTeamListMin = (): Promise<TeamList> => {
8
7
  // ignore active field
@@ -30,127 +29,10 @@ interface UserRole extends ResponseType {
30
29
  }
31
30
  }
32
31
 
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
-
46
32
  export function getUserRole(appName?: string): Promise<UserRole> {
47
33
  return get(`${ROUTES.USER_CHECK_ROLE}${appName ? `?appName=${appName}` : ''}`)
48
34
  }
49
35
 
50
36
  export function setImageTags(request, pipelineId: number, artifactId: number){
51
37
  return post(`${ROUTES.IMAGE_TAGGING}/${pipelineId}/${artifactId}`,request )
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
- showSourceInfo: false,
87
- deployed: material.deployed || false,
88
- latest: material.latest || false,
89
- vulnerabilitiesLoading: true,
90
- scanned: material.scanned,
91
- scanEnabled: material.scanEnabled,
92
- isSelected: !material.vulnerable && index === 0,
93
- vulnerable: material.vulnerable,
94
- runningOnParentCd: material.runningOnParentCd,
95
- artifactStatus: artifactStatusValue,
96
- userApprovalMetadata: material.userApprovalMetadata,
97
- triggeredBy: material.triggeredBy,
98
- isVirtualEnvironment: material.isVirtualEnvironment,
99
- imageComment: material.imageComment,
100
- imageReleaseTags: material.imageReleaseTags,
101
- materialInfo: material.material_info
102
- ? material.material_info.map((mat) => {
103
- return {
104
- modifiedTime: mat.modifiedTime ? moment(mat.modifiedTime).format("ddd, DD MMM YYYY, hh:mm A") : '',
105
- commitLink: createGitCommitUrl(mat.url, mat.revision),
106
- author: mat.author || '',
107
- message: mat.message || '',
108
- revision: mat.revision || '',
109
- tag: mat.tag || '',
110
- webhookData: mat.webhookData || '',
111
- url: mat.url || '',
112
- branch:
113
- (material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
114
- ? material.ciConfigureSourceValue
115
- : mat.branch) || '',
116
- type: material.ciConfigureSourceType || '',
117
- }
118
- })
119
- : [],
120
- }
121
- })
122
- return {
123
- materials: materials
124
- }
125
- }
126
- })
127
- }
128
-
129
- export function extractImage(image: string): string {
130
- return image ? image.split(':').pop() : ''
131
- }
132
-
133
- export function createGitCommitUrl(url: string, revision: string): string {
134
- if (!url || !revision) {
135
- return "NA"
136
- }
137
- if (url.indexOf("gitlab") > 0 || url.indexOf("github") > 0 || url.indexOf("azure") > 0) {
138
- let urlpart = url.split("@")
139
- if (urlpart.length > 1) {
140
- return "https://" + urlpart[1].split(".git")[0] + "/commit/" + revision
141
- }
142
- if (urlpart.length == 1) {
143
- return urlpart[0].split(".git")[0] + "/commit/" + revision
144
- }
145
- }
146
- if (url.indexOf("bitbucket") > 0) {
147
- let urlpart = url.split("@")
148
- if (urlpart.length > 1) {
149
- return "https://" + urlpart[1].split(".git")[0] + "/commits/" + revision
150
- }
151
- if (urlpart.length == 1) {
152
- return urlpart[0].split(".git")[0] + "/commits/" + revision
153
- }
154
- }
155
- return "NA"
156
- }
38
+ }
@@ -19,6 +19,7 @@ function GenericEmptyState({
19
19
  SvgImage,
20
20
  noImage
21
21
  }: GenericEmptyStateType): JSX.Element {
22
+ console.log(image);
22
23
 
23
24
  return (
24
25
  <div
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
1
+ import React, { useCallback, useEffect, 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,8 +6,6 @@ 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'
11
9
 
12
10
  toast.configure({
13
11
  autoClose: 3000,
@@ -348,24 +346,3 @@ export function handleUTCTime(ts: string, isRelativeTime = false) {
348
346
  }
349
347
  return timestamp;
350
348
  }
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 fs-13"
355
+ className="form__input"
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 fs-13"
423
+ className="flex left flex-wrap dc__gap-8 dc__description-textarea"
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,34 @@
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
+ ...props
14
+ }) => {
15
+ const [active, setActive] = React.useState(selected)
7
16
 
8
- useEffectAfterMount(()=>{
9
- if(typeof onSelect === 'function'){
10
- if(active !== selected){
17
+ useEffectAfterMount(() => {
18
+ if (typeof onSelect === 'function') {
19
+ if (active !== selected) {
11
20
  onSelect(active)
12
21
  }
13
22
  }
14
- },[active])
23
+ }, [active])
15
24
 
16
25
  useEffectAfterMount(() => {
17
26
  setActive(selected)
18
27
  }, [selected])
19
28
 
20
- function handleClick(e){
21
- if(!disabled){
22
- setActive(active=>!active)
29
+ function handleClick(e) {
30
+ if (!disabled) {
31
+ setActive((active) => !active)
23
32
  }
24
33
  }
25
34
 
@@ -30,9 +39,11 @@ const Toggle = ({selected=false, onSelect=null, color="#36b37e", rootClassName="
30
39
  style={{ ['--color' as any]: color }}
31
40
  >
32
41
  <input type="checkbox" checked={!!active} onChange={handleClick} className="toggle__input" />
33
- <span className="toggle__slider round" data-testid={dataTestId}></span>
42
+ <span className={`toggle__slider ${Icon ? 'with-icon br-4 dc__border' : 'round'}`} data-testid={dataTestId}>
43
+ {Icon && <Icon className="icon-dim-20 br-4" />}
44
+ </span>
34
45
  </label>
35
46
  )
36
47
  }
37
48
 
38
- export default Toggle
49
+ export default Toggle
@@ -364,11 +364,4 @@ 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
- }
374
367
  }