@devtron-labs/devtron-fe-common-lib 0.0.17-beta-10 → 0.0.17-beta-16

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.
@@ -6,8 +6,14 @@ interface UserRole extends ResponseType {
6
6
  superAdmin: boolean;
7
7
  };
8
8
  }
9
+ export declare const SourceTypeMap: {
10
+ BranchFixed: string;
11
+ WEBHOOK: string;
12
+ BranchRegex: string;
13
+ };
9
14
  export declare function getUserRole(appName?: string): Promise<UserRole>;
10
15
  export declare function setImageTags(request: any, pipelineId: number, artifactId: number): Promise<ResponseType>;
11
16
  export declare const getCDMaterials: (cdMaterialId: any, stageType: DeploymentNodeType, abortSignal: AbortSignal, isApprovalNode?: boolean, imageTag?: string) => Promise<any>;
12
17
  export declare function extractImage(image: string): string;
18
+ export declare function createGitCommitUrl(url: string, revision: string): string;
13
19
  export {};
package/dist/index.js CHANGED
@@ -22545,6 +22545,11 @@ var stageMap = {
22545
22545
  POSTCD: 'POST',
22546
22546
  APPROVAL: 'APPROVAL',
22547
22547
  };
22548
+ var SourceTypeMap = {
22549
+ BranchFixed: 'SOURCE_TYPE_BRANCH_FIXED',
22550
+ WEBHOOK: 'WEBHOOK',
22551
+ BranchRegex: 'SOURCE_TYPE_BRANCH_REGEX',
22552
+ };
22548
22553
  function getUserRole(appName) {
22549
22554
  return get("".concat(ROUTES.USER_CHECK_ROLE).concat(appName ? "?appName=".concat(appName) : ''));
22550
22555
  }
@@ -22578,6 +22583,7 @@ var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalN
22578
22583
  showChanges: false,
22579
22584
  vulnerabilities: [],
22580
22585
  buildTime: material.build_time || '',
22586
+ tab: CDModalTab.Changes,
22581
22587
  showSourceInfo: false,
22582
22588
  deployed: material.deployed || false,
22583
22589
  latest: material.latest || false,
@@ -22596,12 +22602,17 @@ var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalN
22596
22602
  materialInfo: material.material_info
22597
22603
  ? material.material_info.map(function (mat) {
22598
22604
  return {
22605
+ modifiedTime: mat.modifiedTime ? moment(mat.modifiedTime).format("ddd, DD MMM YYYY, hh:mm A") : '',
22606
+ commitLink: createGitCommitUrl(mat.url, mat.revision),
22599
22607
  author: mat.author || '',
22600
22608
  message: mat.message || '',
22601
22609
  revision: mat.revision || '',
22602
22610
  tag: mat.tag || '',
22603
22611
  webhookData: mat.webhookData || '',
22604
22612
  url: mat.url || '',
22613
+ branch: (material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
22614
+ ? material.ciConfigureSourceValue
22615
+ : mat.branch) || '',
22605
22616
  type: material.ciConfigureSourceType || '',
22606
22617
  };
22607
22618
  })
@@ -22616,6 +22627,30 @@ var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalN
22616
22627
  };
22617
22628
  function extractImage(image) {
22618
22629
  return image ? image.split(':').pop() : '';
22630
+ }
22631
+ function createGitCommitUrl(url, revision) {
22632
+ if (!url || !revision) {
22633
+ return "NA";
22634
+ }
22635
+ if (url.indexOf("gitlab") > 0 || url.indexOf("github") > 0 || url.indexOf("azure") > 0) {
22636
+ var urlpart = url.split("@");
22637
+ if (urlpart.length > 1) {
22638
+ return "https://" + urlpart[1].split(".git")[0] + "/commit/" + revision;
22639
+ }
22640
+ if (urlpart.length == 1) {
22641
+ return urlpart[0].split(".git")[0] + "/commit/" + revision;
22642
+ }
22643
+ }
22644
+ if (url.indexOf("bitbucket") > 0) {
22645
+ var urlpart = url.split("@");
22646
+ if (urlpart.length > 1) {
22647
+ return "https://" + urlpart[1].split(".git")[0] + "/commits/" + revision;
22648
+ }
22649
+ if (urlpart.length == 1) {
22650
+ return urlpart[0].split(".git")[0] + "/commits/" + revision;
22651
+ }
22652
+ }
22653
+ return "NA";
22619
22654
  }
22620
22655
 
