@devtron-labs/devtron-fe-common-lib 0.0.17-beta-1 → 0.0.17-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.
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { UseSearchString } from './Types';
2
+ import { DeploymentNodeType, 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,4 +42,6 @@ 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;
45
47
  export {};
package/dist/index.js CHANGED
@@ -10095,6 +10095,71 @@ function useSearchString() {
10095
10095
  return agg;
10096
10096
  }, {});
10097
10097
  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() : '';
10098
10163
  }
10099
10164
 
10100
10165
  function Progressing(_a) {
@@ -23266,8 +23331,10 @@ exports.TriggerTypeMap = TriggerTypeMap;
23266
23331
  exports.URLS = URLS;
23267
23332
  exports.VisibleModal = VisibleModal;
23268
23333
  exports.VisibleModal2 = VisibleModal2;
23334
+ exports.extractImage = extractImage;
23269
23335
  exports.get = get;
23270
23336
  exports.getAlphabetIcon = getAlphabetIcon;
23337
+ exports.getCDMaterials = getCDMaterials;
23271
23338
  exports.getCookie = getCookie;
23272
23339
  exports.getEmptyArrayOfLength = getEmptyArrayOfLength;
23273
23340
  exports.getLoginInfo = getLoginInfo;
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-1",
3
+ "version": "0.0.17-beta-3",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -6,8 +6,9 @@ import { toastAccessDenied } from './ToastBody'
6
6
  import { ERROR_EMPTY_SCREEN, TOKEN_COOKIE_NAME } from './Constants'
7
7
  import { ReactComponent as FormError } from '../Assets/Icon/ic-warning.svg'
8
8
  import moment from 'moment';
9
- import { UseSearchString } from './Types'
9
+ import { DeploymentNodeType, UseSearchString } from './Types'
10
10
  import { useLocation } from 'react-router-dom'
11
+ import { get } from './Api'
11
12
 
12
13
  toast.configure({
13
14
  autoClose: 3000,
@@ -367,3 +368,75 @@ export function useSearchString(): UseSearchString {
367
368
 
368
369
  return { queryParams, searchParams }
369
370
  }
371
+
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
+
440
+ export function extractImage(image: string): string {
441
+ return image ? image.split(':').pop() : ''
442
+ }