@devtron-labs/devtron-fe-common-lib 0.0.29 → 0.0.30-beta1

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.
@@ -24,6 +24,7 @@ export interface ImageTaggingContainerType {
24
24
  setTagsEditable?: (tagsEditable: boolean) => void;
25
25
  toggleCardMode?: (id: number) => void;
26
26
  hideHardDelete?: boolean;
27
+ isSuperAdmin?: boolean;
27
28
  }
28
29
  export interface ImageButtonType {
29
30
  text: string;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { ImageButtonType, ImageTaggingContainerType } from './ImageTags.Types';
3
- export declare const ImageTagsContainer: ({ ciPipelineId, artifactId, imageComment, imageReleaseTags, updateCurrentAppMaterial, appReleaseTagNames, setAppReleaseTagNames, tagsEditable, setTagsEditable, toggleCardMode, hideHardDelete, forceReInit, }: ImageTaggingContainerType) => JSX.Element;
3
+ export declare const ImageTagsContainer: ({ ciPipelineId, artifactId, imageComment, imageReleaseTags, updateCurrentAppMaterial, appReleaseTagNames, setAppReleaseTagNames, tagsEditable, setTagsEditable, toggleCardMode, hideHardDelete, forceReInit, isSuperAdmin }: ImageTaggingContainerType) => JSX.Element;
4
4
  export declare const ImageTagButton: ({ text, isSoftDeleted, isEditing, onSoftDeleteClick, onHardDeleteClick, tagId, softDeleteTags, isSuperAdmin, duplicateTag, hideHardDelete, }: ImageButtonType) => JSX.Element;
@@ -192,6 +192,11 @@ export interface UserApprovalMetadataType {
192
192
  approvedUsersData: ApprovalUserDataType[];
193
193
  requestedUserData: ApprovalUserDataType;
194
194
  }
195
+ export declare enum FilterStates {
196
+ BLOCKED = 0,
197
+ ALLOWED = 1,
198
+ ERROR = 2
199
+ }
195
200
  export interface CDMaterialType {
196
201
  index: number;
197
202
  id: string;
@@ -217,6 +222,7 @@ export interface CDMaterialType {
217
222
  imageComment?: ImageComment;
218
223
  imageReleaseTags?: ReleaseTag[];
219
224
  artifactStatus?: string;
225
+ filterState: FilterStates;
220
226
  }
221
227
  export interface CommonNodeAttr {
222
228
  connectingCiPipelineId?: number;
package/dist/index.js CHANGED
@@ -424,6 +424,12 @@ exports.DeploymentNodeType = void 0;
424
424
  DeploymentNodeType["POSTCD"] = "POSTCD";
425
425
  DeploymentNodeType["APPROVAL"] = "APPROVAL";
426
426
  })(exports.DeploymentNodeType || (exports.DeploymentNodeType = {}));
427
+ exports.FilterStates = void 0;
428
+ (function (FilterStates) {
429
+ FilterStates[FilterStates["BLOCKED"] = 0] = "BLOCKED";
430
+ FilterStates[FilterStates["ALLOWED"] = 1] = "ALLOWED";
431
+ FilterStates[FilterStates["ERROR"] = 2] = "ERROR";
432
+ })(exports.FilterStates || (exports.FilterStates = {}));
427
433
  exports.DeploymentAppTypes = void 0;
428
434
  (function (DeploymentAppTypes) {
429
435
  DeploymentAppTypes["HELM"] = "helm";
@@ -10065,7 +10071,7 @@ function CustomInput(_a) {
10065
10071
  return (jsxRuntime.jsxs("div", __assign({ className: "flex column left top" }, { children: [jsxRuntime.jsx("label", __assign({ className: "form__label ".concat(labelClassName) }, { children: label })), jsxRuntime.jsx("input", { "data-testid": dataTestid, type: type, name: name, autoComplete: "off", className: "form__input", onChange: function (e) {
10066
10072
  e.persist();
10067
10073
  onChange(e);
10068
- }, onBlur: onBlur, onFocus: onFocus, placeholder: placeholder, value: value, disabled: disabled, tabIndex: tabIndex }), handleError(error).map(function (err) { return (jsxRuntime.jsxs("div", __assign({ className: "form__error" }, { children: [jsxRuntime.jsx(SvgIcWarning, { className: "form__icon form__icon--error" }), err] }))); })] })));
10074
+ }, onBlur: onBlur, onFocus: onFocus, placeholder: placeholder, value: value, disabled: disabled, tabIndex: tabIndex }), handleError(error).map(function (err) { return (jsxRuntime.jsxs("div", __assign({ className: "form__error" }, { children: [jsxRuntime.jsx(SvgIcWarning, { className: "form__icon form__icon--error" }), err] }), err)); })] })));
10069
10075
  }
