@devtron-labs/devtron-fe-common-lib 0.0.10-beta-15 → 0.0.10-beta-17

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
1
  /// <reference types="react" />
2
2
  import { ImageButtonType, ImageTaggingContainerType } from './Types';
3
- export declare const ImageTagsContainer: ({ ciPipelineId, artifactId, imageComment, imageReleaseTags, appReleaseTagNames, setAppReleaseTagNames, tagsEditable, setTagsEditable, toggleCardMode, hideHardDelete, forceReInit }: ImageTaggingContainerType) => JSX.Element;
4
- export declare const ImageTagButton: ({ text, isSoftDeleted, isEditing, onSoftDeleteClick, onHardDeleteClick, tagId, softDeleteTags, isSuperAdmin, duplicateTag, }: ImageButtonType) => JSX.Element;
3
+ export declare const ImageTagsContainer: ({ ciPipelineId, artifactId, imageComment, imageReleaseTags, updateCurrentAppMaterial, appReleaseTagNames, setAppReleaseTagNames, tagsEditable, setTagsEditable, toggleCardMode, hideHardDelete, forceReInit, }: ImageTaggingContainerType) => JSX.Element;
4
+ export declare const ImageTagButton: ({ text, isSoftDeleted, isEditing, onSoftDeleteClick, onHardDeleteClick, tagId, softDeleteTags, isSuperAdmin, duplicateTag, hideHardDelete, }: ImageButtonType) => JSX.Element;
@@ -1,4 +1,4 @@
1
- import { ReactNode, CSSProperties } from 'react';
1
+ import React, { ReactNode, CSSProperties } from 'react';
2
2
  import { Placement } from 'tippy.js';
