@devtron-labs/devtron-fe-common-lib 0.0.17-beta-3 → 0.0.17-beta-5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { TeamList, ResponseType } from './Types';
1
+ import { TeamList, ResponseType, DeploymentNodeType } from './Types';
2
2
  export declare const getTeamListMin: () => Promise<TeamList>;
3
3
  interface UserRole extends ResponseType {
4
4
  result?: {
@@ -8,4 +8,6 @@ interface UserRole extends ResponseType {
8
8
  }
9
9
  export declare function getUserRole(appName?: string): Promise<UserRole>;
10
10
  export declare function setImageTags(request: any, pipelineId: number, artifactId: number): Promise<ResponseType>;
11
+ export declare const getCDMaterials: (cdMaterialId: any, stageType: DeploymentNodeType, abortSignal: AbortSignal, isApprovalNode?: boolean, imageTag?: string) => Promise<any>;
12
+ export declare function extractImage(image: string): string;
11
13
  export {};
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { DeploymentNodeType, UseSearchString } from './Types';
2
+ import { UseSearchString } from './Types';
3
3
  export declare function showError(serverError: any, showToastOnUnknownError?: boolean, hideAccessError?: boolean): void;
4
4
  interface ConditionalWrapper<T> {
5
5
  condition: boolean;
@@ -42,6 +42,4 @@ export declare function CustomInput({ name, value, error, onChange, onBlur, onFo
42
42
  }): JSX.Element;
43
43
  export declare function handleUTCTime(ts: string, isRelativeTime?: boolean): string;
44
44
  export declare function useSearchString(): UseSearchString;
45
- export declare const getCDMaterials: (cdMaterialId: any, stageType: DeploymentNodeType, abortSignal: AbortSignal, isApprovalNode?: boolean, imageTag?: string) => Promise<any>;
46
- export declare function extractImage(image: string): string;
47
45
  export {};
package/dist/index.js CHANGED
@@ -2162,7 +2162,6 @@ var AppNotDeployed = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAGQCAYA
2162
2162
 
2163
2163
  function GenericEmptyState(_a) {
2164
2164
  var title = _a.title, image = _a.image, subTitle = _a.subTitle, isButtonAvailable = _a.isButtonAvailable, classname = _a.classname, styles = _a.styles, heightToDeduct = _a.heightToDeduct, imageType = _a.imageType, renderButton = _a.renderButton, imageClassName = _a.imageClassName, children = _a.children, SvgImage = _a.SvgImage, noImage = _a.noImage;
2165
- console.log(image);
2166
2165
  return (jsxRuntime.jsxs("div", __assign({ className: "flex column empty-state ".concat(classname ? classname : ''), style: styles, "data-testid": "generic-empty-state" }, (heightToDeduct >= 0 && { style: __assign(__assign({}, styles), { height: "calc(100vh - ".concat(heightToDeduct, "px)") }) }), { children: [!SvgImage ? !noImage && jsxRuntime.jsx("img", { className: imageClassName ? imageClassName : '', src: image || AppNotDeployed, width: imageType === exports.ImageType.Medium ? '200' : '250', height: imageType === exports.ImageType.Medium ? '160' : '200', alt: "empty-state" }) : jsxRuntime.jsx(SvgImage, {}), jsxRuntime.jsx("h4", __assign({ className: "title fw-6 cn-9 mb-8" }, { children: title })), subTitle && jsxRuntime.jsx("p", __assign({ className: "subtitle" }, { children: subTitle })), isButtonAvailable && renderButton(), children] })));
2167
2166
  }
2168
2167
 
@@ -10095,71 +10094,6 @@ function useSearchString() {
10095
10094
  return agg;
10096
10095
  }, {});
10097
10096
  return { queryParams: queryParams, searchParams: searchParams };
10098
- }
10099
- var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalNode, imageTag) {
10100
- var URL = (!imageTag) ? "app/cd-pipeline/".concat(cdMaterialId, "/material?stage=APPROVAL") : "app/cd-pipeline/".concat(cdMaterialId, "/material?stage=APPROVAL&search=").concat(imageTag);
10101
- return get(URL, {
10102
- signal: abortSignal,
10103
- }).then(function (response) {
10104
- var _a;
10105
- var artifacts = (_a = response.result.ci_artifacts) !== null && _a !== void 0 ? _a : [];
10106
- if (!response.result) {
10107
- return {
10108
- materials: [],
10109
- };
10110
- }
10111
- else {
10112
- var materials = artifacts.map(function (material, index) {
10113
- var artifactStatusValue = '';
10114
- return {
10115
- index: index,
10116
- id: material.id,
10117
- deployedTime: material.deployed_time
10118
- ? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
10119
- : 'Not Deployed',
10120
- deployedBy: material.deployedBy,
10121
- wfrId: material.wfrId,
10122
- image: extractImage(material.image),
10123
- showChanges: false,
10124
- vulnerabilities: [],
10125
- buildTime: material.build_time || '',
10126
- showSourceInfo: false,
10127
- deployed: material.deployed || false,
10128
- latest: material.latest || false,
10129
- vulnerabilitiesLoading: true,
10130
- scanned: material.scanned,
10131
- scanEnabled: material.scanEnabled,
10132
- vulnerable: material.vulnerable,
10133
- runningOnParentCd: material.runningOnParentCd,
10134
- artifactStatus: artifactStatusValue,
10135
- userApprovalMetadata: material.userApprovalMetadata,
10136
- triggeredBy: material.triggeredBy,
10137
- isVirtualEnvironment: material.isVirtualEnvironment,
10138
- imageComment: material.imageComment,
10139
- imageReleaseTags: material.imageReleaseTags,
10140
- materialInfo: material.material_info
10141
- ? material.material_info.map(function (mat) {
10142
- return {
10143
- author: mat.author || '',
10144
- message: mat.message || '',
10145
- revision: mat.revision || '',
10146
- tag: mat.tag || '',
10147
- webhookData: mat.webhookData || '',
10148
- url: mat.url || '',
10149
- type: material.ciConfigureSourceType || '',
10150
- };
10151
- })
10152
- : [],
10153
- };
10154
- });
10155
- return {
10156
- materials: materials
10157
- };
10158
- }
10159
- });
10160
- };
10161
- function extractImage(image) {
10162
- return image ? image.split(':').pop() : '';
10163
10097
  }
