@devtron-labs/devtron-fe-common-lib 0.0.17-beta-11 → 0.0.17-beta-10
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 +3 -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 +93 -39
- package/package.json +1 -1
- package/src/Common/Common.service.ts +82 -1
- 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?: {
|
|
@@ -8,4 +8,6 @@ interface UserRole extends ResponseType {
|
|
|
8
8
|
}
|
|
9
9
|
export declare function getUserRole(appName?: string): Promise<UserRole>;
|
|
10
10
|
export declare function setImageTags(request: any, pipelineId: number, artifactId: number): Promise<ResponseType>;
|
|
11
|
+
export declare const getCDMaterials: (cdMaterialId: any, stageType: DeploymentNodeType, abortSignal: AbortSignal, isApprovalNode?: boolean, imageTag?: string) => Promise<any>;
|
|
12
|
+
export declare function extractImage(image: string): string;
|
|
11
13
|
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,83 @@ 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
|
+
};
|
|
22527
22548
|
function getUserRole(appName) {
|
|
22528
22549
|
return get("".concat(ROUTES.USER_CHECK_ROLE).concat(appName ? "?appName=".concat(appName) : ''));
|
|
22529
22550
|
}
|
|
22530
22551
|
function setImageTags(request, pipelineId, artifactId) {
|
|
22531
22552
|
return post("".concat(ROUTES.IMAGE_TAGGING, "/").concat(pipelineId, "/").concat(artifactId), request);
|
|
22553
|
+
}
|
|
22554
|
+
var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalNode, imageTag) {
|
|
22555
|
+
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);
|
|
22556
|
+
return get(URL, {
|
|
22557
|
+
signal: abortSignal,
|
|
22558
|
+
}).then(function (response) {
|
|
22559
|
+
var _a;
|
|
22560
|
+
var artifacts = (_a = response.result.ci_artifacts) !== null && _a !== void 0 ? _a : [];
|
|
22561
|
+
if (!response.result) {
|
|
22562
|
+
return {
|
|
22563
|
+
materials: [],
|
|
22564
|
+
};
|
|
22565
|
+
}
|
|
22566
|
+
else {
|
|
22567
|
+
var materials = artifacts.map(function (material, index) {
|
|
22568
|
+
var artifactStatusValue = '';
|
|
22569
|
+
return {
|
|
22570
|
+
index: index,
|
|
22571
|
+
id: material.id,
|
|
22572
|
+
deployedTime: material.deployed_time
|
|
22573
|
+
? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
|
|
22574
|
+
: 'Not Deployed',
|
|
22575
|
+
deployedBy: material.deployedBy,
|
|
22576
|
+
wfrId: material.wfrId,
|
|
22577
|
+
image: extractImage(material.image),
|
|
22578
|
+
showChanges: false,
|
|
22579
|
+
vulnerabilities: [],
|
|
22580
|
+
buildTime: material.build_time || '',
|
|
22581
|
+
showSourceInfo: false,
|
|
22582
|
+
deployed: material.deployed || false,
|
|
22583
|
+
latest: material.latest || false,
|
|
22584
|
+
vulnerabilitiesLoading: true,
|
|
22585
|
+
scanned: material.scanned,
|
|
22586
|
+
scanEnabled: material.scanEnabled,
|
|
22587
|
+
isSelected: !material.vulnerable && index === 0,
|
|
22588
|
+
vulnerable: material.vulnerable,
|
|
22589
|
+
runningOnParentCd: material.runningOnParentCd,
|
|
22590
|
+
artifactStatus: artifactStatusValue,
|
|
22591
|
+
userApprovalMetadata: material.userApprovalMetadata,
|
|
22592
|
+
triggeredBy: material.triggeredBy,
|
|
22593
|
+
isVirtualEnvironment: material.isVirtualEnvironment,
|
|
22594
|
+
imageComment: material.imageComment,
|
|
22595
|
+
imageReleaseTags: material.imageReleaseTags,
|
|
22596
|
+
materialInfo: material.material_info
|
|
22597
|
+
? material.material_info.map(function (mat) {
|
|
22598
|
+
return {
|
|
22599
|
+
author: mat.author || '',
|
|
22600
|
+
message: mat.message || '',
|
|
22601
|
+
revision: mat.revision || '',
|
|
22602
|
+
tag: mat.tag || '',
|
|
22603
|
+
webhookData: mat.webhookData || '',
|
|
22604
|
+
url: mat.url || '',
|
|
22605
|
+
type: material.ciConfigureSourceType || '',
|
|
22606
|
+
};
|
|
22607
|
+
})
|
|
22608
|
+
: [],
|
|
22609
|
+
};
|
|
22610
|
+
});
|
|
22611
|
+
return {
|
|
22612
|
+
materials: materials
|
|
22613
|
+
};
|
|
22614
|
+
}
|
|
22615
|
+
});
|
|
22616
|
+
};
|
|
22617
|
+
function extractImage(image) {
|
|
22618
|
+
return image ? image.split(':').pop() : '';
|
|
22532
22619
|
}
|
|
22533
22620
|
|
|
22534
22621
|
/*
|
|
@@ -23130,7 +23217,7 @@ var ImageTagsContainer = function (_a) {
|
|
|
23130
23217
|
}
|
|
23131
23218
|
handleSave(tagsToBeCreated);
|
|
23132
23219
|
};
|
|
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: {
|
|
23220
|
+
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
23221
|
top: '50%',
|
|
23135
23222
|
fontFamily: 'monospace',
|
|
23136
23223
|
right: '8px',
|
|
@@ -23141,7 +23228,7 @@ var ImageTagsContainer = function (_a) {
|
|
|
23141
23228
|
}, onHardDeleteClick: function (e) {
|
|
23142
23229
|
stopPropagation(e);
|
|
23143
23230
|
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) {
|
|
23231
|
+
}, 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
23232
|
stopPropagation(e);
|
|
23146
23233
|
handleCancel();
|
|
23147
23234
|
} }, { 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 +23272,6 @@ var AddImageButton = function (_a) {
|
|
|
23185
23272
|
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
23273
|
};
|
|
23187
23274
|
|
|
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
23275
|
exports.BreadCrumb = BreadCrumb;
|
|
23224
23276
|
exports.BreadcrumbStore = Store;
|
|
23225
23277
|
exports.BuildStageVariable = BuildStageVariable;
|
|
@@ -23266,7 +23318,6 @@ exports.RadioGroupItem = RadioGroupItem;
|
|
|
23266
23318
|
exports.Reload = Reload;
|
|
23267
23319
|
exports.RequestTimeout = RequestTimeout;
|
|
23268
23320
|
exports.ResizableTagTextArea = ResizableTagTextArea;
|
|
23269
|
-
exports.ResizableTextarea = ResizableTextarea;
|
|
23270
23321
|
exports.ScanVulnerabilitiesTable = ScanVulnerabilitiesTable;
|
|
23271
23322
|
exports.ServerError = ServerError;
|
|
23272
23323
|
exports.ServerErrors = ServerErrors;
|
|
@@ -23286,8 +23337,10 @@ exports.TriggerTypeMap = TriggerTypeMap;
|
|
|
23286
23337
|
exports.URLS = URLS;
|
|
23287
23338
|
exports.VisibleModal = VisibleModal;
|
|
23288
23339
|
exports.VisibleModal2 = VisibleModal2;
|
|
23340
|
+
exports.extractImage = extractImage;
|
|
23289
23341
|
exports.get = get;
|
|
23290
23342
|
exports.getAlphabetIcon = getAlphabetIcon;
|
|
23343
|
+
exports.getCDMaterials = getCDMaterials;
|
|
23291
23344
|
exports.getCookie = getCookie;
|
|
23292
23345
|
exports.getEmptyArrayOfLength = getEmptyArrayOfLength;
|
|
23293
23346
|
exports.getLoginInfo = getLoginInfo;
|
|
@@ -23309,4 +23362,5 @@ exports.trash = trash;
|
|
|
23309
23362
|
exports.useBreadcrumb = useBreadcrumb;
|
|
23310
23363
|
exports.useEffectAfterMount = useEffectAfterMount;
|
|
23311
23364
|
exports.useForm = useForm;
|
|
23365
|
+
exports.useSearchString = useSearchString;
|
|
23312
23366
|
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,90 @@ 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
|
+
|
|
32
40
|
export function getUserRole(appName?: string): Promise<UserRole> {
|
|
33
41
|
return get(`${ROUTES.USER_CHECK_ROLE}${appName ? `?appName=${appName}` : ''}`)
|
|
34
42
|
}
|
|
35
43
|
|
|
36
44
|
export function setImageTags(request, pipelineId: number, artifactId: number){
|
|
37
45
|
return post(`${ROUTES.IMAGE_TAGGING}/${pipelineId}/${artifactId}`,request )
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const getCDMaterials = (
|
|
49
|
+
cdMaterialId,
|
|
50
|
+
stageType: DeploymentNodeType,
|
|
51
|
+
abortSignal: AbortSignal,
|
|
52
|
+
isApprovalNode?: boolean,
|
|
53
|
+
imageTag?: string): Promise<any> => {
|
|
54
|
+
const URL = (!imageTag) ? `app/cd-pipeline/${cdMaterialId}/material?stage=${stageMap[stageType]}` : `app/cd-pipeline/${cdMaterialId}/material?stage=${stageMap[stageType]}&search=${imageTag}`
|
|
55
|
+
|
|
56
|
+
return get(URL, {
|
|
57
|
+
signal: abortSignal,
|
|
58
|
+
}).then((response) => {
|
|
59
|
+
let artifacts = response.result.ci_artifacts ?? []
|
|
60
|
+
if (!response.result) {
|
|
61
|
+
return {
|
|
62
|
+
materials: [],
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const materials = artifacts.map((material, index) => {
|
|
67
|
+
let artifactStatusValue = ''
|
|
68
|
+
return {
|
|
69
|
+
index,
|
|
70
|
+
id: material.id,
|
|
71
|
+
deployedTime: material.deployed_time
|
|
72
|
+
? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
|
|
73
|
+
: 'Not Deployed',
|
|
74
|
+
deployedBy: material.deployedBy,
|
|
75
|
+
wfrId: material.wfrId,
|
|
76
|
+
image: extractImage(material.image),
|
|
77
|
+
showChanges: false,
|
|
78
|
+
vulnerabilities: [],
|
|
79
|
+
buildTime: material.build_time || '',
|
|
80
|
+
showSourceInfo: false,
|
|
81
|
+
deployed: material.deployed || false,
|
|
82
|
+
latest: material.latest || false,
|
|
83
|
+
vulnerabilitiesLoading: true,
|
|
84
|
+
scanned: material.scanned,
|
|
85
|
+
scanEnabled: material.scanEnabled,
|
|
86
|
+
isSelected: !material.vulnerable && index === 0,
|
|
87
|
+
vulnerable: material.vulnerable,
|
|
88
|
+
runningOnParentCd: material.runningOnParentCd,
|
|
89
|
+
artifactStatus: artifactStatusValue,
|
|
90
|
+
userApprovalMetadata: material.userApprovalMetadata,
|
|
91
|
+
triggeredBy: material.triggeredBy,
|
|
92
|
+
isVirtualEnvironment: material.isVirtualEnvironment,
|
|
93
|
+
imageComment: material.imageComment,
|
|
94
|
+
imageReleaseTags: material.imageReleaseTags,
|
|
95
|
+
materialInfo: material.material_info
|
|
96
|
+
? material.material_info.map((mat) => {
|
|
97
|
+
return {
|
|
98
|
+
author: mat.author || '',
|
|
99
|
+
message: mat.message || '',
|
|
100
|
+
revision: mat.revision || '',
|
|
101
|
+
tag: mat.tag || '',
|
|
102
|
+
webhookData: mat.webhookData || '',
|
|
103
|
+
url: mat.url || '',
|
|
104
|
+
type: material.ciConfigureSourceType || '',
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
: [],
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
return {
|
|
111
|
+
materials: materials
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function extractImage(image: string): string {
|
|
118
|
+
return image ? image.split(':').pop() : ''
|
|
38
119
|
}
|
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
|
-
}
|