3
3
  export interface ResponseType {
4
4
  code: number;
@@ -323,6 +323,7 @@ export interface ImageTaggingContainerType {
323
323
  artifactId?: number;
324
324
  imageComment?: ImageComment;
325
325
  imageReleaseTags?: ReleaseTag[];
326
+ updateCurrentAppMaterial?: (matId: number, releaseTags?: ReleaseTag[], imageComment?: ImageComment) => void;
326
327
  appReleaseTagNames?: string[];
327
328
  tagsEditable?: boolean;
328
329
  forceReInit?: boolean;
@@ -341,5 +342,6 @@ export interface ImageButtonType {
341
342
  softDeleteTags: any;
342
343
  isSuperAdmin: any;
343
344
  duplicateTag?: boolean;
345
+ hideHardDelete?: boolean;
344
346
  }
345
347
  export {};
package/dist/index.js CHANGED
@@ -22696,7 +22696,7 @@ var SvgIcEnter = function SvgIcEnter(props) {
22696
22696
  };
22697
22697
 
22698
22698
  var ImageTagsContainer = function (_a) {
22699
- var ciPipelineId = _a.ciPipelineId, artifactId = _a.artifactId, imageComment = _a.imageComment, imageReleaseTags = _a.imageReleaseTags, appReleaseTagNames = _a.appReleaseTagNames, setAppReleaseTagNames = _a.setAppReleaseTagNames, tagsEditable = _a.tagsEditable, setTagsEditable = _a.setTagsEditable, toggleCardMode = _a.toggleCardMode; _a.hideHardDelete; var forceReInit = _a.forceReInit;
22699
+ 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;
22700
22700
  var _b = __read(React.useState(imageReleaseTags ? imageReleaseTags : []), 2), initialTags = _b[0], setInitialTags = _b[1];
22701
22701
  var _c = __read(React.useState(imageComment ? imageComment.comment : ''), 2), initialDescription = _c[0], setInitialDescription = _c[1];
22702
22702
  var _d = __read(React.useState(appReleaseTagNames ? appReleaseTagNames : []), 2), existingTags = _d[0], setExistingTags = _d[1];
@@ -22782,8 +22782,7 @@ var ImageTagsContainer = function (_a) {
22782
22782
  setShowTagsWarning(false);
22783
22783
  setTagErrorMessage('');
22784
22784
  };
22785
- var handleTagCreate = function (newValue) {
22786
- var lowercaseValue = newValue.toLowerCase().trim();
22785
+ var validateTag = function (lowercaseValue) {
22787
22786
  if (lowercaseValue.length == 0 ||
22788
22787
  lowercaseValue.length >= 128 ||
22789
22788
  lowercaseValue[0] == '.' ||
@@ -22802,6 +22801,10 @@ var ImageTagsContainer = function (_a) {
22802
22801
  setTagErrorMessage('This tag is already being used in this application');
22803
22802
  return;
22804
22803
  }
22804
+ };
22805
+ var handleTagCreate = function (newValue) {
22806
+ var lowercaseValue = newValue.toLowerCase().trim();
22807
+ validateTag(lowercaseValue);
22805
22808
  var newTag = {
22806
22809
  id: 0,
22807
22810
  tagName: lowercaseValue,
@@ -22885,7 +22888,7 @@ var ImageTagsContainer = function (_a) {
22885
22888
  // set loading state true
22886
22889
  setImageTags(payload, ciPipelineId, artifactId)
22887
22890
  .then(function (res) {
22888
- var _a, _b, _c, _d, _e, _f, _g, _h;
22891
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
22889
22892
  var tags = (_b = (_a = res.result) === null || _a === void 0 ? void 0 : _a.imageReleaseTags) === null || _b === void 0 ? void 0 : _b.map(function (tag) { return ({
22890
22893
  id: tag.id,
22891
22894
  tagName: tag.tagName,
@@ -22909,6 +22912,8 @@ var ImageTagsContainer = function (_a) {
22909
22912
  handleEditClick();
22910
22913
  setShowTagsWarning(false);
22911
22914
  setTagErrorMessage('');
22915
+ if (updateCurrentAppMaterial)
22916
+ updateCurrentAppMaterial(artifactId, tags, (_j = res.result) === null || _j === void 0 ? void 0 : _j.imageComment);
22912
22917
  })
22913
22918
  .catch(function (err) {
22914
22919
  var _a, _b, _c, _d, _e, _f, _g;
@@ -22943,6 +22948,7 @@ var ImageTagsContainer = function (_a) {
22943
22948
  }
22944
22949
  };
22945
22950
  var setInputValue = function (e) {
22951
+ e.target.value && validateTag(e.target.value);
22946
22952
  setTextInput(e.target.value);
22947
22953
  };
22948
22954
  var enterTagCreate = function (e) {
@@ -22968,7 +22974,7 @@ var ImageTagsContainer = function (_a) {
22968
22974
  }, onHardDeleteClick: function (e) {
22969
22975
  stopPropagation(e);
22970
22976
  handleTagHardDelete(index);
22971
- }, tagId: tag.id, softDeleteTags: softDeleteTags, isSuperAdmin: isSuperAdmin, duplicateTag: tag === null || tag === void 0 ? void 0 : tag.duplicateTag }, tag.id)); }) })), showTagsWarning && (jsxRuntime.jsxs("div", __assign({ className: "cn-7 mb-8 flex left" }, { children: [jsxRuntime.jsx(SvgIcInfoFilled, { className: "form__icon--info icon-dim-16 mr-2" }), "Tags cannot be edited/removed later"] }))), jsxRuntime.jsx("div", __assign({ className: "cn-7 mt-12" }, { children: "Comment" })), jsxRuntime.jsx("div", __assign({ className: "flex left flex-wrap dc__gap-8 w-100 mt-6 mb-12", "data-testid": "add-image-comment-text-area" }, { children: jsxRuntime.jsx("textarea", { value: newDescription, onChange: handleDescriptionChange, className: "flex left flex-wrap dc__gap-8 dc__description-textarea", style: { height: '90px !important' } }) })), descriptionValidationMessage !== '' && (jsxRuntime.jsxs("div", __assign({ className: "flex left" }, { children: [jsxRuntime.jsx(SvgIcWarning, { className: "form__icon form__icon--error" }), jsxRuntime.jsx("div", __assign({ className: "form__error" }, { children: descriptionValidationMessage }))] }))), jsxRuntime.jsxs("div", __assign({ className: "w-100 flex right mt-12" }, { children: [jsxRuntime.jsx("button", __assign({ className: "cta flex cancel h-32 lh-32-imp", type: "button", onClick: function (e) {
22977
+ }, tagId: tag.id, softDeleteTags: softDeleteTags, isSuperAdmin: isSuperAdmin, duplicateTag: tag === null || tag === void 0 ? void 0 : tag.duplicateTag, hideHardDelete: hideHardDelete }, tag.id)); }) })), showTagsWarning && (jsxRuntime.jsxs("div", __assign({ className: "cn-7 mb-8 flex left" }, { children: [jsxRuntime.jsx(SvgIcInfoFilled, { className: "form__icon--info icon-dim-16 mr-2" }), "Tags cannot be edited/removed later"] }))), jsxRuntime.jsx("div", __assign({ className: "cn-7 mt-12" }, { children: "Comment" })), jsxRuntime.jsx("div", __assign({ className: "flex left flex-wrap dc__gap-8 w-100 mt-6 mb-12", "data-testid": "add-image-comment-text-area" }, { children: jsxRuntime.jsx("textarea", { value: newDescription, onChange: handleDescriptionChange, className: "flex left flex-wrap dc__gap-8 dc__description-textarea", style: { height: '90px !important' } }) })), descriptionValidationMessage !== '' && (jsxRuntime.jsxs("div", __assign({ className: "flex left" }, { children: [jsxRuntime.jsx(SvgIcWarning, { className: "form__icon form__icon--error" }), jsxRuntime.jsx("div", __assign({ className: "form__error" }, { children: descriptionValidationMessage }))] }))), jsxRuntime.jsxs("div", __assign({ className: "w-100 flex right mt-12" }, { children: [jsxRuntime.jsx("button", __assign({ className: "cta flex cancel h-32 lh-32-imp", type: "button", onClick: function (e) {
22972
22978
  stopPropagation(e);
22973
22979
  handleCancel();
22974
22980
  } }, { children: "Cancel" })), jsxRuntime.jsx("button", __assign({ className: "cta flex h-32 lh-32-imp ml-12", "data-testid": "save-tags-button", type: "button", onClick: function (e) {
@@ -22980,16 +22986,16 @@ var ImageTagsContainer = function (_a) {
22980
22986
  }, onHardDeleteClick: function (e) {
22981
22987
  stopPropagation(e);
22982
22988
  handleTagHardDelete(index);
22983
- }, tagId: tag.id, softDeleteTags: softDeleteTags, isSuperAdmin: isSuperAdmin, duplicateTag: tag === null || tag === void 0 ? void 0 : tag.duplicateTag }, tag === null || tag === void 0 ? void 0 : tag.id)); }) }))] }) })), jsxRuntime.jsx("div", __assign({ className: "mt-8 mr-6 icon-dim-16" }, { children: tagsEditable && (jsxRuntime.jsx(SvgIcPencil, { className: "icon-dim-16 image-tags-container-edit__icon cursor", "data-testid": "edit-tags-icon", onClick: function (e) {
22989
+ }, tagId: tag.id, softDeleteTags: softDeleteTags, isSuperAdmin: isSuperAdmin, duplicateTag: tag === null || tag === void 0 ? void 0 : tag.duplicateTag, hideHardDelete: hideHardDelete }, tag === null || tag === void 0 ? void 0 : tag.id)); }) }))] }) })), jsxRuntime.jsx("div", __assign({ className: "mt-8 mr-6 icon-dim-16" }, { children: tagsEditable && (jsxRuntime.jsx(SvgIcPencil, { className: "icon-dim-16 image-tags-container-edit__icon cursor", "data-testid": "edit-tags-icon", onClick: function (e) {
22984
22990
  stopPropagation(e);
22985
22991
  handleEditClick();
22986
22992
  } })) }))] }))) })));
