@devtron-labs/devtron-fe-common-lib 0.0.17-beta-11 → 0.0.17-beta-12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Common/Common.service.d.ts +9 -1
- package/dist/Common/Helper.d.ts +2 -0
- package/dist/Common/Types.d.ts +5 -14
- package/dist/Common/index.d.ts +0 -1
- package/dist/index.js +129 -39
- package/package.json +1 -1
- package/src/Common/Common.service.ts +120 -2
- package/src/Common/EmptyState/GenericEmptyState.tsx +0 -1
- package/src/Common/Helper.tsx +24 -1
- package/src/Common/ImageTags.tsx +2 -2
- package/src/Common/Types.ts +5 -14
- package/src/Common/index.ts +0 -1
- package/dist/Common/ResizableTextarea.d.ts +0 -3
- package/src/Common/ResizableTextarea.tsx +0 -73
|
@@ -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 {};
|
package/dist/Common/Helper.d.ts
CHANGED
|
@@ -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 {};
|
package/dist/Common/Types.d.ts
CHANGED
|
@@ -332,19 +332,10 @@ export interface RegistryTypeDetailType {
|
|
|
332
332
|
id: InputDetailType;
|
|
333
333
|
password: InputDetailType;
|
|
334
334
|
}
|
|
335
|
-
export interface
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
onBlur?: (e: any) => void;
|
|
341
|
-
onFocus?: (e: any) => void;
|
|
342
|
-
className?: string;
|
|
343
|
-
placeholder?: string;
|
|
344
|
-
lineHeight?: number;
|
|
345
|
-
padding?: number;
|
|
346
|
-
disabled?: boolean;
|
|
347
|
-
name?: string;
|
|
348
|
-
dataTestId?: string;
|
|
335
|
+
export interface UseSearchString {
|
|
336
|
+
queryParams: URLSearchParams;
|
|
337
|
+
searchParams: {
|
|
338
|
+
[key: string]: string;
|
|
339
|
+
};
|
|
349
340
|
}
|
|
350
341
|
export {};
|
package/dist/Common/index.d.ts
CHANGED
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,117 @@ 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
|
+
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";
|
|
22532
22653
|
}
|
|
22533
22654
|
|
|
22534
22655
|
/*
|
|
@@ -23130,7 +23251,7 @@ var ImageTagsContainer = function (_a) {
|
|
|
23130
23251
|
}
|
|
23131
23252
|
handleSave(tagsToBeCreated);
|
|
23132
23253
|
};
|
|
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: {
|
|
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: {
|
|
23134
23255
|
top: '50%',
|
|
23135
23256
|
fontFamily: 'monospace',
|
|
23136
23257
|
right: '8px',
|
|
@@ -23141,7 +23262,7 @@ var ImageTagsContainer = function (_a) {
|
|
|
23141
23262
|
}, onHardDeleteClick: function (e) {
|
|
23142
23263
|
stopPropagation(e);
|
|
23143
23264
|
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) {
|
|
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) {
|
|
23145
23266
|
stopPropagation(e);
|
|
23146
23267
|
handleCancel();
|
|
23147
23268
|
} }, { 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) {
|
|
@@ -23185,41 +23306,6 @@ var AddImageButton = function (_a) {
|
|
|
23185
23306
|
return (jsxRuntime.jsx("div", __assign({ className: "add-tag-button flex pt-12 pr-12", "data-testid": "add-tags-button", onClick: handleClick }, { children: jsxRuntime.jsxs("div", __assign({ className: "lh-16 flex" }, { children: [jsxRuntime.jsx(SvgIcAdd, { className: "icon-dim-16 cn-6" }), jsxRuntime.jsx("span", __assign({ className: "cn-7" }, { children: "Add tags/comment" }))] })) })));
|
|
23186
23307
|
};
|
|
23187
23308
|
|
|
23188
|
-
var ResizableTextarea = function (_a) {
|
|
23189
|
-
var minHeight = _a.minHeight, maxHeight = _a.maxHeight, value = _a.value, _b = _a.onChange, onChange = _b === void 0 ? null : _b, _c = _a.onBlur, onBlur = _c === void 0 ? null : _c, _d = _a.onFocus, onFocus = _d === void 0 ? null : _d, _e = _a.className, className = _e === void 0 ? '' : _e, _f = _a.placeholder, placeholder = _f === void 0 ? 'Enter your text here..' : _f, _g = _a.lineHeight, lineHeight = _g === void 0 ? 14 : _g, _h = _a.padding, padding = _h === void 0 ? 12 : _h, _j = _a.disabled, disabled = _j === void 0 ? false : _j, dataTestId = _a.dataTestId, props = __rest(_a, ["minHeight", "maxHeight", "value", "onChange", "onBlur", "onFocus", "className", "placeholder", "lineHeight", "padding", "disabled", "dataTestId"]);
|
|
23190
|
-
var _k = __read(React.useState(''), 2), text = _k[0], setText = _k[1];
|
|
23191
|
-
var _textRef = React.useRef(null);
|
|
23192
|
-
React.useEffect(function () {
|
|
23193
|
-
setText(value);
|
|
23194
|
-
}, [value]);
|
|
23195
|
-
function handleChange(e) {
|
|
23196
|
-
e.persist();
|
|
23197
|
-
setText(e.target.value);
|
|
23198
|
-
if (typeof onChange === 'function')
|
|
23199
|
-
onChange(e);
|
|
23200
|
-
}
|
|
23201
|
-
function handleBlur(e) {
|
|
23202
|
-
if (typeof onBlur === 'function')
|
|
23203
|
-
onBlur(e);
|
|
23204
|
-
}
|
|
23205
|
-
function handleFocus(e) {
|
|
23206
|
-
if (typeof onFocus === 'function')
|
|
23207
|
-
onFocus(e);
|
|
23208
|
-
}
|
|
23209
|
-
useThrottledEffect(function () {
|
|
23210
|
-
_textRef.current.style.height = 'auto';
|
|
23211
|
-
var nextHeight = _textRef.current.scrollHeight;
|
|
23212
|
-
if (minHeight && nextHeight < minHeight) {
|
|
23213
|
-
nextHeight = minHeight;
|
|
23214
|
-
}
|
|
23215
|
-
if (maxHeight && nextHeight > maxHeight) {
|
|
23216
|
-
nextHeight = maxHeight;
|
|
23217
|
-
}
|
|
23218
|
-
_textRef.current.style.height = nextHeight + 2 + 'px';
|
|
23219
|
-
}, 500, [text]);
|
|
23220
|
-
return (jsxRuntime.jsx("textarea", __assign({ "data-testid": dataTestId, ref: function (el) { return (_textRef.current = el); }, value: text, placeholder: placeholder, className: "dc__resizable-textarea ".concat(className), onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, style: { lineHeight: "".concat(lineHeight, "px"), padding: "".concat(padding, "px") }, spellCheck: false, disabled: disabled }, props)));
|
|
23221
|
-
};
|
|
23222
|
-
|
|
23223
23309
|
exports.BreadCrumb = BreadCrumb;
|
|
23224
23310
|
exports.BreadcrumbStore = Store;
|
|
23225
23311
|
exports.BuildStageVariable = BuildStageVariable;
|
|
@@ -23266,11 +23352,11 @@ exports.RadioGroupItem = RadioGroupItem;
|
|
|
23266
23352
|
exports.Reload = Reload;
|
|
23267
23353
|
exports.RequestTimeout = RequestTimeout;
|
|
23268
23354
|
exports.ResizableTagTextArea = ResizableTagTextArea;
|
|
23269
|
-
exports.ResizableTextarea = ResizableTextarea;
|
|
23270
23355
|
exports.ScanVulnerabilitiesTable = ScanVulnerabilitiesTable;
|
|
23271
23356
|
exports.ServerError = ServerError;
|
|
23272
23357
|
exports.ServerErrors = ServerErrors;
|
|
23273
23358
|
exports.SingleSelectOption = SingleSelectOption;
|
|
23359
|
+
exports.SourceTypeMap = SourceTypeMap;
|
|
23274
23360
|
exports.StyledRadioGroup = RadioGroup;
|
|
23275
23361
|
exports.TOAST_ACCESS_DENIED = TOAST_ACCESS_DENIED;
|
|
23276
23362
|
exports.TOKEN_COOKIE_NAME = TOKEN_COOKIE_NAME;
|
|
@@ -23286,8 +23372,11 @@ exports.TriggerTypeMap = TriggerTypeMap;
|
|
|
23286
23372
|
exports.URLS = URLS;
|
|
23287
23373
|
exports.VisibleModal = VisibleModal;
|
|
23288
23374
|
exports.VisibleModal2 = VisibleModal2;
|
|
23375
|
+
exports.createGitCommitUrl = createGitCommitUrl;
|
|
23376
|
+
exports.extractImage = extractImage;
|
|
23289
23377
|
exports.get = get;
|
|
23290
23378
|
exports.getAlphabetIcon = getAlphabetIcon;
|
|
23379
|
+
exports.getCDMaterials = getCDMaterials;
|
|
23291
23380
|
exports.getCookie = getCookie;
|
|
23292
23381
|
exports.getEmptyArrayOfLength = getEmptyArrayOfLength;
|
|
23293
23382
|
exports.getLoginInfo = getLoginInfo;
|
|
@@ -23309,4 +23398,5 @@ exports.trash = trash;
|
|
|
23309
23398
|
exports.useBreadcrumb = useBreadcrumb;
|
|
23310
23399
|
exports.useEffectAfterMount = useEffectAfterMount;
|
|
23311
23400
|
exports.useForm = useForm;
|
|
23401
|
+
exports.useSearchString = useSearchString;
|
|
23312
23402
|
exports.useThrottledEffect = useThrottledEffect;
|
package/package.json
CHANGED
|
@@ -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 } from './Types';
|
|
5
6
|
|
|
6
7
|
export const getTeamListMin = (): Promise<TeamList> => {
|
|
7
8
|
// ignore active field
|
|
@@ -29,10 +30,127 @@ 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
|
+
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
|
+
}
|
package/src/Common/Helper.tsx
CHANGED
|
@@ -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
|
+
|
package/src/Common/ImageTags.tsx
CHANGED
|
@@ -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>
|
package/src/Common/Types.ts
CHANGED
|
@@ -366,18 +366,9 @@ export interface RegistryTypeDetailType {
|
|
|
366
366
|
password: InputDetailType
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
-
export interface
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
onBlur?: (e) => void
|
|
375
|
-
onFocus?: (e) => void
|
|
376
|
-
className?: string
|
|
377
|
-
placeholder?: string
|
|
378
|
-
lineHeight?: number
|
|
379
|
-
padding?: number
|
|
380
|
-
disabled?: boolean
|
|
381
|
-
name?: string
|
|
382
|
-
dataTestId?: string
|
|
369
|
+
export interface UseSearchString {
|
|
370
|
+
queryParams: URLSearchParams
|
|
371
|
+
searchParams: {
|
|
372
|
+
[key: string]: string
|
|
373
|
+
}
|
|
383
374
|
}
|
package/src/Common/index.ts
CHANGED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from 'react'
|
|
2
|
-
import { useThrottledEffect } from './Helper'
|
|
3
|
-
import { ResizableTextareaProps } from './Types'
|
|
4
|
-
|
|
5
|
-
export const ResizableTextarea: React.FC<ResizableTextareaProps> = ({
|
|
6
|
-
minHeight,
|
|
7
|
-
maxHeight,
|
|
8
|
-
value,
|
|
9
|
-
onChange = null,
|
|
10
|
-
onBlur = null,
|
|
11
|
-
onFocus = null,
|
|
12
|
-
className = '',
|
|
13
|
-
placeholder = 'Enter your text here..',
|
|
14
|
-
lineHeight = 14,
|
|
15
|
-
padding = 12,
|
|
16
|
-
disabled = false,
|
|
17
|
-
dataTestId,
|
|
18
|
-
...props
|
|
19
|
-
}) => {
|
|
20
|
-
const [text, setText] = useState('')
|
|
21
|
-
const _textRef = useRef(null)
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
setText(value)
|
|
25
|
-
}, [value])
|
|
26
|
-
|
|
27
|
-
function handleChange(e) {
|
|
28
|
-
e.persist()
|
|
29
|
-
setText(e.target.value)
|
|
30
|
-
if (typeof onChange === 'function') onChange(e)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function handleBlur(e) {
|
|
34
|
-
if (typeof onBlur === 'function') onBlur(e)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function handleFocus(e) {
|
|
38
|
-
if (typeof onFocus === 'function') onFocus(e)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
useThrottledEffect(
|
|
42
|
-
() => {
|
|
43
|
-
_textRef.current.style.height = 'auto'
|
|
44
|
-
let nextHeight = _textRef.current.scrollHeight
|
|
45
|
-
if (minHeight && nextHeight < minHeight) {
|
|
46
|
-
nextHeight = minHeight
|
|
47
|
-
}
|
|
48
|
-
if (maxHeight && nextHeight > maxHeight) {
|
|
49
|
-
nextHeight = maxHeight
|
|
50
|
-
}
|
|
51
|
-
_textRef.current.style.height = nextHeight + 2 + 'px'
|
|
52
|
-
},
|
|
53
|
-
500,
|
|
54
|
-
[text],
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<textarea
|
|
59
|
-
data-testid={dataTestId}
|
|
60
|
-
ref={(el) => (_textRef.current = el)}
|
|
61
|
-
value={text}
|
|
62
|
-
placeholder={placeholder}
|
|
63
|
-
className={`dc__resizable-textarea ${className}`}
|
|
64
|
-
onChange={handleChange}
|
|
65
|
-
onBlur={handleBlur}
|
|
66
|
-
onFocus={handleFocus}
|
|
67
|
-
style={{ lineHeight: `${lineHeight}px`, padding: `${padding}px` }}
|
|
68
|
-
spellCheck={false}
|
|
69
|
-
disabled={disabled}
|
|
70
|
-
{...props}
|
|
71
|
-
/>
|
|
72
|
-
)
|
|
73
|
-
}
|