22621
22656
  /*
@@ -23322,6 +23357,7 @@ exports.ScanVulnerabilitiesTable = ScanVulnerabilitiesTable;
23322
23357
  exports.ServerError = ServerError;
23323
23358
  exports.ServerErrors = ServerErrors;
23324
23359
  exports.SingleSelectOption = SingleSelectOption;
23360
+ exports.SourceTypeMap = SourceTypeMap;
23325
23361
  exports.StyledRadioGroup = RadioGroup;
23326
23362
  exports.TOAST_ACCESS_DENIED = TOAST_ACCESS_DENIED;
23327
23363
  exports.TOKEN_COOKIE_NAME = TOKEN_COOKIE_NAME;
@@ -23337,6 +23373,7 @@ exports.TriggerTypeMap = TriggerTypeMap;
23337
23373
  exports.URLS = URLS;
23338
23374
  exports.VisibleModal = VisibleModal;
23339
23375
  exports.VisibleModal2 = VisibleModal2;
23376
+ exports.createGitCommitUrl = createGitCommitUrl;
23340
23377
  exports.extractImage = extractImage;
23341
23378
  exports.get = get;
23342
23379
  exports.getAlphabetIcon = getAlphabetIcon;
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-10",
3
+ "version": "0.0.17-beta-16",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -2,7 +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 { TeamList ,ResponseType, DeploymentNodeType } from './Types';
5
+ import { TeamList ,ResponseType, DeploymentNodeType, CDModalTab } from './Types';
6
6
 
7
7
  export const getTeamListMin = (): Promise<TeamList> => {
8
8
  // ignore active field
@@ -37,6 +37,12 @@ let stageMap = {
37
37
  APPROVAL: 'APPROVAL',
38
38
  }
39
39
 
40
+ export const SourceTypeMap = {
41
+ BranchFixed: 'SOURCE_TYPE_BRANCH_FIXED',
42
+ WEBHOOK: 'WEBHOOK',
43
+ BranchRegex: 'SOURCE_TYPE_BRANCH_REGEX',
44
+ }
45
+
40
46
  export function getUserRole(appName?: string): Promise<UserRole> {
41
47
  return get(`${ROUTES.USER_CHECK_ROLE}${appName ? `?appName=${appName}` : ''}`)
42
48
  }
@@ -77,6 +83,7 @@ export const getCDMaterials = (
77
83
  showChanges: false,
78
84
  vulnerabilities: [],
79
85
  buildTime: material.build_time || '',
86
+ tab: CDModalTab.Changes,
80
87
  showSourceInfo: false,
81
88
  deployed: material.deployed || false,
82
89
  latest: material.latest || false,
@@ -95,12 +102,18 @@ export const getCDMaterials = (
95
102
  materialInfo: material.material_info
96
103
  ? material.material_info.map((mat) => {
97
104
  return {
105
+ modifiedTime: mat.modifiedTime ? moment(mat.modifiedTime).format("ddd, DD MMM YYYY, hh:mm A") : '',
106
+ commitLink: createGitCommitUrl(mat.url, mat.revision),
98
107
  author: mat.author || '',
99
108
  message: mat.message || '',
100
109
  revision: mat.revision || '',
101
110
  tag: mat.tag || '',
102
111
  webhookData: mat.webhookData || '',
103
112
  url: mat.url || '',
113
+ branch:
114
+ (material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
115
+ ? material.ciConfigureSourceValue
116
+ : mat.branch) || '',
104
117
  type: material.ciConfigureSourceType || '',
105
118
  }
106
119
  })
@@ -116,4 +129,29 @@ export const getCDMaterials = (
116
129
 
117
130
  export function extractImage(image: string): string {
118
131
  return image ? image.split(':').pop() : ''
119
- }
132
+ }
133
+
134
+ export function createGitCommitUrl(url: string, revision: string): string {
135
+ if (!url || !revision) {
136
+ return "NA"
137
+ }
138
+ if (url.indexOf("gitlab") > 0 || url.indexOf("github") > 0 || url.indexOf("azure") > 0) {
139
+ let urlpart = url.split("@")
140
+ if (urlpart.length > 1) {
141
+ return "https://" + urlpart[1].split(".git")[0] + "/commit/" + revision
142
+ }
143
+ if (urlpart.length == 1) {
144
+ return urlpart[0].split(".git")[0] + "/commit/" + revision
145
+ }
146
+ }
147
+ if (url.indexOf("bitbucket") > 0) {
148
+ let urlpart = url.split("@")
149
+ if (urlpart.length > 1) {
150
+ return "https://" + urlpart[1].split(".git")[0] + "/commits/" + revision
151
+ }
152
+ if (urlpart.length == 1) {
153
+ return urlpart[0].split(".git")[0] + "/commits/" + revision
154
+ }
155
+ }
156
+ return "NA"
157
+ }