10070
10076
  function handleUTCTime(ts, isRelativeTime) {
10071
10077
  if (isRelativeTime === void 0) { isRelativeTime = false; }
@@ -22567,6 +22573,7 @@ function getUserRole(appName) {
22567
22573
  function setImageTags(request, pipelineId, artifactId) {
22568
22574
  return post("".concat(ROUTES.IMAGE_TAGGING, "/").concat(pipelineId, "/").concat(artifactId), request);
22569
22575
  }
22576
+ // TODO: Add enum for filterState as well
22570
22577
  var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalNode, imageTag) {
22571
22578
  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);
22572
22579
  return get(URL, {
@@ -22581,7 +22588,9 @@ var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalN
22581
22588
  }
22582
22589
  else {
22583
22590
  var materials = artifacts.map(function (material, index) {
22591
+ var _a;
22584
22592
  var artifactStatusValue = '';
22593
+ var filterState = (_a = material.filterState) !== null && _a !== void 0 ? _a : exports.FilterStates.ALLOWED;
22585
22594
  return {
22586
22595
  index: index,
22587
22596
  id: material.id,
@@ -22601,7 +22610,7 @@ var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalN
22601
22610
  vulnerabilitiesLoading: true,
22602
22611
  scanned: material.scanned,
22603
22612
  scanEnabled: material.scanEnabled,
22604
- isSelected: !material.vulnerable && index === 0,
22613
+ isSelected: !material.vulnerable && filterState === exports.FilterStates.ALLOWED && index === 0,
22605
22614
  vulnerable: material.vulnerable,
22606
22615
  runningOnParentCd: material.runningOnParentCd,
22607
22616
  artifactStatus: artifactStatusValue,
@@ -22628,6 +22637,7 @@ var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalN
22628
22637
  };
22629
22638
  })
22630
22639
  : [],
22640
+ filterState: filterState,
22631
22641
  };
22632
22642
  });