10164
10098
 
10165
10099
  function Progressing(_a) {
@@ -22610,6 +22544,71 @@ function getUserRole(appName) {
22610
22544
  }
22611
22545
  function setImageTags(request, pipelineId, artifactId) {
22612
22546
  return post("".concat(ROUTES.IMAGE_TAGGING, "/").concat(pipelineId, "/").concat(artifactId), request);
22547
+ }
22548
+ var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalNode, imageTag) {
22549
+ var URL = (!imageTag) ? "app/cd-pipeline/".concat(cdMaterialId, "/material?stage=APPROVAL") : "app/cd-pipeline/".concat(cdMaterialId, "/material?stage=APPROVAL&search=").concat(imageTag);
22550
+ return get(URL, {
22551
+ signal: abortSignal,
22552
+ }).then(function (response) {
22553
+ var _a;
22554
+ var artifacts = (_a = response.result.ci_artifacts) !== null && _a !== void 0 ? _a : [];
22555
+ if (!response.result) {
22556
+ return {
22557
+ materials: [],
22558
+ };
22559
+ }
22560
+ else {
22561
+ var materials = artifacts.map(function (material, index) {
22562
+ var artifactStatusValue = '';
22563
+ return {
22564
+ index: index,
22565
+ id: material.id,
22566
+ deployedTime: material.deployed_time
22567
+ ? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
22568
+ : 'Not Deployed',
22569
+ deployedBy: material.deployedBy,
22570
+ wfrId: material.wfrId,
22571
+ image: extractImage(material.image),
22572
+ showChanges: false,
22573
+ vulnerabilities: [],
22574
+ buildTime: material.build_time || '',
22575
+ showSourceInfo: false,
22576
+ deployed: material.deployed || false,
22577
+ latest: material.latest || false,
22578
+ vulnerabilitiesLoading: true,
22579
+ scanned: material.scanned,
22580
+ scanEnabled: material.scanEnabled,
22581
+ vulnerable: material.vulnerable,
22582
+ runningOnParentCd: material.runningOnParentCd,
22583
+ artifactStatus: artifactStatusValue,
22584
+ userApprovalMetadata: material.userApprovalMetadata,
22585
+ triggeredBy: material.triggeredBy,
22586
+ isVirtualEnvironment: material.isVirtualEnvironment,
22587
+ imageComment: material.imageComment,
22588
+ imageReleaseTags: material.imageReleaseTags,
22589
+ materialInfo: material.material_info
22590
+ ? material.material_info.map(function (mat) {
22591
+ return {
22592
+ author: mat.author || '',
22593
+ message: mat.message || '',
22594
+ revision: mat.revision || '',
22595
+ tag: mat.tag || '',
22596
+ webhookData: mat.webhookData || '',
22597
+ url: mat.url || '',
22598
+ type: material.ciConfigureSourceType || '',
22599
+ };
22600
+ })
22601
+ : [],
22602
+ };
22603
+ });
22604
+ return {
22605
+ materials: materials
22606
+ };
22607
+ }
22608
+ });
22609
+ };
22610
+ function extractImage(image) {
22611
+ return image ? image.split(':').pop() : '';
22613
22612
  }
