@devtron-labs/devtron-fe-common-lib 0.0.37-beta-3 → 0.0.37-beta-4

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.
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { AppStatusType } from './types';
3
+ export default function AppStatus({ appStatus, isDeploymentStatus, isJobView, isVirtualEnv, hideStatusMessage, }: AppStatusType): JSX.Element;
@@ -0,0 +1,51 @@
1
+ export declare const StatusConstants: {
2
+ NOT_DEPLOYED: {
3
+ noSpaceLower: string;
4
+ normalCase: string;
5
+ lowerCase: string;
6
+ };
7
+ APP_STATUS: {
8
+ noSpaceLower: string;
9
+ normalText: string;
10
+ };
11
+ PROJECT: {
12
+ pluralLower: string;
13
+ lowerCase: string;
14
+ };
15
+ CLUSTER: {
16
+ pluralLower: string;
17
+ lowerCase: string;
18
+ };
19
+ NAMESPACE: {
20
+ pluralLower: string;
21
+ lowerCase: string;
22
+ };
23
+ ENVIRONMENT: {
24
+ pluralLower: string;
25
+ lowerCase: string;
26
+ };
27
+ NOT_AVILABLE: {
28
+ normalCase: string;
29
+ };
30
+ };
31
+ export declare enum TIMELINE_STATUS {
32
+ DEPLOYMENT_INITIATED = "DEPLOYMENT_INITIATED",
33
+ GIT_COMMIT = "GIT_COMMIT",
34
+ GIT_COMMIT_FAILED = "GIT_COMMIT_FAILED",
35
+ KUBECTL_APPLY = "KUBECTL_APPLY",
36
+ KUBECTL_APPLY_STARTED = "KUBECTL_APPLY_STARTED",
37
+ KUBECTL_APPLY_SYNCED = "KUBECTL_APPLY_SYNCED",
38
+ HEALTHY = "HEALTHY",
39
+ APP_HEALTH = "APP_HEALTH",
40
+ DEPLOYMENT_FAILED = "FAILED",
41
+ FETCH_TIMED_OUT = "TIMED_OUT",
42
+ UNABLE_TO_FETCH_STATUS = "UNABLE_TO_FETCH_STATUS",
43
+ DEGRADED = "DEGRADED",
44
+ DEPLOYMENT_SUPERSEDED = "DEPLOYMENT_SUPERSEDED",
45
+ ABORTED = "ABORTED",
46
+ INPROGRESS = "INPROGRESS",
47
+ HELM_PACKAGE_GENERATED = "HELM_PACKAGE_GENERATED",
48
+ HELM_MANIFEST_PUSHED_TO_HELM_REPO = "HELM_MANIFEST_PUSHED_TO_HELM_REPO",
49
+ HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED = "HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED"
50
+ }
51
+ export declare const YET_TO_RUN = "Yet to run";
@@ -0,0 +1 @@
1
+ export { default as AppStatus } from './AppStatus';
@@ -0,0 +1,12 @@
1
+ export interface AppStatusType {
2
+ appStatus: string;
3
+ isDeploymentStatus?: boolean;
4
+ isJobView?: boolean;
5
+ isVirtualEnv?: boolean;
6
+ /**
7
+ * Hide the status message if true
8
+ *
9
+ * @default false
10
+ */
11
+ hideStatusMessage?: boolean;
12
+ }
@@ -0,0 +1 @@
1
+ export declare const triggerStatus: (triggerDetailStatus: string) => string;
@@ -1,4 +1,4 @@
1
- import { TeamList, ResponseType, DeploymentNodeType, CDMaterialServiceEnum, CDMaterialServiceQueryParams, CDMaterialResponseType } 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?: {
@@ -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 genericCDMaterialsService: (serviceType: CDMaterialServiceEnum, cdMaterialID: number, stage: DeploymentNodeType, signal: AbortSignal, queryParams?: CDMaterialServiceQueryParams) => Promise<CDMaterialResponseType>;
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 {};
@@ -19,7 +19,6 @@ export declare const ROUTES: {
19
19
  PROJECT_LIST_MIN: string;
20
20
  USER_CHECK_ROLE: string;
21
21
  IMAGE_TAGGING: string;
22
- CD_MATERIAL_GET: string;
23
22
  };
24
23
  export declare enum KEY_VALUE {
25
24
  KEY = "key",
@@ -51,4 +51,5 @@ export declare const closeOnEscKeyPressed: (e: any, actionClose: () => void) =>
51
51
  */
52
52
  export declare function copyToClipboard(str: any, callback?: typeof noop): void;
53
53
  export declare function useAsync<T>(func: (...rest: any[]) => Promise<T>, dependencyArray?: any[], shouldRun?: boolean, options?: AsyncOptions): [boolean, T, any | null, () => void, React.Dispatch<any>, any[]];
54
+ export declare const processDeployedTime: (lastDeployed: any, isArgoInstalled: any) => string;
54
55
  export {};
@@ -202,9 +202,6 @@ export declare enum FilterStates {
202
202
  BLOCKED = 1,
203
203
  ERROR = 2
204
204
  }
205
- export declare enum MaterialDataSource {
206
- EXTERNAL = "ext"
207
- }
208
205
  export interface CDMaterialType {
209
206
  index: number;
210
207
  id: string;
@@ -231,31 +228,6 @@ export interface CDMaterialType {
231
228
  imageReleaseTags?: ReleaseTag[];
232
229
  artifactStatus?: string;
233
230
  filterState: FilterStates;
234
- scanToolId?: number;
235
- appliedFiltersTimestamp?: string;
236
- appliedFilters?: FilterConditionsListType[];
237
- appliedFiltersState?: FilterStates;
238
- createdTime?: string;
239
- deployed?: boolean;
240
- dataSource?: MaterialDataSource;
241
- }
242
- export declare enum CDMaterialServiceEnum {
243
- ROLLBACK = "rollback",
244
- CD_MATERIALS = "cd-materials"
245
- }
246
- export declare enum CDMaterialResourceQuery {
247
- PENDING_APPROVAL = "PENDING_APPROVAL"
248
- }
249
- export declare enum CDMaterialFilterQuery {
250
- RESOURCE = "ELIGIBLE_RESOURCES",
251
- ALL = "ALL_RESOURCES"
252
- }
253
- export interface CDMaterialServiceQueryParams {
254
- search?: string;
255
- offset?: number;
256
- size?: number;
257
- resource?: CDMaterialResourceQuery;
258
- filter?: CDMaterialFilterQuery;
259
231
  }
260
232
  export interface CommonNodeAttr {
261
233
  connectingCiPipelineId?: number;
@@ -362,21 +334,15 @@ export interface FilterConditionsListType {
362
334
  description: string;
363
335
  conditions: FilterConditionsInfo[];
364
336
  }
365
- export interface CDMaterialsApprovalInfo {
337
+ export interface CDMaterialResponseType {
366
338
  approvalUsers: string[];
339
+ materials: any[];
367
340
  userApprovalConfig: UserApprovalConfigType;
368
341
  requestedUserId: number;
369
- }
370
- export interface CDMaterialsMetaInfo {
371
342
  tagsEditable: boolean;
372
343
  appReleaseTagNames: string[];
373
344
  hideImageTaggingHardDelete: boolean;
374
345
  resourceFilters?: FilterConditionsListType[];
375
- totalCount: number;
376
- canApproverDeploy: boolean;
377
- }
378
- export interface CDMaterialResponseType extends CDMaterialsMetaInfo, CDMaterialsApprovalInfo {
379
- materials: CDMaterialType[];
380
346
  }
381
347
  export interface InputDetailType {
382
348
  label: string;
@@ -39,3 +39,4 @@ export { default as DebouncedSearch } from './DebouncedSearch/DebouncedSearch';
39
39
  export { default as Grid } from './Grid/Grid';
40
40
  export { default as ClipboardButton } from './ClipboardButton/ClipboardButton';
41
41
  export * from './Hooks';
42
+ export { AppStatus } from './AppStatus';
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,24 +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.MaterialDataSource = void 0;
435
- (function (MaterialDataSource) {
436
- MaterialDataSource["EXTERNAL"] = "ext";
437
- })(exports.MaterialDataSource || (exports.MaterialDataSource = {}));
438
- exports.CDMaterialServiceEnum = void 0;
439
- (function (CDMaterialServiceEnum) {
440
- CDMaterialServiceEnum["ROLLBACK"] = "rollback";
441
- CDMaterialServiceEnum["CD_MATERIALS"] = "cd-materials";
442
- })(exports.CDMaterialServiceEnum || (exports.CDMaterialServiceEnum = {}));
443
- exports.CDMaterialResourceQuery = void 0;
444
- (function (CDMaterialResourceQuery) {
445
- CDMaterialResourceQuery["PENDING_APPROVAL"] = "PENDING_APPROVAL";
446
- })(exports.CDMaterialResourceQuery || (exports.CDMaterialResourceQuery = {}));
447
- exports.CDMaterialFilterQuery = void 0;
448
- (function (CDMaterialFilterQuery) {
449
- CDMaterialFilterQuery["RESOURCE"] = "ELIGIBLE_RESOURCES";
450
- CDMaterialFilterQuery["ALL"] = "ALL_RESOURCES";
451
- })(exports.CDMaterialFilterQuery || (exports.CDMaterialFilterQuery = {}));
452
433
  exports.DeploymentAppTypes = void 0;
453
434
  (function (DeploymentAppTypes) {
454
435
  DeploymentAppTypes["HELM"] = "helm";
@@ -10239,7 +10220,15 @@ function useAsync(func, dependencyArray, shouldRun, options) {
10239
10220
  }
10240
10221
  };
10241
10222
  return [state.loading, state.result, state.error, reload, setResult, state.dependencies];
10242
- }
10223
+ }
10224
+ var processDeployedTime = function (lastDeployed, isArgoInstalled) {
10225
+ if (lastDeployed) {
10226
+ return handleUTCTime(lastDeployed, true);
10227
+ }
10228
+ else {
10229
+ return isArgoInstalled ? '' : 'Not deployed';
10230
+ }
10231
+ };
10243
10232
 
10244
10233
  function Progressing(_a) {
10245
10234
  var pageLoader = _a.pageLoader, size = _a.size, theme = _a.theme, styles = _a.styles, fillColor = _a.fillColor;
@@ -22708,170 +22697,77 @@ function getUserRole(appName) {
22708
22697
  function setImageTags(request, pipelineId, artifactId) {
22709
22698
  return post("".concat(ROUTES.IMAGE_TAGGING, "/").concat(pipelineId, "/").concat(artifactId), request);
22710
22699
  }
22711
- var processURL = function (url, params) {
22712
- var validParams = Object.keys(params).filter(function (key) {
22713
- return params[key] != null;
22714
- });
22715
- if (!validParams.length) {
22716
- return url;
22717
- }
22718
- var queryString = validParams
22719
- .map(function (key) {
22720
- if (Array.isArray(params[key])) {
22721
- return "".concat(key, "=").concat(params[key].join(','));
22722
- }
22723
- return "".concat(key, "=").concat(params[key]);
22724
- })
22725
- .join('&');
22726
- return "".concat(url, "?").concat(queryString);
22727
- };
22728
- var cdMaterialListModal = function (artifacts, offset, artifactId, artifactStatus) {
22729
- if (!artifacts || !artifacts.length)
22730
- return [];
22731
- var markFirstSelected = offset === 0;
22732
- var startIndex = offset;
22733
- var isImageMarked = false;
22734
- var materials = artifacts.map(function (material, index) {
22735
- var _a, _b, _c, _d, _e, _f;
22736
- var artifactStatusValue = '';
22737
- var filterState = (_a = material.filterState) !== null && _a !== void 0 ? _a : exports.FilterStates.ALLOWED;
22738
- if (artifactId && artifactStatus && material.id === artifactId) {
22739
- artifactStatusValue = artifactStatus;
22700
+ // 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.
22701
+ var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalNode, imageTag) {
22702
+ 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);
22703
+ return get(URL, {
22704
+ signal: abortSignal,
22705
+ }).then(function (response) {
22706
+ var _a;
22707
+ var artifacts = (_a = response.result.ci_artifacts) !== null && _a !== void 0 ? _a : [];
22708
+ if (!response.result) {
22709
+ return {
22710
+ materials: [],
22711
+ };
22740
22712
  }
22741
- var selectImage = !isImageMarked && markFirstSelected && filterState === exports.FilterStates.ALLOWED ? !material.vulnerable : false;
22742
- if (selectImage) {
22743
- isImageMarked = true;
22713
+ else {
22714
+ var materials = artifacts.map(function (material, index) {
22715
+ var _a;
22716
+ var artifactStatusValue = '';
22717
+ var filterState = (_a = material.filterState) !== null && _a !== void 0 ? _a : exports.FilterStates.ALLOWED;
22718
+ return {
22719
+ index: index,
22720
+ id: material.id,
22721
+ deployedTime: material.deployed_time
22722
+ ? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
22723
+ : 'Not Deployed',
22724
+ deployedBy: material.deployedBy,
22725
+ wfrId: material.wfrId,
22726
+ image: extractImage(material.image),
22727
+ showChanges: false,
22728
+ vulnerabilities: [],
22729
+ buildTime: material.build_time || '',
22730
+ tab: CDModalTab.Changes,
22731
+ showSourceInfo: false,
22732
+ deployed: material.deployed || false,
22733
+ latest: material.latest || false,
22734
+ vulnerabilitiesLoading: true,
22735
+ scanned: material.scanned,
22736
+ scanEnabled: material.scanEnabled,
22737
+ isSelected: !material.vulnerable && filterState === exports.FilterStates.ALLOWED && index === 0,
22738
+ vulnerable: material.vulnerable,
22739
+ runningOnParentCd: material.runningOnParentCd,
22740
+ artifactStatus: artifactStatusValue,
22741
+ userApprovalMetadata: material.userApprovalMetadata,
22742
+ triggeredBy: material.triggeredBy,
22743
+ isVirtualEnvironment: material.isVirtualEnvironment,
22744
+ imageComment: material.imageComment,
22745
+ imageReleaseTags: material.imageReleaseTags,
22746
+ materialInfo: material.material_info
22747
+ ? material.material_info.map(function (mat) {
22748
+ return {
22749
+ modifiedTime: mat.modifiedTime ? moment(mat.modifiedTime).format("ddd, DD MMM YYYY, hh:mm A") : '',
22750
+ commitLink: createGitCommitUrl(mat.url, mat.revision),
22751
+ author: mat.author || '',
22752
+ message: mat.message || '',
22753
+ revision: mat.revision || '',
22754
+ tag: mat.tag || '',
22755
+ webhookData: mat.webhookData || '',
22756
+ url: mat.url || '',
22757
+ branch: (material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
22758
+ ? material.ciConfigureSourceValue
22759
+ : mat.branch) || '',
22760
+ type: material.ciConfigureSourceType || '',
22761
+ };
22762
+ })
22763
+ : [],
22764
+ filterState: filterState,
22765
+ };
22766
+ });
22767
+ return {
22768
+ materials: materials
22769
+ };
22744
22770
  }
22745
- return {
22746
- index: startIndex + index,
22747
- id: material.id,
22748
- deployedTime: material.deployed_time
22749
- ? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
22750
- : 'Not Deployed',
22751
- deployedBy: material.deployedBy,
22752
- wfrId: material.wfrId,
22753
- tab: CDModalTab.Changes,
22754
- image: extractImage(material.image),
22755
- showChanges: false,
22756
- vulnerabilities: [],
22757
- buildTime: material.build_time || '',
22758
- isSelected: selectImage,
22759
- showSourceInfo: false,
22760
- deployed: material.deployed || false,
22761
- latest: material.latest || false,
22762
- vulnerabilitiesLoading: true,
22763
- scanned: material.scanned,
22764
- scanEnabled: material.scanEnabled,
22765
- vulnerable: material.vulnerable,
22766
- runningOnParentCd: material.runningOnParentCd,
22767
- artifactStatus: artifactStatusValue,
22768
- userApprovalMetadata: material.userApprovalMetadata,
22769
- triggeredBy: material.triggeredBy,
22770
- isVirtualEnvironment: material.isVirtualEnvironment,
22771
- imageComment: material.imageComment,
22772
- imageReleaseTags: material.imageReleaseTags,
22773
- // It is going to be null but required in type so can't remove
22774
- lastExecution: material.lastExecution,
22775
- materialInfo: material.material_info
22776
- ? material.material_info.map(function (mat) {
22777
- return {
22778
- modifiedTime: mat.modifiedTime
22779
- ? moment(mat.modifiedTime).format('ddd, DD MMM YYYY, hh:mm A')
22780
- : '',
22781
- commitLink: createGitCommitUrl(mat.url, mat.revision),
22782
- author: mat.author || '',
22783
- message: mat.message || '',
22784
- revision: mat.revision || '',
22785
- tag: mat.tag || '',
22786
- webhookData: mat.webhookData || '',
22787
- url: mat.url || '',
22788
- branch: (material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
22789
- ? material.ciConfigureSourceValue
22790
- : mat.branch) || '',
22791
- type: material.ciConfigureSourceType || '',
22792
- };
22793
- })
22794
- : [],
22795
- filterState: filterState,
22796
- appliedFiltersTimestamp: (_b = material.appliedFiltersTimestamp) !== null && _b !== void 0 ? _b : '',
22797
- appliedFilters: (_c = material.appliedFilters) !== null && _c !== void 0 ? _c : [],
22798
- appliedFiltersState: (_d = material.appliedFiltersState) !== null && _d !== void 0 ? _d : exports.FilterStates.ALLOWED,
22799
- createdTime: (_e = material.createdTime) !== null && _e !== void 0 ? _e : '',
22800
- dataSource: (_f = material.data_source) !== null && _f !== void 0 ? _f : '',
22801
- };
22802
- });
22803
- return materials;
22804
- };
22805
- var processCDMaterialsApprovalInfo = function (enableApproval, cdMaterialsResult) {
22806
- if (!enableApproval) {
22807
- return {
22808
- approvalUsers: [],
22809
- userApprovalConfig: null,
22810
- requestedUserId: 0,
22811
- };
22812
- }
22813
- return {
22814
- approvalUsers: cdMaterialsResult.approvalUsers,
22815
- userApprovalConfig: cdMaterialsResult.userApprovalConfig,
22816
- requestedUserId: cdMaterialsResult.requestedUserId,
22817
- };
22818
- };
22819
- var processCDMaterialsMetaInfo = function (cdMaterialsResult) {
22820
- var _a, _b, _c, _d;
22821
- if (!cdMaterialsResult) {
22822
- return {
22823
- tagsEditable: false,
22824
- appReleaseTagNames: [],
22825
- hideImageTaggingHardDelete: false,
22826
- resourceFilters: [],
22827
- totalCount: 0,
22828
- canApproverDeploy: (_a = cdMaterialsResult.canApproverDeploy) !== null && _a !== void 0 ? _a : false,
22829
- };
22830
- }
22831
- return {
22832
- appReleaseTagNames: cdMaterialsResult.appReleaseTagNames,
22833
- tagsEditable: cdMaterialsResult.tagsEditable,
22834
- hideImageTaggingHardDelete: cdMaterialsResult.hideImageTaggingHardDelete,
22835
- resourceFilters: (_b = cdMaterialsResult.resourceFilters) !== null && _b !== void 0 ? _b : [],
22836
- totalCount: (_c = cdMaterialsResult.totalCount) !== null && _c !== void 0 ? _c : 0,
22837
- canApproverDeploy: (_d = cdMaterialsResult.canApproverDeploy) !== null && _d !== void 0 ? _d : false,
22838
- };
22839
- };
22840
- var processCDMaterialServiceResponse = function (cdMaterialsResult, stage, offset, filter) {
22841
- if (!cdMaterialsResult) {
22842
- return __assign(__assign({ materials: [] }, processCDMaterialsMetaInfo(cdMaterialsResult)), processCDMaterialsApprovalInfo(false, cdMaterialsResult));
22843
- }
22844
- var materials = cdMaterialListModal(cdMaterialsResult.ci_artifacts, offset !== null && offset !== void 0 ? offset : 0, cdMaterialsResult.latest_wf_artifact_id, cdMaterialsResult.latest_wf_artifact_status);
22845
- var approvalInfo = processCDMaterialsApprovalInfo(stage === exports.DeploymentNodeType.CD || stage === exports.DeploymentNodeType.APPROVAL, cdMaterialsResult);
22846
- var metaInfo = processCDMaterialsMetaInfo(cdMaterialsResult);
22847
- // TODO: On update of service would remove from here
22848
- var filteredMaterials = filter && filter === exports.CDMaterialFilterQuery.RESOURCE
22849
- ? materials.filter(function (material) {
22850
- return material.filterState === exports.FilterStates.ALLOWED;
22851
- })
22852
- : materials;
22853
- return __assign(__assign({ materials: filteredMaterials }, approvalInfo), metaInfo);
22854
- };
22855
- var getSanitizedQueryParams = function (queryParams) {
22856
- queryParams.filter; var rest = __rest(queryParams, ["filter"]);
22857
- return rest;
22858
- };
22859
- var genericCDMaterialsService = function (serviceType, cdMaterialID, stage, signal, queryParams) {
22860
- if (queryParams === void 0) { queryParams = {}; }
22861
- // TODO: On update of service would remove from here
22862
- var manipulatedParams = getSanitizedQueryParams(queryParams);
22863
- var URL;
22864
- switch (serviceType) {
22865
- case exports.CDMaterialServiceEnum.ROLLBACK:
22866
- URL = processURL("".concat(ROUTES.CD_MATERIAL_GET, "/").concat(cdMaterialID, "/material/rollback"), manipulatedParams);
22867
- break;
22868
- // Meant for handling getCDMaterialList
22869
- default:
22870
- URL = processURL("".concat(ROUTES.CD_MATERIAL_GET, "/").concat(cdMaterialID, "/material"), __assign(__assign({}, manipulatedParams), { stage: stageMap[stage] }));
22871
- break;
22872
- }
22873
- return get(URL, { signal: signal }).then(function (response) {
22874
- return processCDMaterialServiceResponse(response.result, stage, queryParams.offset, queryParams.filter);
22875
22771
  });
22876
22772
  };
22877
22773
  function extractImage(image) {
@@ -23238,9 +23134,7 @@ var SvgIcEnter = function SvgIcEnter(props) {
23238
23134
  };
23239
23135
 
23240
23136
  var ImageTagsContainer = function (_a) {
23241
- var
23242
- // Setting it to zero in case of external pipeline
23243
- 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;
23137
+ 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;
23244
23138
  var _b = __read(React.useState(imageReleaseTags ? imageReleaseTags : []), 2), initialTags = _b[0], setInitialTags = _b[1];
23245
23139
  var _c = __read(React.useState(imageComment ? imageComment.comment : ''), 2), initialDescription = _c[0], setInitialDescription = _c[1];
23246
23140
  var _d = __read(React.useState(appReleaseTagNames ? appReleaseTagNames : []), 2), existingTags = _d[0], setExistingTags = _d[1];
@@ -23254,7 +23148,6 @@ var ImageTagsContainer = function (_a) {
23254
23148
  var _m = __read(React.useState([]), 2), hardDeleteTags = _m[0], setHardDeleteTags = _m[1];
23255
23149
  var _o = __read(React.useState(''), 2), descriptionValidationMessage = _o[0], setDescriptionValidationMessage = _o[1];
23256
23150
  var _p = __read(React.useState(''), 2), textInput = _p[0], setTextInput = _p[1];
23257
- var _q = __read(React.useState(false), 2), loading = _q[0], setLoading = _q[1];
23258
23151
  React.useEffect(function () {
23259
23152
  reInitState();
23260
23153
  }, [imageReleaseTags, imageComment, tagsEditable]);
@@ -23402,8 +23295,7 @@ var ImageTagsContainer = function (_a) {
23402
23295
  hardDeleteTags: hardDeleteTags,
23403
23296
  };
23404
23297
  // set loading state true
23405
- setLoading(true);
23406
- setImageTags(payload, ciPipelineId !== null && ciPipelineId !== void 0 ? ciPipelineId : 0, artifactId)
23298
+ setImageTags(payload, ciPipelineId, artifactId)
23407
23299
  .then(function (res) {
23408
23300
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
23409
23301
  var tags = (_b = (_a = res.result) === null || _a === void 0 ? void 0 : _a.imageReleaseTags) === null || _b === void 0 ? void 0 : _b.map(function (tag) { return ({
@@ -23442,9 +23334,6 @@ var ImageTagsContainer = function (_a) {
23442
23334
  else {
23443
23335
  showError(err);
23444
23336
  }
23445
- })
23446
- .finally(function () {
23447
- setLoading(false);
23448
23337
  });
23449
23338
  return [2 /*return*/];
23450
23339
  });
@@ -23495,10 +23384,10 @@ var ImageTagsContainer = function (_a) {
23495
23384
  }, 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) {
23496
23385
  stopPropagation(e);
23497
23386
  handleCancel();
23498
- }, disabled: loading }, { 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) {
23387
+ } }, { 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) {
23499
23388
  stopPropagation(e);
23500
23389
  onClickSave();
23501
- }, disabled: loading }, { children: loading ? jsxRuntime.jsx(Progressing, {}) : '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) {
23390
+ } }, { 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) {
23502
23391
  stopPropagation(e);
23503
23392
  handleTagSoftDelete(index);
23504
23393
  }, onHardDeleteClick: function (e) {
@@ -23727,6 +23616,101 @@ var useSuperAdmin = function () {
23727
23616
  return { isSuperAdmin: isSuperAdmin };
23728
23617
  };
23729
23618
 
23619
+ var StatusConstants = {
23620
+ NOT_DEPLOYED: {
23621
+ noSpaceLower: 'notdeployed',
23622
+ normalCase: 'Not deployed',
23623
+ lowerCase: 'not-deployed',
23624
+ },
23625
+ APP_STATUS: {
23626
+ noSpaceLower: 'appStatus',
23627
+ normalText: 'App status',
23628
+ },
23629
+ PROJECT: {
23630
+ pluralLower: 'projects',
23631
+ lowerCase: 'project',
23632
+ },
23633
+ CLUSTER: {
23634
+ pluralLower: 'clusters',
23635
+ lowerCase: 'cluster',
23636
+ },
23637
+ NAMESPACE: {
23638
+ pluralLower: 'namespaces',
23639
+ lowerCase: 'namespace',
23640
+ },
23641
+ ENVIRONMENT: {
23642
+ pluralLower: 'environments',
23643
+ lowerCase: 'environment',
23644
+ },
23645
+ NOT_AVILABLE: {
23646
+ normalCase: 'Not available',
23647
+ },
23648
+ };
23649
+ var TIMELINE_STATUS;
23650
+ (function (TIMELINE_STATUS) {
23651
+ TIMELINE_STATUS["DEPLOYMENT_INITIATED"] = "DEPLOYMENT_INITIATED";
23652
+ TIMELINE_STATUS["GIT_COMMIT"] = "GIT_COMMIT";
23653
+ TIMELINE_STATUS["GIT_COMMIT_FAILED"] = "GIT_COMMIT_FAILED";
23654
+ TIMELINE_STATUS["KUBECTL_APPLY"] = "KUBECTL_APPLY";
23655
+ TIMELINE_STATUS["KUBECTL_APPLY_STARTED"] = "KUBECTL_APPLY_STARTED";
23656
+ TIMELINE_STATUS["KUBECTL_APPLY_SYNCED"] = "KUBECTL_APPLY_SYNCED";
23657
+ TIMELINE_STATUS["HEALTHY"] = "HEALTHY";
23658
+ TIMELINE_STATUS["APP_HEALTH"] = "APP_HEALTH";
23659
+ TIMELINE_STATUS["DEPLOYMENT_FAILED"] = "FAILED";
23660
+ TIMELINE_STATUS["FETCH_TIMED_OUT"] = "TIMED_OUT";
23661
+ TIMELINE_STATUS["UNABLE_TO_FETCH_STATUS"] = "UNABLE_TO_FETCH_STATUS";
23662
+ TIMELINE_STATUS["DEGRADED"] = "DEGRADED";
23663
+ TIMELINE_STATUS["DEPLOYMENT_SUPERSEDED"] = "DEPLOYMENT_SUPERSEDED";
23664
+ TIMELINE_STATUS["ABORTED"] = "ABORTED";
23665
+ TIMELINE_STATUS["INPROGRESS"] = "INPROGRESS";
23666
+ TIMELINE_STATUS["HELM_PACKAGE_GENERATED"] = "HELM_PACKAGE_GENERATED";
23667
+ TIMELINE_STATUS["HELM_MANIFEST_PUSHED_TO_HELM_REPO"] = "HELM_MANIFEST_PUSHED_TO_HELM_REPO";
23668
+ TIMELINE_STATUS["HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED"] = "HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED";
23669
+ })(TIMELINE_STATUS || (TIMELINE_STATUS = {}));
23670
+ var YET_TO_RUN = 'Yet to run';
23671
+
23672
+ var triggerStatus = function (triggerDetailStatus) {
23673
+ var triggerStatus = triggerDetailStatus === null || triggerDetailStatus === void 0 ? void 0 : triggerDetailStatus.toUpperCase();
23674
+ if (triggerStatus === TIMELINE_STATUS.ABORTED || triggerStatus === TIMELINE_STATUS.DEGRADED) {
23675
+ return 'Failed';
23676
+ }
23677
+ else if (triggerStatus === TIMELINE_STATUS.HEALTHY) {
23678
+ return 'Succeeded';
23679
+ }
23680
+ else if (triggerStatus === TIMELINE_STATUS.INPROGRESS) {
23681
+ return 'Inprogress';
23682
+ }
23683
+ else {
23684
+ return triggerDetailStatus;
23685
+ }
23686
+ };
23687
+
23688
+ function AppStatus(_a) {
23689
+ var appStatus = _a.appStatus, _b = _a.isDeploymentStatus, isDeploymentStatus = _b === void 0 ? false : _b, _c = _a.isJobView, isJobView = _c === void 0 ? false : _c, isVirtualEnv = _a.isVirtualEnv, _d = _a.hideStatusMessage, hideStatusMessage = _d === void 0 ? false : _d;
23690
+ var status = appStatus;
23691
+ if (isDeploymentStatus) {
23692
+ status = triggerStatus(appStatus);
23693
+ }
23694
+ var appStatusLowerCase = status === null || status === void 0 ? void 0 : status.toLowerCase();
23695
+ var isNotDeployed = appStatusLowerCase === StatusConstants.NOT_DEPLOYED.noSpaceLower;
23696
+ var iconClass = isNotDeployed ? StatusConstants.NOT_DEPLOYED.lowerCase : appStatusLowerCase;
23697
+ var statusMessage = status || (isVirtualEnv ? StatusConstants.NOT_AVILABLE.normalCase : '-');
23698
+ var notDeployed = isJobView ? YET_TO_RUN : StatusConstants.NOT_DEPLOYED.normalCase;
23699
+ var renderIcon = function () {
23700
+ if (iconClass) {
23701
+ return jsxRuntime.jsx("span", { className: "dc__app-summary__icon icon-dim-16 ".concat(iconClass, " ").concat(iconClass, "--node") });
23702
+ }
23703
+ else if (isVirtualEnv) {
23704
+ return (jsxRuntime.jsx("span", { className: "dc__app-summary__icon icon-dim-16 ".concat(StatusConstants.NOT_DEPLOYED.lowerCase, " ").concat(StatusConstants.NOT_DEPLOYED.lowerCase, "--node") }));
23705
+ }
23706
+ else {
23707
+ return (jsxRuntime.jsx(Tippy, __assign({ className: "default-tt w-200", arrow: false, placement: "top", content: "To fetch app status for GitOps based deployments open the app detail page" }, { children: jsxRuntime.jsx(SvgIcInfoOutlined, { className: "icon-dim-16 fcn-6" }) })));
23708
+ }
23709
+ };
23710
+ return hideStatusMessage ? (renderIcon()) : (jsxRuntime.jsxs("div", __assign({ className: "flex left" }, { children: [jsxRuntime.jsx("div", __assign({ className: "flex mr-6" }, { children: renderIcon() })), jsxRuntime.jsx("p", __assign({ "data-testid": "".concat(status, "-app-status"), className: "dc__truncate-text dc__first-letter-capitalize cn-6 m-0" }, { children: isNotDeployed ? notDeployed : statusMessage }))] })));
23711
+ }
23712
+
23713
+ exports.AppStatus = AppStatus;
23730
23714
  exports.BreadCrumb = BreadCrumb;
23731
23715
  exports.BreadcrumbStore = Store;
23732
23716
  exports.BuildStageVariable = BuildStageVariable;
@@ -23802,9 +23786,9 @@ exports.closeOnEscKeyPressed = closeOnEscKeyPressed;
23802
23786
  exports.copyToClipboard = copyToClipboard;
23803
23787
  exports.createGitCommitUrl = createGitCommitUrl;
23804
23788
  exports.extractImage = extractImage;
23805
- exports.genericCDMaterialsService = genericCDMaterialsService;
23806
23789
  exports.get = get;
23807
23790
  exports.getAlphabetIcon = getAlphabetIcon;
23791
+ exports.getCDMaterials = getCDMaterials;
23808
23792
  exports.getCookie = getCookie;
23809
23793
  exports.getEmptyArrayOfLength = getEmptyArrayOfLength;
23810
23794
  exports.getLoginInfo = getLoginInfo;
@@ -23816,6 +23800,7 @@ exports.multiSelectStyles = multiSelectStyles;
23816
23800
  exports.noop = noop$1;
23817
23801
  exports.not = not;
23818
23802
  exports.post = post;
23803
+ exports.processDeployedTime = processDeployedTime;
23819
23804
  exports.put = put;
23820
23805
  exports.setImageTags = setImageTags;
23821
23806
  exports.showError = showError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.37-beta-3",
3
+ "version": "0.0.37-beta-4",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -0,0 +1,13 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
2
+ <g fill="none" fill-rule="evenodd">
3
+ <g fill="#06C">
4
+ <g>
5
+ <g>
6
+ <g>
7
+ <path d="M10 1.667c4.6 0 8.333 3.733 8.333 8.333S14.6 18.333 10 18.333 1.667 14.6 1.667 10 5.4 1.667 10 1.667zm0 1.666C6.32 3.333 3.333 6.32 3.333 10c0 3.68 2.987 6.667 6.667 6.667 3.68 0 6.667-2.987 6.667-6.667 0-3.68-2.987-6.667-6.667-6.667zm0 5.834c.46 0 .833.373.833.833v3.333c0 .46-.373.834-.833.834-.46 0-.833-.373-.833-.834V10c0-.46.373-.833.833-.833zm0-3.334c.46 0 .833.373.833.834 0 .46-.373.833-.833.833-.46 0-.833-.373-.833-.833 0-.46.373-.834.833-.834z" transform="translate(-315.000000, -313.000000) translate(303.000000, 256.000000) translate(4.000000, 49.000000) translate(8.000000, 8.000000)"/>
8
+ </g>
9
+ </g>
10
+ </g>
11
+ </g>
12
+ </g>
13
+ </svg>
@@ -0,0 +1,57 @@
1
+ import Tippy from '@tippyjs/react'
2
+ import { ReactComponent as InfoIcon } from '../../Assets/Icon/ic-info-outlined.svg'
3
+ import { StatusConstants, YET_TO_RUN } from './constants'
4
+ import { AppStatusType } from './types'
5
+ import { triggerStatus } from './utils'
6
+
7
+ export default function AppStatus({
8
+ appStatus,
9
+ isDeploymentStatus = false,
10
+ isJobView = false,
11
+ isVirtualEnv,
12
+ hideStatusMessage = false,
13
+ }: AppStatusType) {
14
+ let status = appStatus
15
+ if (isDeploymentStatus) {
16
+ status = triggerStatus(appStatus)
17
+ }
18
+ const appStatusLowerCase = status?.toLowerCase()
19
+ const isNotDeployed = appStatusLowerCase === StatusConstants.NOT_DEPLOYED.noSpaceLower
20
+ const iconClass = isNotDeployed ? StatusConstants.NOT_DEPLOYED.lowerCase : appStatusLowerCase
21
+ const statusMessage = status || (isVirtualEnv ? StatusConstants.NOT_AVILABLE.normalCase : '-')
22
+ const notDeployed = isJobView ? YET_TO_RUN : StatusConstants.NOT_DEPLOYED.normalCase
23
+
24
+ const renderIcon = () => {
25
+ if (iconClass) {
26
+ return <span className={`dc__app-summary__icon icon-dim-16 ${iconClass} ${iconClass}--node`} />
27
+ } else if (isVirtualEnv) {
28
+ return (
29
+ <span
30
+ className={`dc__app-summary__icon icon-dim-16 ${StatusConstants.NOT_DEPLOYED.lowerCase} ${StatusConstants.NOT_DEPLOYED.lowerCase}--node`}
31
+ />
32
+ )
33
+ } else {
34
+ return (
35
+ <Tippy
36
+ className="default-tt w-200"
37
+ arrow={false}
38
+ placement="top"
39
+ content="To fetch app status for GitOps based deployments open the app detail page"
40
+ >
41
+ <InfoIcon className="icon-dim-16 fcn-6" />
42
+ </Tippy>
43
+ )
44
+ }
45
+ }
46
+
47
+ return hideStatusMessage ? (
48
+ renderIcon()
49
+ ) : (
50
+ <div className="flex left">
51
+ <div className="flex mr-6">{renderIcon()}</div>
52
+ <p data-testid={`${status}-app-status`} className="dc__truncate-text dc__first-letter-capitalize cn-6 m-0">
53
+ {isNotDeployed ? notDeployed : statusMessage}
54
+ </p>
55
+ </div>
56
+ )
57
+ }
@@ -0,0 +1,53 @@
1
+ export const StatusConstants = {
2
+ NOT_DEPLOYED: {
3
+ noSpaceLower: 'notdeployed',
4
+ normalCase: 'Not deployed',
5
+ lowerCase: 'not-deployed',
6
+ },
7
+ APP_STATUS: {
8
+ noSpaceLower: 'appStatus',
9
+ normalText: 'App status',
10
+ },
11
+ PROJECT: {
12
+ pluralLower: 'projects',
13
+ lowerCase: 'project',
14
+ },
15
+ CLUSTER: {
16
+ pluralLower: 'clusters',
17
+ lowerCase: 'cluster',
18
+ },
19
+ NAMESPACE: {
20
+ pluralLower: 'namespaces',
21
+ lowerCase: 'namespace',
22
+ },
23
+ ENVIRONMENT: {
24
+ pluralLower: 'environments',
25
+ lowerCase: 'environment',
26
+ },
27
+ NOT_AVILABLE: {
28
+ normalCase: 'Not available',
29
+ },
30
+ }
31
+
32
+ export enum TIMELINE_STATUS {
33
+ DEPLOYMENT_INITIATED = 'DEPLOYMENT_INITIATED',
34
+ GIT_COMMIT = 'GIT_COMMIT',
35
+ GIT_COMMIT_FAILED = 'GIT_COMMIT_FAILED',
36
+ KUBECTL_APPLY = 'KUBECTL_APPLY',
37
+ KUBECTL_APPLY_STARTED = 'KUBECTL_APPLY_STARTED',
38
+ KUBECTL_APPLY_SYNCED = 'KUBECTL_APPLY_SYNCED',
39
+ HEALTHY = 'HEALTHY',
40
+ APP_HEALTH = 'APP_HEALTH',
41
+ DEPLOYMENT_FAILED = 'FAILED',
42
+ FETCH_TIMED_OUT = 'TIMED_OUT',
43
+ UNABLE_TO_FETCH_STATUS = 'UNABLE_TO_FETCH_STATUS',
44
+ DEGRADED = 'DEGRADED',
45
+ DEPLOYMENT_SUPERSEDED = 'DEPLOYMENT_SUPERSEDED',
46
+ ABORTED = 'ABORTED',
47
+ INPROGRESS = 'INPROGRESS',
48
+ HELM_PACKAGE_GENERATED = 'HELM_PACKAGE_GENERATED',
49
+ HELM_MANIFEST_PUSHED_TO_HELM_REPO = 'HELM_MANIFEST_PUSHED_TO_HELM_REPO',
50
+ HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED = 'HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED',
51
+ }
52
+
53
+ export const YET_TO_RUN = 'Yet to run'
@@ -0,0 +1 @@
1
+ export { default as AppStatus } from './AppStatus'
@@ -0,0 +1,12 @@
1
+ export interface AppStatusType {
2
+ appStatus: string
3
+ isDeploymentStatus?: boolean
4
+ isJobView?: boolean
5
+ isVirtualEnv?: boolean
6
+ /**
7
+ * Hide the status message if true
8
+ *
9
+ * @default false
10
+ */
11
+ hideStatusMessage?: boolean
12
+ }
@@ -0,0 +1,14 @@
1
+ import { TIMELINE_STATUS } from './constants'
2
+
3
+ export const triggerStatus = (triggerDetailStatus: string): string => {
4
+ let triggerStatus = triggerDetailStatus?.toUpperCase()
5
+ if (triggerStatus === TIMELINE_STATUS.ABORTED || triggerStatus === TIMELINE_STATUS.DEGRADED) {
6
+ return 'Failed'
7
+ } else if (triggerStatus === TIMELINE_STATUS.HEALTHY) {
8
+ return 'Succeeded'
9
+ } else if (triggerStatus === TIMELINE_STATUS.INPROGRESS) {
10
+ return 'Inprogress'
11
+ } else {
12
+ return triggerDetailStatus
13
+ }
14
+ }
@@ -2,19 +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
- } from './Types'
5
+ import { TeamList ,ResponseType, DeploymentNodeType, CDModalTab, FilterStates } from './Types';
18
6
 
19
7
  export const getTeamListMin = (): Promise<TeamList> => {
20
8
  // ignore active field
@@ -42,7 +30,7 @@ interface UserRole extends ResponseType {
42
30
  }
43
31
  }
44
32
 
45
- const stageMap = {
33
+ let stageMap = {
46
34
  PRECD: 'PRE',
47
35
  CD: 'DEPLOY',
48
36
  POSTCD: 'POST',
@@ -63,218 +51,83 @@ export function setImageTags(request, pipelineId: number, artifactId: number){
63
51
  return post(`${ROUTES.IMAGE_TAGGING}/${pipelineId}/${artifactId}`,request )
64
52
  }
65
53
 
66
- const processURL = (url: string, params: object) => {
67
- const validParams = Object.keys(params).filter((key) => {
68
- return params[key] != null
69
- })
70
-
71
- if (!validParams.length) {
72
- return url
73
- }
74
-
75
- const queryString = validParams
76
- .map((key) => {
77
- if (Array.isArray(params[key])) {
78
- return `${key}=${params[key].join(',')}`
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: [],
79
70
  }
80
- return `${key}=${params[key]}`
81
- })
82
- .join('&')
83
-
84
- return `${url}?${queryString}`
85
- }
86
-
87
- const cdMaterialListModal = (artifacts: any[], offset: number, artifactId?: number, artifactStatus?: string) => {
88
- if (!artifacts || !artifacts.length) return []
89
-
90
- const markFirstSelected = offset === 0
91
- const startIndex = offset
92
- let isImageMarked = false
93
-
94
- const materials = artifacts.map((material, index) => {
95
- let artifactStatusValue = ''
96
- const filterState = material.filterState ?? FilterStates.ALLOWED
97
-
98
- if (artifactId && artifactStatus && material.id === artifactId) {
99
- artifactStatusValue = artifactStatus
100
- }
101
-
102
- const selectImage =
103
- !isImageMarked && markFirstSelected && filterState === FilterStates.ALLOWED ? !material.vulnerable : false
104
- if (selectImage) {
105
- isImageMarked = true
106
- }
107
-
108
- return {
109
- index: startIndex + index,
110
- id: material.id,
111
- deployedTime: material.deployed_time
112
- ? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
113
- : 'Not Deployed',
114
- deployedBy: material.deployedBy,
115
- wfrId: material.wfrId,
116
- tab: CDModalTab.Changes,
117
- image: extractImage(material.image),
118
- showChanges: false,
119
- vulnerabilities: [],
120
- buildTime: material.build_time || '',
121
- isSelected: selectImage,
122
- showSourceInfo: false,
123
- deployed: material.deployed || false,
124
- latest: material.latest || false,
125
- vulnerabilitiesLoading: true,
126
- scanned: material.scanned,
127
- scanEnabled: material.scanEnabled,
128
- vulnerable: material.vulnerable,
129
- runningOnParentCd: material.runningOnParentCd,
130
- artifactStatus: artifactStatusValue,
131
- userApprovalMetadata: material.userApprovalMetadata,
132
- triggeredBy: material.triggeredBy,
133
- isVirtualEnvironment: material.isVirtualEnvironment,
134
- imageComment: material.imageComment,
135
- imageReleaseTags: material.imageReleaseTags,
136
- // It is going to be null but required in type so can't remove
137
- lastExecution: material.lastExecution,
138
- materialInfo: material.material_info
139
- ? material.material_info.map((mat) => {
140
- return {
141
- modifiedTime: mat.modifiedTime
142
- ? moment(mat.modifiedTime).format('ddd, DD MMM YYYY, hh:mm A')
143
- : '',
144
- commitLink: createGitCommitUrl(mat.url, mat.revision),
145
- author: mat.author || '',
146
- message: mat.message || '',
147
- revision: mat.revision || '',
148
- tag: mat.tag || '',
149
- webhookData: mat.webhookData || '',
150
- url: mat.url || '',
151
- branch:
152
- (material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
153
- ? material.ciConfigureSourceValue
154
- : mat.branch) || '',
155
- type: material.ciConfigureSourceType || '',
156
- }
157
- })
158
- : [],
159
- filterState,
160
- appliedFiltersTimestamp: material.appliedFiltersTimestamp ?? '',
161
- appliedFilters: material.appliedFilters ?? [],
162
- appliedFiltersState: material.appliedFiltersState ?? FilterStates.ALLOWED,
163
- createdTime: material.createdTime ?? '',
164
- dataSource: material.data_source ?? '',
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
- canApproverDeploy: cdMaterialsResult.canApproverDeploy ?? false,
195
71
  }
196
- }
197
-
198
- return {
199
- appReleaseTagNames: cdMaterialsResult.appReleaseTagNames,
200
- tagsEditable: cdMaterialsResult.tagsEditable,
201
- hideImageTaggingHardDelete: cdMaterialsResult.hideImageTaggingHardDelete,
202
- resourceFilters: cdMaterialsResult.resourceFilters ?? [],
203
- totalCount: cdMaterialsResult.totalCount ?? 0,
204
- canApproverDeploy: cdMaterialsResult.canApproverDeploy ?? false,
205
- }
206
- }
207
-
208
- const processCDMaterialServiceResponse = (
209
- cdMaterialsResult,
210
- stage: DeploymentNodeType,
211
- offset: number,
212
- filter: CDMaterialFilterQuery,
213
- ): CDMaterialResponseType => {
214
- if (!cdMaterialsResult) {
215
- return {
216
- materials: [],
217
- ...processCDMaterialsMetaInfo(cdMaterialsResult),
218
- ...processCDMaterialsApprovalInfo(false, cdMaterialsResult),
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
+ }
219
130
  }
220
- }
221
-
222
- const materials = cdMaterialListModal(
223
- cdMaterialsResult.ci_artifacts,
224
- offset ?? 0,
225
- cdMaterialsResult.latest_wf_artifact_id,
226
- cdMaterialsResult.latest_wf_artifact_status,
227
- )
228
- const approvalInfo = processCDMaterialsApprovalInfo(
229
- stage === DeploymentNodeType.CD || stage === DeploymentNodeType.APPROVAL,
230
- cdMaterialsResult,
231
- )
232
- const metaInfo = processCDMaterialsMetaInfo(cdMaterialsResult)
233
-
234
- // TODO: On update of service would remove from here
235
- const filteredMaterials =
236
- filter && filter === CDMaterialFilterQuery.RESOURCE
237
- ? materials.filter((material) => {
238
- return material.filterState === FilterStates.ALLOWED
239
- })
240
- : materials
241
-
242
- return {
243
- materials: filteredMaterials,
244
- ...approvalInfo,
245
- ...metaInfo,
246
- }
247
- }
248
-
249
- const getSanitizedQueryParams = (queryParams: CDMaterialServiceQueryParams): CDMaterialServiceQueryParams => {
250
- const { filter, ...rest } = queryParams
251
- return rest
252
- }
253
-
254
- export const genericCDMaterialsService = (
255
- serviceType: CDMaterialServiceEnum,
256
- cdMaterialID: number,
257
- stage: DeploymentNodeType,
258
- signal: AbortSignal,
259
- queryParams: CDMaterialServiceQueryParams = {},
260
- ): Promise<CDMaterialResponseType> => {
261
- // TODO: On update of service would remove from here
262
- const manipulatedParams = getSanitizedQueryParams(queryParams)
263
-
264
- let URL
265
- switch (serviceType) {
266
- case CDMaterialServiceEnum.ROLLBACK:
267
- URL = processURL(`${ROUTES.CD_MATERIAL_GET}/${cdMaterialID}/material/rollback`, manipulatedParams)
268
- break
269
-
270
- // Meant for handling getCDMaterialList
271
- default:
272
- URL = processURL(`${ROUTES.CD_MATERIAL_GET}/${cdMaterialID}/material`, { ...manipulatedParams, stage: stageMap[stage] })
273
- break
274
- }
275
-
276
- return get(URL, { signal }).then((response) => {
277
- return processCDMaterialServiceResponse(response.result, stage, queryParams.offset, queryParams.filter)
278
131
  })
279
132
  }
280
133
 
@@ -24,7 +24,6 @@ export const ROUTES = {
24
24
  PROJECT_LIST_MIN: 'team/autocomplete',
25
25
  USER_CHECK_ROLE: 'user/check/roles',
26
26
  IMAGE_TAGGING:'app/image-tagging',
27
- CD_MATERIAL_GET: 'app/cd-pipeline'
28
27
  }
29
28
 
30
29
  export enum KEY_VALUE {
@@ -487,3 +487,11 @@ export function useAsync<T>(
487
487
 
488
488
  return [state.loading, state.result, state.error, reload, setResult, state.dependencies]
489
489
  }
490
+
491
+ export const processDeployedTime = (lastDeployed, isArgoInstalled) => {
492
+ if (lastDeployed) {
493
+ return handleUTCTime(lastDeployed, true)
494
+ } else {
495
+ return isArgoInstalled ? '' : 'Not deployed'
496
+ }
497
+ }
@@ -18,10 +18,8 @@ import { showError, stopPropagation } from './Helper'
18
18
  import { TippyCustomized } from './TippyCustomized'
19
19
  import { setImageTags } from './Common.service'
20
20
  import Tippy from '@tippyjs/react'
21
- import { Progressing } from './Progressing'
22
21
 
23
22
  export const ImageTagsContainer = ({
24
- // Setting it to zero in case of external pipeline
25
23
  ciPipelineId,
26
24
  artifactId,
27
25
  imageComment,
@@ -49,7 +47,6 @@ export const ImageTagsContainer = ({
49
47
  const [hardDeleteTags, setHardDeleteTags] = useState<ReleaseTag[]>([])
50
48
  const [descriptionValidationMessage, setDescriptionValidationMessage] = useState<string>('')
51
49
  const [textInput, setTextInput] = useState<string>('')
52
- const [loading, setLoading] = useState<boolean>(false)
53
50
 
54
51
 
55
52
  useEffect(() => {
@@ -216,8 +213,7 @@ export const ImageTagsContainer = ({
216
213
  }
217
214
 
218
215
  // set loading state true
219
- setLoading(true)
220
- setImageTags(payload, ciPipelineId ?? 0, artifactId)
216
+ setImageTags(payload, ciPipelineId, artifactId)
221
217
  .then((res) => {
222
218
  const tags = res.result?.imageReleaseTags?.map((tag) => ({
223
219
  id: tag.id,
@@ -253,9 +249,6 @@ export const ImageTagsContainer = ({
253
249
  showError(err)
254
250
  }
255
251
  })
256
- .finally(()=>{
257
- setLoading(false)
258
- })
259
252
  }
260
253
 
261
254
  const renderInfoCard = (): JSX.Element => {
@@ -432,7 +425,6 @@ export const ImageTagsContainer = ({
432
425
  stopPropagation(e)
433
426
  handleCancel()
434
427
  }}
435
- disabled={loading}
436
428
  >
437
429
  Cancel
438
430
  </button>
@@ -444,9 +436,8 @@ export const ImageTagsContainer = ({
444
436
  stopPropagation(e)
445
437
  onClickSave()
446
438
  }}
447
- disabled={loading}
448
439
  >
449
- {loading ? <Progressing /> : 'Save'}
440
+ Save
450
441
  </button>
451
442
  </div>
452
443
  </div>
@@ -226,10 +226,6 @@ export enum FilterStates {
226
226
  ERROR = 2,
227
227
  }
228
228
 
229
- export enum MaterialDataSource {
230
- EXTERNAL = "ext"
231
- }
232
-
233
229
  export interface CDMaterialType {
234
230
  index: number
235
231
  id: string
@@ -256,36 +252,6 @@ export interface CDMaterialType {
256
252
  imageReleaseTags?: ReleaseTag[]
257
253
  artifactStatus?: string
258
254
  filterState: FilterStates
259
- // Not even coming from API but required in CDMaterials for Security which makes its own api call but stores data in CDMaterials
260
- scanToolId?: number
261
- appliedFiltersTimestamp?: string
262
- appliedFilters?: FilterConditionsListType[]
263
- appliedFiltersState?: FilterStates
264
- createdTime?: string
265
- deployed?: boolean
266
- dataSource?: MaterialDataSource
267
- }
268
-
269
- export enum CDMaterialServiceEnum {
270
- ROLLBACK = 'rollback',
271
- CD_MATERIALS = 'cd-materials',
272
- }
273
-
274
- export enum CDMaterialResourceQuery {
275
- PENDING_APPROVAL = 'PENDING_APPROVAL'
276
- }
277
-
278
- export enum CDMaterialFilterQuery {
279
- RESOURCE = 'ELIGIBLE_RESOURCES',
280
- ALL = 'ALL_RESOURCES'
281
- }
282
-
283
- export interface CDMaterialServiceQueryParams {
284
- search?: string
285
- offset?: number
286
- size?: number
287
- resource?: CDMaterialResourceQuery
288
- filter?: CDMaterialFilterQuery
289
255
  }
290
256
 
291
257
  export interface CommonNodeAttr {
@@ -401,23 +367,15 @@ export interface FilterConditionsListType {
401
367
  conditions: FilterConditionsInfo[]
402
368
  }
403
369
 
404
- export interface CDMaterialsApprovalInfo {
370
+ export interface CDMaterialResponseType {
405
371
  approvalUsers: string[]
372
+ materials: any[]
406
373
  userApprovalConfig: UserApprovalConfigType
407
374
  requestedUserId: number
408
- }
409
-
410
- export interface CDMaterialsMetaInfo {
411
375
  tagsEditable: boolean
412
376
  appReleaseTagNames: string[]
413
377
  hideImageTaggingHardDelete: boolean
414
378
  resourceFilters?: FilterConditionsListType[]
415
- totalCount: number
416
- canApproverDeploy: boolean
417
- }
418
-
419
- export interface CDMaterialResponseType extends CDMaterialsMetaInfo, CDMaterialsApprovalInfo {
420
- materials: CDMaterialType[]
421
379
  }
422
380
 
423
381
  export interface InputDetailType {
@@ -39,3 +39,4 @@ export { default as DebouncedSearch } from './DebouncedSearch/DebouncedSearch'
39
39
  export { default as Grid } from './Grid/Grid'
40
40
  export { default as ClipboardButton } from './ClipboardButton/ClipboardButton'
41
41
  export * from './Hooks'
42
+ export { AppStatus } from './AppStatus'