@devtron-labs/devtron-fe-common-lib 0.0.34-beta-2 → 0.0.34-beta-3
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 +2 -2
- package/dist/Common/Constants.d.ts +0 -1
- package/dist/Common/ImageTags.Types.d.ts +1 -0
- package/dist/Common/ImageTags.d.ts +1 -1
- package/dist/Common/Types.d.ts +2 -31
- package/dist/index.js +75 -212
- package/package.json +1 -1
- package/src/Common/Common.service.ts +76 -221
- package/src/Common/Constants.ts +0 -1
- package/src/Common/ImageTags.Types.ts +1 -0
- package/src/Common/ImageTags.tsx +2 -23
- package/src/Common/Types.ts +2 -38
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TeamList, ResponseType, DeploymentNodeType
|
|
1
|
+
import { TeamList, ResponseType, DeploymentNodeType } from './Types';
|
|
2
2
|
export declare const getTeamListMin: () => Promise<TeamList>;
|
|
3
3
|
interface UserRole extends ResponseType {
|
|
4
4
|
result?: {
|
|
@@ -13,7 +13,7 @@ export declare const SourceTypeMap: {
|
|
|
13
13
|
};
|
|
14
14
|
export declare function getUserRole(appName?: string): Promise<UserRole>;
|
|
15
15
|
export declare function setImageTags(request: any, pipelineId: number, artifactId: number): Promise<ResponseType>;
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const getCDMaterials: (cdMaterialId: any, stageType: DeploymentNodeType, abortSignal: AbortSignal, isApprovalNode?: boolean, imageTag?: string) => Promise<any>;
|
|
17
17
|
export declare function extractImage(image: string): string;
|
|
18
18
|
export declare function createGitCommitUrl(url: string, revision: string): string;
|
|
19
19
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ImageButtonType, ImageTaggingContainerType } from './ImageTags.Types';
|
|
3
|
-
export declare const ImageTagsContainer: ({ ciPipelineId, artifactId, imageComment, imageReleaseTags, updateCurrentAppMaterial, appReleaseTagNames, setAppReleaseTagNames, tagsEditable, setTagsEditable, toggleCardMode, hideHardDelete, forceReInit, }: ImageTaggingContainerType) => JSX.Element;
|
|
3
|
+
export declare const ImageTagsContainer: ({ ciPipelineId, artifactId, imageComment, imageReleaseTags, updateCurrentAppMaterial, appReleaseTagNames, setAppReleaseTagNames, tagsEditable, setTagsEditable, toggleCardMode, hideHardDelete, forceReInit, isSuperAdmin }: ImageTaggingContainerType) => JSX.Element;
|
|
4
4
|
export declare const ImageTagButton: ({ text, isSoftDeleted, isEditing, onSoftDeleteClick, onHardDeleteClick, tagId, softDeleteTags, isSuperAdmin, duplicateTag, hideHardDelete, }: ImageButtonType) => JSX.Element;
|
package/dist/Common/Types.d.ts
CHANGED
|
@@ -223,30 +223,6 @@ export interface CDMaterialType {
|
|
|
223
223
|
imageReleaseTags?: ReleaseTag[];
|
|
224
224
|
artifactStatus?: string;
|
|
225
225
|
filterState: FilterStates;
|
|
226
|
-
scanToolId?: number;
|
|
227
|
-
appliedFiltersTimestamp?: string;
|
|
228
|
-
appliedFilters?: FilterConditionsListType[];
|
|
229
|
-
appliedFiltersState?: FilterStates;
|
|
230
|
-
createdTime?: string;
|
|
231
|
-
deployed?: boolean;
|
|
232
|
-
}
|
|
233
|
-
export declare enum CDMaterialServiceEnum {
|
|
234
|
-
ROLLBACK = "rollback",
|
|
235
|
-
CD_MATERIALS = "cd-materials"
|
|
236
|
-
}
|
|
237
|
-
export declare enum CDMaterialResourceQuery {
|
|
238
|
-
PENDING_APPROVAL = "PENDING_APPROVAL"
|
|
239
|
-
}
|
|
240
|
-
export declare enum CDMaterialFilterQuery {
|
|
241
|
-
RESOURCE = "ELIGIBLE_RESOURCES",
|
|
242
|
-
ALL = "ALL_RESOURCES"
|
|
243
|
-
}
|
|
244
|
-
export interface CDMaterialServiceQueryParams {
|
|
245
|
-
search?: string;
|
|
246
|
-
offset?: number;
|
|
247
|
-
size?: number;
|
|
248
|
-
resource?: CDMaterialResourceQuery;
|
|
249
|
-
filter?: CDMaterialFilterQuery;
|
|
250
226
|
}
|
|
251
227
|
export interface CommonNodeAttr {
|
|
252
228
|
connectingCiPipelineId?: number;
|
|
@@ -353,20 +329,15 @@ export interface FilterConditionsListType {
|
|
|
353
329
|
description: string;
|
|
354
330
|
conditions: FilterConditionsInfo[];
|
|
355
331
|
}
|
|
356
|
-
export interface
|
|
332
|
+
export interface CDMaterialResponseType {
|
|
357
333
|
approvalUsers: string[];
|
|
334
|
+
materials: any[];
|
|
358
335
|
userApprovalConfig: UserApprovalConfigType;
|
|
359
336
|
requestedUserId: number;
|
|
360
|
-
}
|
|
361
|
-
export interface CDMaterialsMetaInfo {
|
|
362
337
|
tagsEditable: boolean;
|
|
363
338
|
appReleaseTagNames: string[];
|
|
364
339
|
hideImageTaggingHardDelete: boolean;
|
|
365
340
|
resourceFilters?: FilterConditionsListType[];
|
|
366
|
-
totalCount: number;
|
|
367
|
-
}
|
|
368
|
-
export interface CDMaterialResponseType extends CDMaterialsMetaInfo, CDMaterialsApprovalInfo {
|
|
369
|
-
materials: CDMaterialType[];
|
|
370
341
|
}
|
|
371
342
|
export interface InputDetailType {
|
|
372
343
|
label: string;
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,6 @@ var ROUTES = {
|
|
|
44
44
|
PROJECT_LIST_MIN: 'team/autocomplete',
|
|
45
45
|
USER_CHECK_ROLE: 'user/check/roles',
|
|
46
46
|
IMAGE_TAGGING: 'app/image-tagging',
|
|
47
|
-
CD_MATERIAL_GET: 'app/cd-pipeline'
|
|
48
47
|
};
|
|
49
48
|
exports.KEY_VALUE = void 0;
|
|
50
49
|
(function (KEY_VALUE) {
|
|
@@ -431,20 +430,6 @@ exports.FilterStates = void 0;
|
|
|
431
430
|
FilterStates[FilterStates["BLOCKED"] = 1] = "BLOCKED";
|
|
432
431
|
FilterStates[FilterStates["ERROR"] = 2] = "ERROR";
|
|
433
432
|
})(exports.FilterStates || (exports.FilterStates = {}));
|
|
434
|
-
exports.CDMaterialServiceEnum = void 0;
|
|
435
|
-
(function (CDMaterialServiceEnum) {
|
|
436
|
-
CDMaterialServiceEnum["ROLLBACK"] = "rollback";
|
|
437
|
-
CDMaterialServiceEnum["CD_MATERIALS"] = "cd-materials";
|
|
438
|
-
})(exports.CDMaterialServiceEnum || (exports.CDMaterialServiceEnum = {}));
|
|
439
|
-
exports.CDMaterialResourceQuery = void 0;
|
|
440
|
-
(function (CDMaterialResourceQuery) {
|
|
441
|
-
CDMaterialResourceQuery["PENDING_APPROVAL"] = "PENDING_APPROVAL";
|
|
442
|
-
})(exports.CDMaterialResourceQuery || (exports.CDMaterialResourceQuery = {}));
|
|
443
|
-
exports.CDMaterialFilterQuery = void 0;
|
|
444
|
-
(function (CDMaterialFilterQuery) {
|
|
445
|
-
CDMaterialFilterQuery["RESOURCE"] = "ELIGIBLE_RESOURCES";
|
|
446
|
-
CDMaterialFilterQuery["ALL"] = "ALL_RESOURCES";
|
|
447
|
-
})(exports.CDMaterialFilterQuery || (exports.CDMaterialFilterQuery = {}));
|
|
448
433
|
exports.DeploymentAppTypes = void 0;
|
|
449
434
|
(function (DeploymentAppTypes) {
|
|
450
435
|
DeploymentAppTypes["HELM"] = "helm";
|
|
@@ -22703,167 +22688,77 @@ function getUserRole(appName) {
|
|
|
22703
22688
|
function setImageTags(request, pipelineId, artifactId) {
|
|
22704
22689
|
return post("".concat(ROUTES.IMAGE_TAGGING, "/").concat(pipelineId, "/").concat(artifactId), request);
|
|
22705
22690
|
}
|
|
22706
|
-
|
|
22707
|
-
|
|
22708
|
-
|
|
22709
|
-
|
|
22710
|
-
|
|
22711
|
-
|
|
22712
|
-
|
|
22713
|
-
|
|
22714
|
-
|
|
22715
|
-
|
|
22716
|
-
|
|
22717
|
-
|
|
22718
|
-
return "".concat(key, "=").concat(params[key]);
|
|
22719
|
-
})
|
|
22720
|
-
.join('&');
|
|
22721
|
-
return "".concat(url, "?").concat(queryString);
|
|
22722
|
-
};
|
|
22723
|
-
var cdMaterialListModal = function (artifacts, offset, artifactId, artifactStatus) {
|
|
22724
|
-
if (!artifacts || !artifacts.length)
|
|
22725
|
-
return [];
|
|
22726
|
-
var markFirstSelected = offset === 0;
|
|
22727
|
-
var startIndex = offset;
|
|
22728
|
-
var isImageMarked = false;
|
|
22729
|
-
var materials = artifacts.map(function (material, index) {
|
|
22730
|
-
var _a, _b, _c, _d, _e;
|
|
22731
|
-
var artifactStatusValue = '';
|
|
22732
|
-
var filterState = (_a = material.filterState) !== null && _a !== void 0 ? _a : exports.FilterStates.ALLOWED;
|
|
22733
|
-
if (artifactId && artifactStatus && material.id === artifactId) {
|
|
22734
|
-
artifactStatusValue = artifactStatus;
|
|
22691
|
+
// FIXME: This is only returning materials to cater the case of search in approval but it should be a common function service coming from dashboard.
|
|
22692
|
+
var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalNode, imageTag) {
|
|
22693
|
+
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);
|
|
22694
|
+
return get(URL, {
|
|
22695
|
+
signal: abortSignal,
|
|
22696
|
+
}).then(function (response) {
|
|
22697
|
+
var _a;
|
|
22698
|
+
var artifacts = (_a = response.result.ci_artifacts) !== null && _a !== void 0 ? _a : [];
|
|
22699
|
+
if (!response.result) {
|
|
22700
|
+
return {
|
|
22701
|
+
materials: [],
|
|
22702
|
+
};
|
|
22735
22703
|
}
|
|
22736
|
-
|
|
22737
|
-
|
|
22738
|
-
|
|
22704
|
+
else {
|
|
22705
|
+
var materials = artifacts.map(function (material, index) {
|
|
22706
|
+
var _a;
|
|
22707
|
+
var artifactStatusValue = '';
|
|
22708
|
+
var filterState = (_a = material.filterState) !== null && _a !== void 0 ? _a : exports.FilterStates.ALLOWED;
|
|
22709
|
+
return {
|
|
22710
|
+
index: index,
|
|
22711
|
+
id: material.id,
|
|
22712
|
+
deployedTime: material.deployed_time
|
|
22713
|
+
? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
|
|
22714
|
+
: 'Not Deployed',
|
|
22715
|
+
deployedBy: material.deployedBy,
|
|
22716
|
+
wfrId: material.wfrId,
|
|
22717
|
+
image: extractImage(material.image),
|
|
22718
|
+
showChanges: false,
|
|
22719
|
+
vulnerabilities: [],
|
|
22720
|
+
buildTime: material.build_time || '',
|
|
22721
|
+
tab: CDModalTab.Changes,
|
|
22722
|
+
showSourceInfo: false,
|
|
22723
|
+
deployed: material.deployed || false,
|
|
22724
|
+
latest: material.latest || false,
|
|
22725
|
+
vulnerabilitiesLoading: true,
|
|
22726
|
+
scanned: material.scanned,
|
|
22727
|
+
scanEnabled: material.scanEnabled,
|
|
22728
|
+
isSelected: !material.vulnerable && filterState === exports.FilterStates.ALLOWED && index === 0,
|
|
22729
|
+
vulnerable: material.vulnerable,
|
|
22730
|
+
runningOnParentCd: material.runningOnParentCd,
|
|
22731
|
+
artifactStatus: artifactStatusValue,
|
|
22732
|
+
userApprovalMetadata: material.userApprovalMetadata,
|
|
22733
|
+
triggeredBy: material.triggeredBy,
|
|
22734
|
+
isVirtualEnvironment: material.isVirtualEnvironment,
|
|
22735
|
+
imageComment: material.imageComment,
|
|
22736
|
+
imageReleaseTags: material.imageReleaseTags,
|
|
22737
|
+
materialInfo: material.material_info
|
|
22738
|
+
? material.material_info.map(function (mat) {
|
|
22739
|
+
return {
|
|
22740
|
+
modifiedTime: mat.modifiedTime ? moment(mat.modifiedTime).format("ddd, DD MMM YYYY, hh:mm A") : '',
|
|
22741
|
+
commitLink: createGitCommitUrl(mat.url, mat.revision),
|
|
22742
|
+
author: mat.author || '',
|
|
22743
|
+
message: mat.message || '',
|
|
22744
|
+
revision: mat.revision || '',
|
|
22745
|
+
tag: mat.tag || '',
|
|
22746
|
+
webhookData: mat.webhookData || '',
|
|
22747
|
+
url: mat.url || '',
|
|
22748
|
+
branch: (material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
|
|
22749
|
+
? material.ciConfigureSourceValue
|
|
22750
|
+
: mat.branch) || '',
|
|
22751
|
+
type: material.ciConfigureSourceType || '',
|
|
22752
|
+
};
|
|
22753
|
+
})
|
|
22754
|
+
: [],
|
|
22755
|
+
filterState: filterState,
|
|
22756
|
+
};
|
|
22757
|
+
});
|
|
22758
|
+
return {
|
|
22759
|
+
materials: materials
|
|
22760
|
+
};
|
|
22739
22761
|
}
|
|
22740
|
-
return {
|
|
22741
|
-
index: startIndex + index,
|
|
22742
|
-
id: material.id,
|
|
22743
|
-
deployedTime: material.deployed_time
|
|
22744
|
-
? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
|
|
22745
|
-
: 'Not Deployed',
|
|
22746
|
-
deployedBy: material.deployedBy,
|
|
22747
|
-
wfrId: material.wfrId,
|
|
22748
|
-
tab: CDModalTab.Changes,
|
|
22749
|
-
image: extractImage(material.image),
|
|
22750
|
-
showChanges: false,
|
|
22751
|
-
vulnerabilities: [],
|
|
22752
|
-
buildTime: material.build_time || '',
|
|
22753
|
-
isSelected: selectImage,
|
|
22754
|
-
showSourceInfo: false,
|
|
22755
|
-
deployed: material.deployed || false,
|
|
22756
|
-
latest: material.latest || false,
|
|
22757
|
-
vulnerabilitiesLoading: true,
|
|
22758
|
-
scanned: material.scanned,
|
|
22759
|
-
scanEnabled: material.scanEnabled,
|
|
22760
|
-
vulnerable: material.vulnerable,
|
|
22761
|
-
runningOnParentCd: material.runningOnParentCd,
|
|
22762
|
-
artifactStatus: artifactStatusValue,
|
|
22763
|
-
userApprovalMetadata: material.userApprovalMetadata,
|
|
22764
|
-
triggeredBy: material.triggeredBy,
|
|
22765
|
-
isVirtualEnvironment: material.isVirtualEnvironment,
|
|
22766
|
-
imageComment: material.imageComment,
|
|
22767
|
-
imageReleaseTags: material.imageReleaseTags,
|
|
22768
|
-
// It is going to be null but required in type so can't remove
|
|
22769
|
-
lastExecution: material.lastExecution,
|
|
22770
|
-
materialInfo: material.material_info
|
|
22771
|
-
? material.material_info.map(function (mat) {
|
|
22772
|
-
return {
|
|
22773
|
-
modifiedTime: mat.modifiedTime
|
|
22774
|
-
? moment(mat.modifiedTime).format('ddd, DD MMM YYYY, hh:mm A')
|
|
22775
|
-
: '',
|
|
22776
|
-
commitLink: createGitCommitUrl(mat.url, mat.revision),
|
|
22777
|
-
author: mat.author || '',
|
|
22778
|
-
message: mat.message || '',
|
|
22779
|
-
revision: mat.revision || '',
|
|
22780
|
-
tag: mat.tag || '',
|
|
22781
|
-
webhookData: mat.webhookData || '',
|
|
22782
|
-
url: mat.url || '',
|
|
22783
|
-
branch: (material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
|
|
22784
|
-
? material.ciConfigureSourceValue
|
|
22785
|
-
: mat.branch) || '',
|
|
22786
|
-
type: material.ciConfigureSourceType || '',
|
|
22787
|
-
};
|
|
22788
|
-
})
|
|
22789
|
-
: [],
|
|
22790
|
-
filterState: filterState,
|
|
22791
|
-
appliedFiltersTimestamp: (_b = material.appliedFiltersTimestamp) !== null && _b !== void 0 ? _b : '',
|
|
22792
|
-
appliedFilters: (_c = material.appliedFilters) !== null && _c !== void 0 ? _c : [],
|
|
22793
|
-
appliedFiltersState: (_d = material.appliedFiltersState) !== null && _d !== void 0 ? _d : exports.FilterStates.ALLOWED,
|
|
22794
|
-
createdTime: (_e = material.createdTime) !== null && _e !== void 0 ? _e : '',
|
|
22795
|
-
};
|
|
22796
|
-
});
|
|
22797
|
-
return materials;
|
|
22798
|
-
};
|
|
22799
|
-
var processCDMaterialsApprovalInfo = function (enableApproval, cdMaterialsResult) {
|
|
22800
|
-
if (!enableApproval) {
|
|
22801
|
-
return {
|
|
22802
|
-
approvalUsers: [],
|
|
22803
|
-
userApprovalConfig: null,
|
|
22804
|
-
requestedUserId: 0,
|
|
22805
|
-
};
|
|
22806
|
-
}
|
|
22807
|
-
return {
|
|
22808
|
-
approvalUsers: cdMaterialsResult.approvalUsers,
|
|
22809
|
-
userApprovalConfig: cdMaterialsResult.userApprovalConfig,
|
|
22810
|
-
requestedUserId: cdMaterialsResult.requestedUserId,
|
|
22811
|
-
};
|
|
22812
|
-
};
|
|
22813
|
-
var processCDMaterialsMetaInfo = function (cdMaterialsResult) {
|
|
22814
|
-
var _a, _b;
|
|
22815
|
-
if (!cdMaterialsResult) {
|
|
22816
|
-
return {
|
|
22817
|
-
tagsEditable: false,
|
|
22818
|
-
appReleaseTagNames: [],
|
|
22819
|
-
hideImageTaggingHardDelete: false,
|
|
22820
|
-
resourceFilters: [],
|
|
22821
|
-
totalCount: 0,
|
|
22822
|
-
};
|
|
22823
|
-
}
|
|
22824
|
-
return {
|
|
22825
|
-
appReleaseTagNames: cdMaterialsResult.appReleaseTagNames,
|
|
22826
|
-
tagsEditable: cdMaterialsResult.tagsEditable,
|
|
22827
|
-
hideImageTaggingHardDelete: cdMaterialsResult.hideImageTaggingHardDelete,
|
|
22828
|
-
resourceFilters: (_a = cdMaterialsResult.resourceFilters) !== null && _a !== void 0 ? _a : [],
|
|
22829
|
-
totalCount: (_b = cdMaterialsResult.totalCount) !== null && _b !== void 0 ? _b : 0,
|
|
22830
|
-
};
|
|
22831
|
-
};
|
|
22832
|
-
var processCDMaterialServiceResponse = function (cdMaterialsResult, stage, offset, filter) {
|
|
22833
|
-
if (!cdMaterialsResult) {
|
|
22834
|
-
return __assign(__assign({ materials: [] }, processCDMaterialsMetaInfo(cdMaterialsResult)), processCDMaterialsApprovalInfo(false, cdMaterialsResult));
|
|
22835
|
-
}
|
|
22836
|
-
var materials = cdMaterialListModal(cdMaterialsResult.ci_artifacts, offset !== null && offset !== void 0 ? offset : 0, cdMaterialsResult.latest_wf_artifact_id, cdMaterialsResult.latest_wf_artifact_status);
|
|
22837
|
-
var approvalInfo = processCDMaterialsApprovalInfo(stage === exports.DeploymentNodeType.CD || stage === exports.DeploymentNodeType.APPROVAL, cdMaterialsResult);
|
|
22838
|
-
var metaInfo = processCDMaterialsMetaInfo(cdMaterialsResult);
|
|
22839
|
-
// TODO: On update of service would remove from here
|
|
22840
|
-
var filteredMaterials = filter && filter === exports.CDMaterialFilterQuery.RESOURCE
|
|
22841
|
-
? materials.filter(function (material) {
|
|
22842
|
-
return material.filterState === exports.FilterStates.ALLOWED;
|
|
22843
|
-
})
|
|
22844
|
-
: materials;
|
|
22845
|
-
return __assign(__assign({ materials: filteredMaterials }, approvalInfo), metaInfo);
|
|
22846
|
-
};
|
|
22847
|
-
var getSanitizedQueryParams = function (queryParams) {
|
|
22848
|
-
queryParams.filter; var rest = __rest(queryParams, ["filter"]);
|
|
22849
|
-
return rest;
|
|
22850
|
-
};
|
|
22851
|
-
var genericCDMaterialsService = function (serviceType, cdMaterialID, stage, signal, queryParams) {
|
|
22852
|
-
if (queryParams === void 0) { queryParams = {}; }
|
|
22853
|
-
// TODO: On update of service would remove from here
|
|
22854
|
-
var manipulatedParams = getSanitizedQueryParams(queryParams);
|
|
22855
|
-
var URL;
|
|
22856
|
-
switch (serviceType) {
|
|
22857
|
-
case exports.CDMaterialServiceEnum.ROLLBACK:
|
|
22858
|
-
URL = processURL("".concat(ROUTES.CD_MATERIAL_GET, "/").concat(cdMaterialID, "/material/rollback"), manipulatedParams);
|
|
22859
|
-
break;
|
|
22860
|
-
// Meant for handling getCDMaterialList
|
|
22861
|
-
default:
|
|
22862
|
-
URL = processURL("".concat(ROUTES.CD_MATERIAL_GET, "/").concat(cdMaterialID, "/material"), __assign(__assign({}, manipulatedParams), { stage: stageMap[stage] }));
|
|
22863
|
-
break;
|
|
22864
|
-
}
|
|
22865
|
-
return get(URL, { signal: signal }).then(function (response) {
|
|
22866
|
-
return processCDMaterialServiceResponse(response.result, stage, queryParams.offset, queryParams.filter);
|
|
22867
22762
|
});
|
|
22868
22763
|
};
|
|
22869
22764
|
function extractImage(image) {
|
|
@@ -23230,7 +23125,7 @@ var SvgIcEnter = function SvgIcEnter(props) {
|
|
|
23230
23125
|
};
|
|
23231
23126
|
|
|
23232
23127
|
var ImageTagsContainer = function (_a) {
|
|
23233
|
-
var ciPipelineId = _a.ciPipelineId, artifactId = _a.artifactId, imageComment = _a.imageComment, imageReleaseTags = _a.imageReleaseTags, updateCurrentAppMaterial = _a.updateCurrentAppMaterial, appReleaseTagNames = _a.appReleaseTagNames, setAppReleaseTagNames = _a.setAppReleaseTagNames, tagsEditable = _a.tagsEditable, setTagsEditable = _a.setTagsEditable, toggleCardMode = _a.toggleCardMode, hideHardDelete = _a.hideHardDelete, forceReInit = _a.forceReInit;
|
|
23128
|
+
var ciPipelineId = _a.ciPipelineId, artifactId = _a.artifactId, imageComment = _a.imageComment, imageReleaseTags = _a.imageReleaseTags, updateCurrentAppMaterial = _a.updateCurrentAppMaterial, appReleaseTagNames = _a.appReleaseTagNames, setAppReleaseTagNames = _a.setAppReleaseTagNames, tagsEditable = _a.tagsEditable, setTagsEditable = _a.setTagsEditable, toggleCardMode = _a.toggleCardMode, hideHardDelete = _a.hideHardDelete, forceReInit = _a.forceReInit, isSuperAdmin = _a.isSuperAdmin;
|
|
23234
23129
|
var _b = __read(React.useState(imageReleaseTags ? imageReleaseTags : []), 2), initialTags = _b[0], setInitialTags = _b[1];
|
|
23235
23130
|
var _c = __read(React.useState(imageComment ? imageComment.comment : ''), 2), initialDescription = _c[0], setInitialDescription = _c[1];
|
|
23236
23131
|
var _d = __read(React.useState(appReleaseTagNames ? appReleaseTagNames : []), 2), existingTags = _d[0], setExistingTags = _d[1];
|
|
@@ -23242,42 +23137,14 @@ var ImageTagsContainer = function (_a) {
|
|
|
23242
23137
|
var _k = __read(React.useState([]), 2), createTags = _k[0], setCreateTags = _k[1];
|
|
23243
23138
|
var _l = __read(React.useState([]), 2), softDeleteTags = _l[0], setSoftDeleteTags = _l[1];
|
|
23244
23139
|
var _m = __read(React.useState([]), 2), hardDeleteTags = _m[0], setHardDeleteTags = _m[1];
|
|
23245
|
-
var _o = __read(React.useState(
|
|
23246
|
-
var _p = __read(React.useState(''), 2),
|
|
23247
|
-
var _q = __read(React.useState(''), 2), textInput = _q[0], setTextInput = _q[1];
|
|
23248
|
-
var _r = __read(React.useState(false), 2), loading = _r[0], setLoading = _r[1];
|
|
23249
|
-
React.useEffect(function () {
|
|
23250
|
-
initialise();
|
|
23251
|
-
}, []);
|
|
23140
|
+
var _o = __read(React.useState(''), 2), descriptionValidationMessage = _o[0], setDescriptionValidationMessage = _o[1];
|
|
23141
|
+
var _p = __read(React.useState(''), 2), textInput = _p[0], setTextInput = _p[1];
|
|
23252
23142
|
React.useEffect(function () {
|
|
23253
23143
|
reInitState();
|
|
23254
23144
|
}, [imageReleaseTags, imageComment, tagsEditable]);
|
|
23255
23145
|
React.useEffect(function () {
|
|
23256
23146
|
setExistingTags(appReleaseTagNames ? appReleaseTagNames : []);
|
|
23257
23147
|
}, [appReleaseTagNames]);
|
|
23258
|
-
function initialise() {
|
|
23259
|
-
var _a, _b;
|
|
23260
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
23261
|
-
var userRole, superAdmin, err_1;
|
|
23262
|
-
return __generator(this, function (_c) {
|
|
23263
|
-
switch (_c.label) {
|
|
23264
|
-
case 0:
|
|
23265
|
-
_c.trys.push([0, 2, , 3]);
|
|
23266
|
-
return [4 /*yield*/, getUserRole()];
|
|
23267
|
-
case 1:
|
|
23268
|
-
userRole = _c.sent();
|
|
23269
|
-
superAdmin = (_b = (_a = userRole === null || userRole === void 0 ? void 0 : userRole.result) === null || _a === void 0 ? void 0 : _a.roles) === null || _b === void 0 ? void 0 : _b.includes('role:super-admin___');
|
|
23270
|
-
setSuperAdmin(superAdmin);
|
|
23271
|
-
return [3 /*break*/, 3];
|
|
23272
|
-
case 2:
|
|
23273
|
-
err_1 = _c.sent();
|
|
23274
|
-
showError(err_1);
|
|
23275
|
-
return [3 /*break*/, 3];
|
|
23276
|
-
case 3: return [2 /*return*/];
|
|
23277
|
-
}
|
|
23278
|
-
});
|
|
23279
|
-
});
|
|
23280
|
-
}
|
|
23281
23148
|
var reInitState = function () {
|
|
23282
23149
|
if (forceReInit || !isEditing) {
|
|
23283
23150
|
setInitialTags(imageReleaseTags ? imageReleaseTags : []);
|
|
@@ -23419,7 +23286,6 @@ var ImageTagsContainer = function (_a) {
|
|
|
23419
23286
|
hardDeleteTags: hardDeleteTags,
|
|
23420
23287
|
};
|
|
23421
23288
|
// set loading state true
|
|
23422
|
-
setLoading(true);
|
|
23423
23289
|
setImageTags(payload, ciPipelineId, artifactId)
|
|
23424
23290
|
.then(function (res) {
|
|
23425
23291
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
@@ -23459,9 +23325,6 @@ var ImageTagsContainer = function (_a) {
|
|
|
23459
23325
|
else {
|
|
23460
23326
|
showError(err);
|
|
23461
23327
|
}
|
|
23462
|
-
})
|
|
23463
|
-
.finally(function () {
|
|
23464
|
-
setLoading(false);
|
|
23465
23328
|
});
|
|
23466
23329
|
return [2 /*return*/];
|
|
23467
23330
|
});
|
|
@@ -23512,10 +23375,10 @@ var ImageTagsContainer = function (_a) {
|
|
|
23512
23375
|
}, 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) {
|
|
23513
23376
|
stopPropagation(e);
|
|
23514
23377
|
handleCancel();
|
|
23515
|
-
}
|
|
23378
|
+
} }, { 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) {
|
|
23516
23379
|
stopPropagation(e);
|
|
23517
23380
|
onClickSave();
|
|
23518
|
-
}
|
|
23381
|
+
} }, { children: "Save" }))] }))] }))) : (jsxRuntime.jsxs("div", __assign({ className: "top br-4 bcn-0 image-tags-container flexbox" }, { children: [jsxRuntime.jsx("div", __assign({ className: "flex left image-tag-left-border w-100 mt-8 mb-8 pr-10 pl-10", "data-testid": "image-tags-container-hover" }, { children: jsxRuntime.jsxs("div", __assign({ className: 'w-100' }, { children: [initialDescription && jsxRuntime.jsx("div", __assign({ className: "mb-6 fs-13 lh-20 dc__word-break-all" }, { children: initialDescription })), jsxRuntime.jsx("div", __assign({ className: "flex-wrap flex left" }, { children: initialTags === null || initialTags === void 0 ? void 0 : initialTags.map(function (tag, index) { return (jsxRuntime.jsx(ImageTagButton, { text: tag === null || tag === void 0 ? void 0 : tag.tagName, isSoftDeleted: tag === null || tag === void 0 ? void 0 : tag.deleted, isEditing: isEditing, onSoftDeleteClick: function (e) {
|
|
23519
23382
|
stopPropagation(e);
|
|
23520
23383
|
handleTagSoftDelete(index);
|
|
23521
23384
|
}, onHardDeleteClick: function (e) {
|
|
@@ -23800,9 +23663,9 @@ exports.closeOnEscKeyPressed = closeOnEscKeyPressed;
|
|
|
23800
23663
|
exports.copyToClipboard = copyToClipboard;
|
|
23801
23664
|
exports.createGitCommitUrl = createGitCommitUrl;
|
|
23802
23665
|
exports.extractImage = extractImage;
|
|
23803
|
-
exports.genericCDMaterialsService = genericCDMaterialsService;
|
|
23804
23666
|
exports.get = get;
|
|
23805
23667
|
exports.getAlphabetIcon = getAlphabetIcon;
|
|
23668
|
+
exports.getCDMaterials = getCDMaterials;
|
|
23806
23669
|
exports.getCookie = getCookie;
|
|
23807
23670
|
exports.getEmptyArrayOfLength = getEmptyArrayOfLength;
|
|
23808
23671
|
exports.getLoginInfo = getLoginInfo;
|
package/package.json
CHANGED
|
@@ -2,20 +2,7 @@ import moment from 'moment';
|
|
|
2
2
|
import {get, post} from './Api';
|
|
3
3
|
import { ROUTES } from './Constants'
|
|
4
4
|
import { sortCallback } from './Helper';
|
|
5
|
-
import {
|
|
6
|
-
TeamList,
|
|
7
|
-
ResponseType,
|
|
8
|
-
DeploymentNodeType,
|
|
9
|
-
CDModalTab,
|
|
10
|
-
FilterStates,
|
|
11
|
-
CDMaterialServiceEnum,
|
|
12
|
-
CDMaterialServiceQueryParams,
|
|
13
|
-
CDMaterialResponseType,
|
|
14
|
-
CDMaterialsMetaInfo,
|
|
15
|
-
CDMaterialsApprovalInfo,
|
|
16
|
-
CDMaterialFilterQuery,
|
|
17
|
-
CDMaterialType,
|
|
18
|
-
} from './Types'
|
|
5
|
+
import { TeamList ,ResponseType, DeploymentNodeType, CDModalTab, FilterStates } from './Types';
|
|
19
6
|
|
|
20
7
|
export const getTeamListMin = (): Promise<TeamList> => {
|
|
21
8
|
// ignore active field
|
|
@@ -43,7 +30,7 @@ interface UserRole extends ResponseType {
|
|
|
43
30
|
}
|
|
44
31
|
}
|
|
45
32
|
|
|
46
|
-
|
|
33
|
+
let stageMap = {
|
|
47
34
|
PRECD: 'PRE',
|
|
48
35
|
CD: 'DEPLOY',
|
|
49
36
|
POSTCD: 'POST',
|
|
@@ -64,215 +51,83 @@ export function setImageTags(request, pipelineId: number, artifactId: number){
|
|
|
64
51
|
return post(`${ROUTES.IMAGE_TAGGING}/${pipelineId}/${artifactId}`,request )
|
|
65
52
|
}
|
|
66
53
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
54
|
+
// FIXME: This is only returning materials to cater the case of search in approval but it should be a common function service coming from dashboard.
|
|
55
|
+
export const getCDMaterials = (
|
|
56
|
+
cdMaterialId,
|
|
57
|
+
stageType: DeploymentNodeType,
|
|
58
|
+
abortSignal: AbortSignal,
|
|
59
|
+
isApprovalNode?: boolean,
|
|
60
|
+
imageTag?: string): Promise<any> => {
|
|
61
|
+
const URL = (!imageTag) ? `app/cd-pipeline/${cdMaterialId}/material?stage=${stageMap[stageType]}` : `app/cd-pipeline/${cdMaterialId}/material?stage=${stageMap[stageType]}&search=${imageTag}`
|
|
62
|
+
|
|
63
|
+
return get(URL, {
|
|
64
|
+
signal: abortSignal,
|
|
65
|
+
}).then((response) => {
|
|
66
|
+
let artifacts = response.result.ci_artifacts ?? []
|
|
67
|
+
if (!response.result) {
|
|
68
|
+
return {
|
|
69
|
+
materials: [],
|
|
80
70
|
}
|
|
81
|
-
return `${key}=${params[key]}`
|
|
82
|
-
})
|
|
83
|
-
.join('&')
|
|
84
|
-
|
|
85
|
-
return `${url}?${queryString}`
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const cdMaterialListModal = (artifacts: any[], offset: number, artifactId?: number, artifactStatus?: string) => {
|
|
89
|
-
if (!artifacts || !artifacts.length) return []
|
|
90
|
-
|
|
91
|
-
const markFirstSelected = offset === 0
|
|
92
|
-
const startIndex = offset
|
|
93
|
-
let isImageMarked = false
|
|
94
|
-
|
|
95
|
-
const materials = artifacts.map((material, index) => {
|
|
96
|
-
let artifactStatusValue = ''
|
|
97
|
-
const filterState = material.filterState ?? FilterStates.ALLOWED
|
|
98
|
-
|
|
99
|
-
if (artifactId && artifactStatus && material.id === artifactId) {
|
|
100
|
-
artifactStatusValue = artifactStatus
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const selectImage =
|
|
104
|
-
!isImageMarked && markFirstSelected && filterState === FilterStates.ALLOWED ? !material.vulnerable : false
|
|
105
|
-
if (selectImage) {
|
|
106
|
-
isImageMarked = true
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
index: startIndex + index,
|
|
111
|
-
id: material.id,
|
|
112
|
-
deployedTime: material.deployed_time
|
|
113
|
-
? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
|
|
114
|
-
: 'Not Deployed',
|
|
115
|
-
deployedBy: material.deployedBy,
|
|
116
|
-
wfrId: material.wfrId,
|
|
117
|
-
tab: CDModalTab.Changes,
|
|
118
|
-
image: extractImage(material.image),
|
|
119
|
-
showChanges: false,
|
|
120
|
-
vulnerabilities: [],
|
|
121
|
-
buildTime: material.build_time || '',
|
|
122
|
-
isSelected: selectImage,
|
|
123
|
-
showSourceInfo: false,
|
|
124
|
-
deployed: material.deployed || false,
|
|
125
|
-
latest: material.latest || false,
|
|
126
|
-
vulnerabilitiesLoading: true,
|
|
127
|
-
scanned: material.scanned,
|
|
128
|
-
scanEnabled: material.scanEnabled,
|
|
129
|
-
vulnerable: material.vulnerable,
|
|
130
|
-
runningOnParentCd: material.runningOnParentCd,
|
|
131
|
-
artifactStatus: artifactStatusValue,
|
|
132
|
-
userApprovalMetadata: material.userApprovalMetadata,
|
|
133
|
-
triggeredBy: material.triggeredBy,
|
|
134
|
-
isVirtualEnvironment: material.isVirtualEnvironment,
|
|
135
|
-
imageComment: material.imageComment,
|
|
136
|
-
imageReleaseTags: material.imageReleaseTags,
|
|
137
|
-
// It is going to be null but required in type so can't remove
|
|
138
|
-
lastExecution: material.lastExecution,
|
|
139
|
-
materialInfo: material.material_info
|
|
140
|
-
? material.material_info.map((mat) => {
|
|
141
|
-
return {
|
|
142
|
-
modifiedTime: mat.modifiedTime
|
|
143
|
-
? moment(mat.modifiedTime).format('ddd, DD MMM YYYY, hh:mm A')
|
|
144
|
-
: '',
|
|
145
|
-
commitLink: createGitCommitUrl(mat.url, mat.revision),
|
|
146
|
-
author: mat.author || '',
|
|
147
|
-
message: mat.message || '',
|
|
148
|
-
revision: mat.revision || '',
|
|
149
|
-
tag: mat.tag || '',
|
|
150
|
-
webhookData: mat.webhookData || '',
|
|
151
|
-
url: mat.url || '',
|
|
152
|
-
branch:
|
|
153
|
-
(material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
|
|
154
|
-
? material.ciConfigureSourceValue
|
|
155
|
-
: mat.branch) || '',
|
|
156
|
-
type: material.ciConfigureSourceType || '',
|
|
157
|
-
}
|
|
158
|
-
})
|
|
159
|
-
: [],
|
|
160
|
-
filterState,
|
|
161
|
-
appliedFiltersTimestamp: material.appliedFiltersTimestamp ?? '',
|
|
162
|
-
appliedFilters: material.appliedFilters ?? [],
|
|
163
|
-
appliedFiltersState: material.appliedFiltersState ?? FilterStates.ALLOWED,
|
|
164
|
-
createdTime: material.createdTime ?? '',
|
|
165
|
-
}
|
|
166
|
-
})
|
|
167
|
-
return materials
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const processCDMaterialsApprovalInfo = (enableApproval: boolean, cdMaterialsResult): CDMaterialsApprovalInfo => {
|
|
171
|
-
if (!enableApproval) {
|
|
172
|
-
return {
|
|
173
|
-
approvalUsers: [],
|
|
174
|
-
userApprovalConfig: null,
|
|
175
|
-
requestedUserId: 0,
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return {
|
|
180
|
-
approvalUsers: cdMaterialsResult.approvalUsers,
|
|
181
|
-
userApprovalConfig: cdMaterialsResult.userApprovalConfig,
|
|
182
|
-
requestedUserId: cdMaterialsResult.requestedUserId,
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const processCDMaterialsMetaInfo = (cdMaterialsResult): CDMaterialsMetaInfo => {
|
|
187
|
-
if (!cdMaterialsResult) {
|
|
188
|
-
return {
|
|
189
|
-
tagsEditable: false,
|
|
190
|
-
appReleaseTagNames: [],
|
|
191
|
-
hideImageTaggingHardDelete: false,
|
|
192
|
-
resourceFilters: [],
|
|
193
|
-
totalCount: 0,
|
|
194
71
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
72
|
+
else {
|
|
73
|
+
const materials = artifacts.map((material, index) => {
|
|
74
|
+
let artifactStatusValue = ''
|
|
75
|
+
const filterState = material.filterState ?? FilterStates.ALLOWED
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
index,
|
|
79
|
+
id: material.id,
|
|
80
|
+
deployedTime: material.deployed_time
|
|
81
|
+
? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
|
|
82
|
+
: 'Not Deployed',
|
|
83
|
+
deployedBy: material.deployedBy,
|
|
84
|
+
wfrId: material.wfrId,
|
|
85
|
+
image: extractImage(material.image),
|
|
86
|
+
showChanges: false,
|
|
87
|
+
vulnerabilities: [],
|
|
88
|
+
buildTime: material.build_time || '',
|
|
89
|
+
tab: CDModalTab.Changes,
|
|
90
|
+
showSourceInfo: false,
|
|
91
|
+
deployed: material.deployed || false,
|
|
92
|
+
latest: material.latest || false,
|
|
93
|
+
vulnerabilitiesLoading: true,
|
|
94
|
+
scanned: material.scanned,
|
|
95
|
+
scanEnabled: material.scanEnabled,
|
|
96
|
+
isSelected: !material.vulnerable && filterState === FilterStates.ALLOWED && index === 0,
|
|
97
|
+
vulnerable: material.vulnerable,
|
|
98
|
+
runningOnParentCd: material.runningOnParentCd,
|
|
99
|
+
artifactStatus: artifactStatusValue,
|
|
100
|
+
userApprovalMetadata: material.userApprovalMetadata,
|
|
101
|
+
triggeredBy: material.triggeredBy,
|
|
102
|
+
isVirtualEnvironment: material.isVirtualEnvironment,
|
|
103
|
+
imageComment: material.imageComment,
|
|
104
|
+
imageReleaseTags: material.imageReleaseTags,
|
|
105
|
+
materialInfo: material.material_info
|
|
106
|
+
? material.material_info.map((mat) => {
|
|
107
|
+
return {
|
|
108
|
+
modifiedTime: mat.modifiedTime ? moment(mat.modifiedTime).format("ddd, DD MMM YYYY, hh:mm A") : '',
|
|
109
|
+
commitLink: createGitCommitUrl(mat.url, mat.revision),
|
|
110
|
+
author: mat.author || '',
|
|
111
|
+
message: mat.message || '',
|
|
112
|
+
revision: mat.revision || '',
|
|
113
|
+
tag: mat.tag || '',
|
|
114
|
+
webhookData: mat.webhookData || '',
|
|
115
|
+
url: mat.url || '',
|
|
116
|
+
branch:
|
|
117
|
+
(material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
|
|
118
|
+
? material.ciConfigureSourceValue
|
|
119
|
+
: mat.branch) || '',
|
|
120
|
+
type: material.ciConfigureSourceType || '',
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
: [],
|
|
124
|
+
filterState,
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
return {
|
|
128
|
+
materials: materials
|
|
129
|
+
}
|
|
217
130
|
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const materials = cdMaterialListModal(
|
|
221
|
-
cdMaterialsResult.ci_artifacts,
|
|
222
|
-
offset ?? 0,
|
|
223
|
-
cdMaterialsResult.latest_wf_artifact_id,
|
|
224
|
-
cdMaterialsResult.latest_wf_artifact_status,
|
|
225
|
-
)
|
|
226
|
-
const approvalInfo = processCDMaterialsApprovalInfo(
|
|
227
|
-
stage === DeploymentNodeType.CD || stage === DeploymentNodeType.APPROVAL,
|
|
228
|
-
cdMaterialsResult,
|
|
229
|
-
)
|
|
230
|
-
const metaInfo = processCDMaterialsMetaInfo(cdMaterialsResult)
|
|
231
|
-
|
|
232
|
-
// TODO: On update of service would remove from here
|
|
233
|
-
const filteredMaterials =
|
|
234
|
-
filter && filter === CDMaterialFilterQuery.RESOURCE
|
|
235
|
-
? materials.filter((material) => {
|
|
236
|
-
return material.filterState === FilterStates.ALLOWED
|
|
237
|
-
})
|
|
238
|
-
: materials
|
|
239
|
-
|
|
240
|
-
return {
|
|
241
|
-
materials: filteredMaterials,
|
|
242
|
-
...approvalInfo,
|
|
243
|
-
...metaInfo,
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
const getSanitizedQueryParams = (queryParams: CDMaterialServiceQueryParams): CDMaterialServiceQueryParams => {
|
|
248
|
-
const { filter, ...rest } = queryParams
|
|
249
|
-
return rest
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
export const genericCDMaterialsService = (
|
|
253
|
-
serviceType: CDMaterialServiceEnum,
|
|
254
|
-
cdMaterialID: number,
|
|
255
|
-
stage: DeploymentNodeType,
|
|
256
|
-
signal: AbortSignal,
|
|
257
|
-
queryParams: CDMaterialServiceQueryParams = {},
|
|
258
|
-
): Promise<CDMaterialResponseType> => {
|
|
259
|
-
// TODO: On update of service would remove from here
|
|
260
|
-
const manipulatedParams = getSanitizedQueryParams(queryParams)
|
|
261
|
-
|
|
262
|
-
let URL
|
|
263
|
-
switch (serviceType) {
|
|
264
|
-
case CDMaterialServiceEnum.ROLLBACK:
|
|
265
|
-
URL = processURL(`${ROUTES.CD_MATERIAL_GET}/${cdMaterialID}/material/rollback`, manipulatedParams)
|
|
266
|
-
break
|
|
267
|
-
|
|
268
|
-
// Meant for handling getCDMaterialList
|
|
269
|
-
default:
|
|
270
|
-
URL = processURL(`${ROUTES.CD_MATERIAL_GET}/${cdMaterialID}/material`, { ...manipulatedParams, stage: stageMap[stage] })
|
|
271
|
-
break
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
return get(URL, { signal }).then((response) => {
|
|
275
|
-
return processCDMaterialServiceResponse(response.result, stage, queryParams.offset, queryParams.filter)
|
|
276
131
|
})
|
|
277
132
|
}
|
|
278
133
|
|
package/src/Common/Constants.ts
CHANGED
package/src/Common/ImageTags.tsx
CHANGED
|
@@ -18,7 +18,6 @@ import { showError, stopPropagation } from './Helper'
|
|
|
18
18
|
import { TippyCustomized } from './TippyCustomized'
|
|
19
19
|
import { setImageTags, getUserRole } from './Common.service'
|
|
20
20
|
import Tippy from '@tippyjs/react'
|
|
21
|
-
import { Progressing } from './Progressing'
|
|
22
21
|
|
|
23
22
|
export const ImageTagsContainer = ({
|
|
24
23
|
ciPipelineId,
|
|
@@ -33,6 +32,7 @@ export const ImageTagsContainer = ({
|
|
|
33
32
|
toggleCardMode,
|
|
34
33
|
hideHardDelete,
|
|
35
34
|
forceReInit,
|
|
35
|
+
isSuperAdmin
|
|
36
36
|
}: ImageTaggingContainerType) => {
|
|
37
37
|
const [initialTags, setInitialTags] = useState<ReleaseTag[]>(imageReleaseTags ? imageReleaseTags : [])
|
|
38
38
|
const [initialDescription, setInitialDescription] = useState(imageComment ? imageComment.comment : '')
|
|
@@ -45,14 +45,9 @@ export const ImageTagsContainer = ({
|
|
|
45
45
|
const [createTags, setCreateTags] = useState<ReleaseTag[]>([])
|
|
46
46
|
const [softDeleteTags, setSoftDeleteTags] = useState<ReleaseTag[]>([])
|
|
47
47
|
const [hardDeleteTags, setHardDeleteTags] = useState<ReleaseTag[]>([])
|
|
48
|
-
const [isSuperAdmin, setSuperAdmin] = useState<boolean>(false)
|
|
49
48
|
const [descriptionValidationMessage, setDescriptionValidationMessage] = useState<string>('')
|
|
50
49
|
const [textInput, setTextInput] = useState<string>('')
|
|
51
|
-
const [loading, setLoading] = useState<boolean>(false)
|
|
52
50
|
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
initialise()
|
|
55
|
-
}, [])
|
|
56
51
|
|
|
57
52
|
useEffect(() => {
|
|
58
53
|
reInitState()
|
|
@@ -62,16 +57,6 @@ export const ImageTagsContainer = ({
|
|
|
62
57
|
setExistingTags(appReleaseTagNames ? appReleaseTagNames : [])
|
|
63
58
|
}, [appReleaseTagNames])
|
|
64
59
|
|
|
65
|
-
async function initialise() {
|
|
66
|
-
try {
|
|
67
|
-
const userRole = await getUserRole()
|
|
68
|
-
|
|
69
|
-
const superAdmin = userRole?.result?.roles?.includes('role:super-admin___')
|
|
70
|
-
setSuperAdmin(superAdmin)
|
|
71
|
-
} catch (err) {
|
|
72
|
-
showError(err)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
60
|
|
|
76
61
|
const reInitState = () => {
|
|
77
62
|
if (forceReInit || !isEditing) {
|
|
@@ -228,7 +213,6 @@ export const ImageTagsContainer = ({
|
|
|
228
213
|
}
|
|
229
214
|
|
|
230
215
|
// set loading state true
|
|
231
|
-
setLoading(true)
|
|
232
216
|
setImageTags(payload, ciPipelineId, artifactId)
|
|
233
217
|
.then((res) => {
|
|
234
218
|
const tags = res.result?.imageReleaseTags?.map((tag) => ({
|
|
@@ -265,9 +249,6 @@ export const ImageTagsContainer = ({
|
|
|
265
249
|
showError(err)
|
|
266
250
|
}
|
|
267
251
|
})
|
|
268
|
-
.finally(()=>{
|
|
269
|
-
setLoading(false)
|
|
270
|
-
})
|
|
271
252
|
}
|
|
272
253
|
|
|
273
254
|
const renderInfoCard = (): JSX.Element => {
|
|
@@ -444,7 +425,6 @@ export const ImageTagsContainer = ({
|
|
|
444
425
|
stopPropagation(e)
|
|
445
426
|
handleCancel()
|
|
446
427
|
}}
|
|
447
|
-
disabled={loading}
|
|
448
428
|
>
|
|
449
429
|
Cancel
|
|
450
430
|
</button>
|
|
@@ -456,9 +436,8 @@ export const ImageTagsContainer = ({
|
|
|
456
436
|
stopPropagation(e)
|
|
457
437
|
onClickSave()
|
|
458
438
|
}}
|
|
459
|
-
disabled={loading}
|
|
460
439
|
>
|
|
461
|
-
|
|
440
|
+
Save
|
|
462
441
|
</button>
|
|
463
442
|
</div>
|
|
464
443
|
</div>
|
package/src/Common/Types.ts
CHANGED
|
@@ -247,35 +247,6 @@ export interface CDMaterialType {
|
|
|
247
247
|
imageReleaseTags?: ReleaseTag[]
|
|
248
248
|
artifactStatus?: string
|
|
249
249
|
filterState: FilterStates
|
|
250
|
-
// Not even coming from API but required in CDMaterials for Security which makes its own api call but stores data in CDMaterials
|
|
251
|
-
scanToolId?: number
|
|
252
|
-
appliedFiltersTimestamp?: string
|
|
253
|
-
appliedFilters?: FilterConditionsListType[]
|
|
254
|
-
appliedFiltersState?: FilterStates
|
|
255
|
-
createdTime?: string
|
|
256
|
-
deployed?: boolean
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
export enum CDMaterialServiceEnum {
|
|
260
|
-
ROLLBACK = 'rollback',
|
|
261
|
-
CD_MATERIALS = 'cd-materials',
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
export enum CDMaterialResourceQuery {
|
|
265
|
-
PENDING_APPROVAL = 'PENDING_APPROVAL'
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
export enum CDMaterialFilterQuery {
|
|
269
|
-
RESOURCE = 'ELIGIBLE_RESOURCES',
|
|
270
|
-
ALL = 'ALL_RESOURCES'
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export interface CDMaterialServiceQueryParams {
|
|
274
|
-
search?: string
|
|
275
|
-
offset?: number
|
|
276
|
-
size?: number
|
|
277
|
-
resource?: CDMaterialResourceQuery
|
|
278
|
-
filter?: CDMaterialFilterQuery
|
|
279
250
|
}
|
|
280
251
|
|
|
281
252
|
export interface CommonNodeAttr {
|
|
@@ -391,22 +362,15 @@ export interface FilterConditionsListType {
|
|
|
391
362
|
conditions: FilterConditionsInfo[]
|
|
392
363
|
}
|
|
393
364
|
|
|
394
|
-
export interface
|
|
365
|
+
export interface CDMaterialResponseType {
|
|
395
366
|
approvalUsers: string[]
|
|
367
|
+
materials: any[]
|
|
396
368
|
userApprovalConfig: UserApprovalConfigType
|
|
397
369
|
requestedUserId: number
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
export interface CDMaterialsMetaInfo {
|
|
401
370
|
tagsEditable: boolean
|
|
402
371
|
appReleaseTagNames: string[]
|
|
403
372
|
hideImageTaggingHardDelete: boolean
|
|
404
373
|
resourceFilters?: FilterConditionsListType[]
|
|
405
|
-
totalCount: number
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
export interface CDMaterialResponseType extends CDMaterialsMetaInfo, CDMaterialsApprovalInfo {
|
|
409
|
-
materials: CDMaterialType[]
|
|
410
374
|
}
|
|
411
375
|
|
|
412
376
|
export interface InputDetailType {
|