22633
22643
  return {
@@ -23000,7 +23010,7 @@ var SvgIcEnter = function SvgIcEnter(props) {
23000
23010
  };
23001
23011
 
23002
23012
  var ImageTagsContainer = function (_a) {
23003
- 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;
23013
+ 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;
23004
23014
  var _b = __read(React.useState(imageReleaseTags ? imageReleaseTags : []), 2), initialTags = _b[0], setInitialTags = _b[1];
23005
23015
  var _c = __read(React.useState(imageComment ? imageComment.comment : ''), 2), initialDescription = _c[0], setInitialDescription = _c[1];
23006
23016
  var _d = __read(React.useState(appReleaseTagNames ? appReleaseTagNames : []), 2), existingTags = _d[0], setExistingTags = _d[1];
@@ -23012,41 +23022,14 @@ var ImageTagsContainer = function (_a) {
23012
23022
  var _k = __read(React.useState([]), 2), createTags = _k[0], setCreateTags = _k[1];
23013
23023
  var _l = __read(React.useState([]), 2), softDeleteTags = _l[0], setSoftDeleteTags = _l[1];
23014
23024
  var _m = __read(React.useState([]), 2), hardDeleteTags = _m[0], setHardDeleteTags = _m[1];
23015
- var _o = __read(React.useState(false), 2), isSuperAdmin = _o[0], setSuperAdmin = _o[1];
23016
- var _p = __read(React.useState(''), 2), descriptionValidationMessage = _p[0], setDescriptionValidationMessage = _p[1];
23017
- var _q = __read(React.useState(''), 2), textInput = _q[0], setTextInput = _q[1];
23018
- React.useEffect(function () {
23019
- initialise();
23020
- }, []);
23025
+ var _o = __read(React.useState(''), 2), descriptionValidationMessage = _o[0], setDescriptionValidationMessage = _o[1];
23026
+ var _p = __read(React.useState(''), 2), textInput = _p[0], setTextInput = _p[1];
23021
23027
  React.useEffect(function () {
23022
23028
  reInitState();
23023
23029
  }, [imageReleaseTags, imageComment, tagsEditable]);
23024
23030
  React.useEffect(function () {
23025
23031
  setExistingTags(appReleaseTagNames ? appReleaseTagNames : []);
23026
23032
  }, [appReleaseTagNames]);
23027
- function initialise() {
23028
- var _a, _b;
23029
- return __awaiter(this, void 0, void 0, function () {
23030
- var userRole, superAdmin, err_1;
23031
- return __generator(this, function (_c) {
23032
- switch (_c.label) {
23033
- case 0:
23034
- _c.trys.push([0, 2, , 3]);
23035
- return [4 /*yield*/, getUserRole()];
23036
- case 1:
23037
- userRole = _c.sent();
23038
- superAdmin = (_b = (_a = userRole === null || userRole === void 0 ? void 0 : userRole.result) === null || _a === void 0 ? void 0 : _a.roles) === null || _b === void 0 ? void 0 : _b.includes('role:super-admin___');
23039
- setSuperAdmin(superAdmin);
23040
- return [3 /*break*/, 3];
23041
- case 2:
23042
- err_1 = _c.sent();
23043
- showError(err_1);
23044
- return [3 /*break*/, 3];
23045
- case 3: return [2 /*return*/];
23046
- }
23047
- });
23048
- });
23049
- }
23050
23033
  var reInitState = function () {
23051
23034
  if (forceReInit || !isEditing) {
23052
23035
  setInitialTags(imageReleaseTags ? imageReleaseTags : []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.29",
3
+ "version": "0.0.30-beta1",
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, CDModalTab } from './Types';
5
+ import { TeamList ,ResponseType, DeploymentNodeType, CDModalTab, FilterStates } from './Types';
6
6
 
7
7
  export const getTeamListMin = (): Promise<TeamList> => {
8
8
  // ignore active field
@@ -51,6 +51,7 @@ export function setImageTags(request, pipelineId: number, artifactId: number){
51
51
  return post(`${ROUTES.IMAGE_TAGGING}/${pipelineId}/${artifactId}`,request )
52
52
  }
53
53
 
54
+ // TODO: Add enum for filterState as well
54
55
  export const getCDMaterials = (
55
56
  cdMaterialId,
56
57
  stageType: DeploymentNodeType,
@@ -71,6 +72,8 @@ export const getCDMaterials = (
71
72
  else {
72
73
  const materials = artifacts.map((material, index) => {
73
74
  let artifactStatusValue = ''
75
+ const filterState = material.filterState ?? FilterStates.ALLOWED
76
+
74
77
  return {
75
78
  index,
76
79
  id: material.id,
@@ -90,7 +93,7 @@ export const getCDMaterials = (
90
93
  vulnerabilitiesLoading: true,
91
94
  scanned: material.scanned,
92
95
  scanEnabled: material.scanEnabled,
93
- isSelected: !material.vulnerable && index === 0,
96
+ isSelected: !material.vulnerable && filterState === FilterStates.ALLOWED && index === 0,
94
97
  vulnerable: material.vulnerable,
95
98
  runningOnParentCd: material.runningOnParentCd,
96
99
  artifactStatus: artifactStatusValue,
@@ -118,6 +121,7 @@ export const getCDMaterials = (
118
121
  }
119
122
  })
120
123
  : [],
124
+ filterState,
121
125
  }
122
126
  })
123
127
  return {
@@ -326,7 +326,7 @@ export function CustomInput({
326
326
  tabIndex={tabIndex}
327
327
  />
328
328
  {handleError(error).map((err) => (
329
- <div className="form__error">
329
+ <div className="form__error" key={err}>
330
330
  <FormError className="form__icon form__icon--error" />
331
331
  {err}
332
332
  </div>
@@ -27,6 +27,7 @@ export interface ImageTaggingContainerType {
27
27
  setTagsEditable?: (tagsEditable: boolean) => void
28
28
  toggleCardMode?: (id: number) => void
29
29
  hideHardDelete?: boolean
30
+ isSuperAdmin?: boolean
30
31
  }
31
32
 
32
33
  export interface ImageButtonType {
@@ -32,6 +32,7 @@ export const ImageTagsContainer = ({
32
32
  toggleCardMode,
33
33
  hideHardDelete,
34
34
  forceReInit,
35
+ isSuperAdmin
35
36
  }: ImageTaggingContainerType) => {
36
37
  const [initialTags, setInitialTags] = useState<ReleaseTag[]>(imageReleaseTags ? imageReleaseTags : [])
37
38
  const [initialDescription, setInitialDescription] = useState(imageComment ? imageComment.comment : '')
@@ -44,13 +45,9 @@ export const ImageTagsContainer = ({
44
45
  const [createTags, setCreateTags] = useState<ReleaseTag[]>([])
45
46
  const [softDeleteTags, setSoftDeleteTags] = useState<ReleaseTag[]>([])
46
47
  const [hardDeleteTags, setHardDeleteTags] = useState<ReleaseTag[]>([])
47
- const [isSuperAdmin, setSuperAdmin] = useState<boolean>(false)
48
48
  const [descriptionValidationMessage, setDescriptionValidationMessage] = useState<string>('')
49
49
  const [textInput, setTextInput] = useState<string>('')
50
50
 
51
- useEffect(() => {
52
- initialise()
53
- }, [])
54
51
 
55
52
  useEffect(() => {
56
53
  reInitState()
@@ -60,16 +57,6 @@ export const ImageTagsContainer = ({
60
57
  setExistingTags(appReleaseTagNames ? appReleaseTagNames : [])
61
58
  }, [appReleaseTagNames])
62
59
 
63
- async function initialise() {
64
- try {
65
- const userRole = await getUserRole()
66
-
67
- const superAdmin = userRole?.result?.roles?.includes('role:super-admin___')
68
- setSuperAdmin(superAdmin)
69
- } catch (err) {
70
- showError(err)
71
- }
72
- }
73
60
 
74
61
  const reInitState = () => {
75
62
  if (forceReInit || !isEditing) {
@@ -215,6 +215,11 @@ export interface UserApprovalMetadataType {
215
215
  requestedUserData: ApprovalUserDataType
216
216
  }
217
217
 
218
+ export enum FilterStates {
219
+ BLOCKED = 0,
220
+ ALLOWED = 1,
221
+ ERROR = 2
222
+ }
218
223
 
219
224
  export interface CDMaterialType {
220
225
  index: number
@@ -241,6 +246,7 @@ export interface CDMaterialType {
241
246
  imageComment?: ImageComment
242
247
  imageReleaseTags?: ReleaseTag[]
243
248
  artifactStatus?: string
249
+ filterState: FilterStates;
244
250
  }
245
251
 
246
252
  export interface CommonNodeAttr {