22987
22993
  };
22988
22994
  var ImageTagButton = function (_a) {
22989
- var text = _a.text, isSoftDeleted = _a.isSoftDeleted, isEditing = _a.isEditing, onSoftDeleteClick = _a.onSoftDeleteClick, onHardDeleteClick = _a.onHardDeleteClick, tagId = _a.tagId, softDeleteTags = _a.softDeleteTags, isSuperAdmin = _a.isSuperAdmin, duplicateTag = _a.duplicateTag;
22995
+ var text = _a.text, isSoftDeleted = _a.isSoftDeleted, isEditing = _a.isEditing, onSoftDeleteClick = _a.onSoftDeleteClick, onHardDeleteClick = _a.onHardDeleteClick, tagId = _a.tagId, softDeleteTags = _a.softDeleteTags, isSuperAdmin = _a.isSuperAdmin, duplicateTag = _a.duplicateTag, hideHardDelete = _a.hideHardDelete;
22990
22996
  var IconComponent = isSoftDeleted ? SvgIcArrowCounterClockwise : SvgIcMinus;
22991
22997
  var isInSoftDeleteTags = isSoftDeleted && softDeleteTags.some(function (tag) { return tag.tagName === text; });
22992
- var canTagBeHardDelete = tagId === 0 || isSuperAdmin;
22998
+ var canTagBeHardDelete = tagId === 0 || (isSuperAdmin && !hideHardDelete);
22993
22999
  var tabColor = function () {
22994
23000
  if (duplicateTag) {
22995
23001
  return 'cr-5 bcr-1 er-2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.10-beta-15",
3
+ "version": "0.0.10-beta-17",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -24,13 +24,14 @@ export const ImageTagsContainer = ({
24
24
  artifactId,
25
25
  imageComment,
26
26
  imageReleaseTags,
27
+ updateCurrentAppMaterial,
27
28
  appReleaseTagNames,
28
29
  setAppReleaseTagNames,
29
30
  tagsEditable,
30
31
  setTagsEditable,
31
32
  toggleCardMode,
32
33
  hideHardDelete,
33
- forceReInit
34
+ forceReInit,
34
35
  }: ImageTaggingContainerType) => {
35
36
  const [initialTags, setInitialTags] = useState<ReleaseTag[]>(imageReleaseTags ? imageReleaseTags : [])
36
37
  const [initialDescription, setInitialDescription] = useState(imageComment ? imageComment.comment : '')
@@ -114,8 +115,7 @@ export const ImageTagsContainer = ({
114
115
  setTagErrorMessage('')
115
116
  }
116
117
 
117
- const handleTagCreate = (newValue) => {
118
- const lowercaseValue = newValue.toLowerCase().trim()
118
+ const validateTag = (lowercaseValue) => {
119
119
  if (
120
120
  lowercaseValue.length == 0 ||
121
121
  lowercaseValue.length >= 128 ||
@@ -135,6 +135,11 @@ export const ImageTagsContainer = ({
135
135
  setTagErrorMessage('This tag is already being used in this application')
136
136
  return
137
137
  }
138
+ }
139
+
140
+ const handleTagCreate = (newValue) => {
141
+ const lowercaseValue = newValue.toLowerCase().trim()
142
+ validateTag(lowercaseValue)
138
143
  const newTag: ReleaseTag = {
139
144
  id: 0,
140
145
  tagName: lowercaseValue,
@@ -249,6 +254,7 @@ export const ImageTagsContainer = ({
249
254
  handleEditClick()
250
255
  setShowTagsWarning(false)
251
256
  setTagErrorMessage('')
257
+ if(updateCurrentAppMaterial)updateCurrentAppMaterial(artifactId,tags,res.result?.imageComment)
252
258
  })
253
259
  .catch((err) => {
254
260
  // Fix toast message
@@ -330,6 +336,7 @@ export const ImageTagsContainer = ({
330
336
  }
331
337
 
332
338
  const setInputValue = (e) => {
339
+ e.target.value && validateTag(e.target.value)
333
340
  setTextInput(e.target.value)
334
341
  }
335
342
 
@@ -406,6 +413,7 @@ export const ImageTagsContainer = ({
406
413
  softDeleteTags={softDeleteTags}
407
414
  isSuperAdmin={isSuperAdmin}
408
415
  duplicateTag={tag?.duplicateTag}
416
+ hideHardDelete={hideHardDelete}
409
417
  />
410
418
  ))}
411
419
  </div>
@@ -484,6 +492,7 @@ export const ImageTagsContainer = ({
484
492
  softDeleteTags={softDeleteTags}
485
493
  isSuperAdmin={isSuperAdmin}
486
494
  duplicateTag={tag?.duplicateTag}
495
+ hideHardDelete={hideHardDelete}
487
496
  />
488
497
  ))}
489
498
  </div>
@@ -517,10 +526,11 @@ export const ImageTagButton = ({
517
526
  softDeleteTags,
518
527
  isSuperAdmin,
519
528
  duplicateTag,
529
+ hideHardDelete,
520
530
  }: ImageButtonType) => {
521
531
  const IconComponent = isSoftDeleted ? Redo : Minus
522
532
  const isInSoftDeleteTags = isSoftDeleted && softDeleteTags.some((tag) => tag.tagName === text)
523
- const canTagBeHardDelete = tagId === 0 || isSuperAdmin
533
+ const canTagBeHardDelete = tagId === 0 || (isSuperAdmin && !hideHardDelete)
524
534
 
525
535
  const tabColor = () => {
526
536
  if (duplicateTag) {
@@ -1,4 +1,4 @@
1
- import { ReactNode, CSSProperties } from 'react'
1
+ import React, { ReactNode, CSSProperties } from 'react'
2
2
  import { Placement } from 'tippy.js'
3
3
  export interface ResponseType {
4
4
  code: number
@@ -356,6 +356,7 @@ export interface ImageTaggingContainerType {
356
356
  artifactId?: number
357
357
  imageComment?: ImageComment
358
358
  imageReleaseTags?: ReleaseTag[]
359
+ updateCurrentAppMaterial? : (matId:number, releaseTags?:ReleaseTag[], imageComment?:ImageComment) => void
359
360
  appReleaseTagNames?: string[]
360
361
  tagsEditable?: boolean
361
362
  forceReInit?: boolean
@@ -375,6 +376,7 @@ export interface ImageButtonType {
375
376
  softDeleteTags: any
376
377
  isSuperAdmin: any
377
378
  duplicateTag?: boolean
379
+ hideHardDelete?: boolean
378
380
  }
379
381
 
380
382