22614
22613
 
22615
22614
  /*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.17-beta-3",
3
+ "version": "0.0.17-beta-5",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,7 +1,8 @@
1
+ import moment from 'moment';
1
2
  import {get, post} from './Api';
2
3
  import { ROUTES } from './Constants'
3
4
  import { sortCallback } from './Helper';
4
- import { TeamList ,ResponseType } from './Types';
5
+ import { TeamList ,ResponseType, DeploymentNodeType } from './Types';
5
6
 
6
7
  export const getTeamListMin = (): Promise<TeamList> => {
7
8
  // ignore active field
@@ -35,4 +36,76 @@ export function getUserRole(appName?: string): Promise<UserRole> {
35
36
 
36
37
  export function setImageTags(request, pipelineId: number, artifactId: number){
37
38
  return post(`${ROUTES.IMAGE_TAGGING}/${pipelineId}/${artifactId}`,request )
39
+ }
40
+
41
+ export const getCDMaterials = (
42
+ cdMaterialId,
43
+ stageType: DeploymentNodeType,
44
+ abortSignal: AbortSignal,
45
+ isApprovalNode?: boolean,
46
+ imageTag?: string): Promise<any> => {
47
+ const URL = (!imageTag) ? `app/cd-pipeline/${cdMaterialId}/material?stage=APPROVAL` : `app/cd-pipeline/${cdMaterialId}/material?stage=APPROVAL&search=${imageTag}`
48
+
49
+ return get(URL, {
50
+ signal: abortSignal,
51
+ }).then((response) => {
52
+ let artifacts = response.result.ci_artifacts ?? []
53
+ if (!response.result) {
54
+ return {
55
+ materials: [],
56
+ }
57
+ }
58
+ else {
59
+ const materials = artifacts.map((material, index) => {
60
+ let artifactStatusValue = ''
61
+ return {
62
+ index,
63
+ id: material.id,
64
+ deployedTime: material.deployed_time
65
+ ? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
66
+ : 'Not Deployed',
67
+ deployedBy: material.deployedBy,
68
+ wfrId: material.wfrId,
69
+ image: extractImage(material.image),
70
+ showChanges: false,
71
+ vulnerabilities: [],
72
+ buildTime: material.build_time || '',
73
+ showSourceInfo: false,
74
+ deployed: material.deployed || false,
75
+ latest: material.latest || false,
76
+ vulnerabilitiesLoading: true,
77
+ scanned: material.scanned,
78
+ scanEnabled: material.scanEnabled,
79
+ vulnerable: material.vulnerable,
80
+ runningOnParentCd: material.runningOnParentCd,
81
+ artifactStatus: artifactStatusValue,
82
+ userApprovalMetadata: material.userApprovalMetadata,
83
+ triggeredBy: material.triggeredBy,
84
+ isVirtualEnvironment: material.isVirtualEnvironment,
85
+ imageComment: material.imageComment,
86
+ imageReleaseTags: material.imageReleaseTags,
87
+ materialInfo: material.material_info
88
+ ? material.material_info.map((mat) => {
89
+ return {
90
+ author: mat.author || '',
91
+ message: mat.message || '',
92
+ revision: mat.revision || '',
93
+ tag: mat.tag || '',
94
+ webhookData: mat.webhookData || '',
95
+ url: mat.url || '',
96
+ type: material.ciConfigureSourceType || '',
97
+ }
98
+ })
99
+ : [],
100
+ }
101
+ })
102
+ return {
103
+ materials: materials
104
+ }
105
+ }
106
+ })
107
+ }
108
+
109
+ export function extractImage(image: string): string {
110
+ return image ? image.split(':').pop() : ''
38
111
  }
@@ -19,7 +19,6 @@ function GenericEmptyState({
19
19
  SvgImage,
20
20
  noImage
21
21
  }: GenericEmptyStateType): JSX.Element {
22
- console.log(image);
23
22
 
24
23
  return (
25
24
  <div
@@ -6,9 +6,8 @@ import { toastAccessDenied } from './ToastBody'
6
6
  import { ERROR_EMPTY_SCREEN, TOKEN_COOKIE_NAME } from './Constants'
7
7
  import { ReactComponent as FormError } from '../Assets/Icon/ic-warning.svg'
8
8
  import moment from 'moment';
9
- import { DeploymentNodeType, UseSearchString } from './Types'
9
+ import { UseSearchString } from './Types'
10
10
  import { useLocation } from 'react-router-dom'
11
- import { get } from './Api'
12
11
 
13
12
  toast.configure({
14
13
  autoClose: 3000,
@@ -369,74 +368,4 @@ export function useSearchString(): UseSearchString {
369
368
  return { queryParams, searchParams }
370
369
  }
371
370
 
372
- export const getCDMaterials = (
373
- cdMaterialId,
374
- stageType: DeploymentNodeType,
375
- abortSignal: AbortSignal,
376
- isApprovalNode?: boolean,
377
- imageTag?: string): Promise<any> => {
378
- const URL = (!imageTag) ? `app/cd-pipeline/${cdMaterialId}/material?stage=APPROVAL` : `app/cd-pipeline/${cdMaterialId}/material?stage=APPROVAL&search=${imageTag}`
379
-
380
- return get(URL, {
381
- signal: abortSignal,
382
- }).then((response) => {
383
- let artifacts = response.result.ci_artifacts ?? []
384
- if (!response.result) {
385
- return {
386
- materials: [],
387
- }
388
- }
389
- else {
390
- const materials = artifacts.map((material, index) => {
391
- let artifactStatusValue = ''
392
- return {
393
- index,
394
- id: material.id,
395
- deployedTime: material.deployed_time
396
- ? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
397
- : 'Not Deployed',
398
- deployedBy: material.deployedBy,
399
- wfrId: material.wfrId,
400
- image: extractImage(material.image),
401
- showChanges: false,
402
- vulnerabilities: [],
403
- buildTime: material.build_time || '',
404
- showSourceInfo: false,
405
- deployed: material.deployed || false,
406
- latest: material.latest || false,
407
- vulnerabilitiesLoading: true,
408
- scanned: material.scanned,
409
- scanEnabled: material.scanEnabled,
410
- vulnerable: material.vulnerable,
411
- runningOnParentCd: material.runningOnParentCd,
412
- artifactStatus: artifactStatusValue,
413
- userApprovalMetadata: material.userApprovalMetadata,
414
- triggeredBy: material.triggeredBy,
415
- isVirtualEnvironment: material.isVirtualEnvironment,
416
- imageComment: material.imageComment,
417
- imageReleaseTags: material.imageReleaseTags,
418
- materialInfo: material.material_info
419
- ? material.material_info.map((mat) => {
420
- return {
421
- author: mat.author || '',
422
- message: mat.message || '',
423
- revision: mat.revision || '',
424
- tag: mat.tag || '',
425
- webhookData: mat.webhookData || '',
426
- url: mat.url || '',
427
- type: material.ciConfigureSourceType || '',
428
- }
429
- })
430
- : [],
431
- }
432
- })
433
- return {
434
- materials: materials
435
- }
436
- }
437
- })
438
- }
439
371
 
440
- export function extractImage(image: string): string {
441
- return image ? image.split(':').pop() : ''
442
- }