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

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
  }
@@ -22596,12 +22601,17 @@ var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalN
22596
22601
  materialInfo: material.material_info
22597
22602
  ? material.material_info.map(function (mat) {
22598
22603
  return {
22604
+ modifiedTime: mat.modifiedTime ? moment(mat.modifiedTime).format("ddd, DD MMM YYYY, hh:mm A") : '',
22605
+ commitLink: createGitCommitUrl(mat.url, mat.revision),
22599
22606
  author: mat.author || '',
22600
22607
  message: mat.message || '',
22601
22608
  revision: mat.revision || '',
22602
22609
  tag: mat.tag || '',
22603
22610
  webhookData: mat.webhookData || '',
22604
22611
  url: mat.url || '',
22612
+ branch: (material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
22613
+ ? material.ciConfigureSourceValue
22614
+ : mat.branch) || '',
22605
22615
  type: material.ciConfigureSourceType || '',
22606
22616
  };
22607
22617
  })
@@ -22616,6 +22626,30 @@ var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalN
22616
22626
  };
22617
22627
  function extractImage(image) {
22618
22628
  return image ? image.split(':').pop() : '';
22629
+ }
22630
+ function createGitCommitUrl(url, revision) {
22631
+ if (!url || !revision) {
22632
+ return "NA";
22633
+ }
22634
+ if (url.indexOf("gitlab") > 0 || url.indexOf("github") > 0 || url.indexOf("azure") > 0) {
22635
+ var urlpart = url.split("@");
22636
+ if (urlpart.length > 1) {
22637
+ return "https://" + urlpart[1].split(".git")[0] + "/commit/" + revision;
22638
+ }
22639
+ if (urlpart.length == 1) {
22640
+ return urlpart[0].split(".git")[0] + "/commit/" + revision;
22641
+ }
22642
+ }
22643
+ if (url.indexOf("bitbucket") > 0) {
22644
+ var urlpart = url.split("@");
22645
+ if (urlpart.length > 1) {
22646
+ return "https://" + urlpart[1].split(".git")[0] + "/commits/" + revision;
22647
+ }
22648
+ if (urlpart.length == 1) {
22649
+ return urlpart[0].split(".git")[0] + "/commits/" + revision;
22650
+ }
22651
+ }
22652
+ return "NA";
22619
22653
  }
22620
22654
 
22621
22655
  /*
@@ -23322,6 +23356,7 @@ exports.ScanVulnerabilitiesTable = ScanVulnerabilitiesTable;
23322
23356
  exports.ServerError = ServerError;
23323
23357
  exports.ServerErrors = ServerErrors;
23324
23358
  exports.SingleSelectOption = SingleSelectOption;
23359
+ exports.SourceTypeMap = SourceTypeMap;
23325
23360
  exports.StyledRadioGroup = RadioGroup;
23326
23361
  exports.TOAST_ACCESS_DENIED = TOAST_ACCESS_DENIED;
23327
23362
  exports.TOKEN_COOKIE_NAME = TOKEN_COOKIE_NAME;
@@ -23337,6 +23372,7 @@ exports.TriggerTypeMap = TriggerTypeMap;
23337
23372
  exports.URLS = URLS;
23338
23373
  exports.VisibleModal = VisibleModal;
23339
23374
  exports.VisibleModal2 = VisibleModal2;
23375
+ exports.createGitCommitUrl = createGitCommitUrl;
23340
23376
  exports.extractImage = extractImage;
23341
23377
  exports.get = get;
23342
23378
  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-12",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -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
  }
@@ -95,12 +101,18 @@ export const getCDMaterials = (
95
101
  materialInfo: material.material_info
96
102
  ? material.material_info.map((mat) => {
97
103
  return {
104
+ modifiedTime: mat.modifiedTime ? moment(mat.modifiedTime).format("ddd, DD MMM YYYY, hh:mm A") : '',
105
+ commitLink: createGitCommitUrl(mat.url, mat.revision),
98
106
  author: mat.author || '',
99
107
  message: mat.message || '',
100
108
  revision: mat.revision || '',
101
109
  tag: mat.tag || '',
102
110
  webhookData: mat.webhookData || '',
103
111
  url: mat.url || '',
112
+ branch:
113
+ (material.ciConfigureSourceType === SourceTypeMap.WEBHOOK
114
+ ? material.ciConfigureSourceValue
115
+ : mat.branch) || '',
104
116
  type: material.ciConfigureSourceType || '',
105
117
  }
106
118
  })
@@ -116,4 +128,29 @@ export const getCDMaterials = (
116
128
 
117
129
  export function extractImage(image: string): string {
118
130
  return image ? image.split(':').pop() : ''
119
- }
131
+ }
132
+
133
+ export function createGitCommitUrl(url: string, revision: string): string {
134
+ if (!url || !revision) {
135
+ return "NA"
136
+ }
137
+ if (url.indexOf("gitlab") > 0 || url.indexOf("github") > 0 || url.indexOf("azure") > 0) {
138
+ let urlpart = url.split("@")
139
+ if (urlpart.length > 1) {
140
+ return "https://" + urlpart[1].split(".git")[0] + "/commit/" + revision
141
+ }
142
+ if (urlpart.length == 1) {
143
+ return urlpart[0].split(".git")[0] + "/commit/" + revision
144
+ }
145
+ }
146
+ if (url.indexOf("bitbucket") > 0) {
147
+ let urlpart = url.split("@")
148
+ if (urlpart.length > 1) {
149
+ return "https://" + urlpart[1].split(".git")[0] + "/commits/" + revision
150
+ }
151
+ if (urlpart.length == 1) {
152
+ return urlpart[0].split(".git")[0] + "/commits/" + revision
153
+ }
154
+ }
155
+ return "NA"
156
+ }