@devtron-labs/devtron-fe-common-lib 0.0.10-beta-14 → 0.0.10-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.
@@ -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, }: 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, matId, 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,8 +323,11 @@ export interface ImageTaggingContainerType {
323
323
  artifactId?: number;
324
324
  imageComment?: ImageComment;
325
325
  imageReleaseTags?: ReleaseTag[];
326
+ matId?: number;
327
+ updateCurrentAppMaterial?: (matId: number, releaseTags?: ReleaseTag[], imageComment?: ImageComment) => void;
326
328
  appReleaseTagNames?: string[];
327
329
  tagsEditable?: boolean;
330
+ forceReInit?: boolean;
328
331
  setAppReleaseTagNames?: (appReleaseTags: string[]) => void;
329
332
  setTagsEditable?: (tagsEditable: boolean) => void;
330
333
  toggleCardMode?: (id: number) => void;
@@ -340,5 +343,6 @@ export interface ImageButtonType {
340
343
  softDeleteTags: any;
341
344
  isSuperAdmin: any;
342
345
  duplicateTag?: boolean;
346
+ hideHardDelete?: boolean;
343
347
  }
344
348
  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;
22699
+ var ciPipelineId = _a.ciPipelineId, artifactId = _a.artifactId, imageComment = _a.imageComment, imageReleaseTags = _a.imageReleaseTags, matId = _a.matId, 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];
@@ -22751,11 +22751,12 @@ var ImageTagsContainer = function (_a) {
22751
22751
  });
22752
22752
  }
22753
22753
  var reInitState = function () {
22754
- if (isEditing === false) {
22754
+ if (forceReInit || !isEditing) {
22755
22755
  setInitialTags(imageReleaseTags ? imageReleaseTags : []);
22756
22756
  setInitialDescription(imageComment ? imageComment.comment : '');
22757
22757
  setNewDescription(imageComment ? imageComment.comment : '');
22758
22758
  setDisplayedTags(imageReleaseTags ? imageReleaseTags : []);
22759
+ setIsEditing(false);
22759
22760
  }
22760
22761
  };
22761
22762
  var handleEditClick = function () {
@@ -22884,7 +22885,7 @@ var ImageTagsContainer = function (_a) {
22884
22885
  // set loading state true
22885
22886
  setImageTags(payload, ciPipelineId, artifactId)
22886
22887
  .then(function (res) {
22887
- var _a, _b, _c, _d, _e, _f, _g, _h;
22888
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
22888
22889
  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 ({
22889
22890
  id: tag.id,
22890
22891
  tagName: tag.tagName,
@@ -22908,6 +22909,8 @@ var ImageTagsContainer = function (_a) {
22908
22909
  handleEditClick();
22909
22910
  setShowTagsWarning(false);
22910
22911
  setTagErrorMessage('');
22912
+ if (updateCurrentAppMaterial)
22913
+ updateCurrentAppMaterial(matId, tags, (_j = res.result) === null || _j === void 0 ? void 0 : _j.imageComment);
22911
22914
  })
22912
22915
  .catch(function (err) {
22913
22916
  var _a, _b, _c, _d, _e, _f, _g;
@@ -22967,7 +22970,7 @@ var ImageTagsContainer = function (_a) {
22967
22970
  }, onHardDeleteClick: function (e) {
22968
22971
  stopPropagation(e);
22969
22972
  handleTagHardDelete(index);
22970
- }, 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) {
22973
+ }, 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) {
22971
22974
  stopPropagation(e);
22972
22975
  handleCancel();
22973
22976
  } }, { 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) {
@@ -22979,16 +22982,16 @@ var ImageTagsContainer = function (_a) {
22979
22982
  }, onHardDeleteClick: function (e) {
22980
22983
  stopPropagation(e);
22981
22984
  handleTagHardDelete(index);
22982
- }, 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) {
22985
+ }, 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) {
22983
22986
  stopPropagation(e);
22984
22987
  handleEditClick();
22985
22988
  } })) }))] }))) })));
22986
22989
  };
22987
22990
  var ImageTagButton = function (_a) {
22988
- 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;
22991
+ 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;
22989
22992
  var IconComponent = isSoftDeleted ? SvgIcArrowCounterClockwise : SvgIcMinus;
22990
22993
  var isInSoftDeleteTags = isSoftDeleted && softDeleteTags.some(function (tag) { return tag.tagName === text; });
22991
- var canTagBeHardDelete = tagId === 0 || isSuperAdmin;
22994
+ var canTagBeHardDelete = tagId === 0 || (isSuperAdmin && !hideHardDelete);
22992
22995
  var tabColor = function () {
22993
22996
  if (duplicateTag) {
22994
22997
  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-14",
3
+ "version": "0.0.10-beta-16",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -24,12 +24,15 @@ export const ImageTagsContainer = ({
24
24
  artifactId,
25
25
  imageComment,
26
26
  imageReleaseTags,
27
+ matId,
28
+ updateCurrentAppMaterial,
27
29
  appReleaseTagNames,
28
30
  setAppReleaseTagNames,
29
31
  tagsEditable,
30
32
  setTagsEditable,
31
33
  toggleCardMode,
32
34
  hideHardDelete,
35
+ forceReInit,
33
36
  }: ImageTaggingContainerType) => {
34
37
  const [initialTags, setInitialTags] = useState<ReleaseTag[]>(imageReleaseTags ? imageReleaseTags : [])
35
38
  const [initialDescription, setInitialDescription] = useState(imageComment ? imageComment.comment : '')
@@ -78,11 +81,12 @@ export const ImageTagsContainer = ({
78
81
  }
79
82
 
80
83
  const reInitState = () => {
81
- if (isEditing === false) {
84
+ if (forceReInit || !isEditing) {
82
85
  setInitialTags(imageReleaseTags ? imageReleaseTags : [])
83
86
  setInitialDescription(imageComment ? imageComment.comment : '')
84
87
  setNewDescription(imageComment ? imageComment.comment : '')
85
88
  setDisplayedTags(imageReleaseTags ? imageReleaseTags : [])
89
+ setIsEditing(false)
86
90
  }
87
91
  }
88
92
 
@@ -247,6 +251,7 @@ export const ImageTagsContainer = ({
247
251
  handleEditClick()
248
252
  setShowTagsWarning(false)
249
253
  setTagErrorMessage('')
254
+ if(updateCurrentAppMaterial)updateCurrentAppMaterial(matId,tags,res.result?.imageComment)
250
255
  })
251
256
  .catch((err) => {
252
257
  // Fix toast message
@@ -328,6 +333,7 @@ export const ImageTagsContainer = ({
328
333
  }
329
334
 
330
335
  const setInputValue = (e) => {
336
+
331
337
  setTextInput(e.target.value)
332
338
  }
333
339
 
@@ -404,6 +410,7 @@ export const ImageTagsContainer = ({
404
410
  softDeleteTags={softDeleteTags}
405
411
  isSuperAdmin={isSuperAdmin}
406
412
  duplicateTag={tag?.duplicateTag}
413
+ hideHardDelete={hideHardDelete}
407
414
  />
408
415
  ))}
409
416
  </div>
@@ -482,6 +489,7 @@ export const ImageTagsContainer = ({
482
489
  softDeleteTags={softDeleteTags}
483
490
  isSuperAdmin={isSuperAdmin}
484
491
  duplicateTag={tag?.duplicateTag}
492
+ hideHardDelete={hideHardDelete}
485
493
  />
486
494
  ))}
487
495
  </div>
@@ -515,10 +523,11 @@ export const ImageTagButton = ({
515
523
  softDeleteTags,
516
524
  isSuperAdmin,
517
525
  duplicateTag,
526
+ hideHardDelete,
518
527
  }: ImageButtonType) => {
519
528
  const IconComponent = isSoftDeleted ? Redo : Minus
520
529
  const isInSoftDeleteTags = isSoftDeleted && softDeleteTags.some((tag) => tag.tagName === text)
521
- const canTagBeHardDelete = tagId === 0 || isSuperAdmin
530
+ const canTagBeHardDelete = tagId === 0 || (isSuperAdmin && !hideHardDelete)
522
531
 
523
532
  const tabColor = () => {
524
533
  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,8 +356,11 @@ export interface ImageTaggingContainerType {
356
356
  artifactId?: number
357
357
  imageComment?: ImageComment
358
358
  imageReleaseTags?: ReleaseTag[]
359
+ matId?: number
360
+ updateCurrentAppMaterial? : (matId:number, releaseTags?:ReleaseTag[], imageComment?:ImageComment) => void
359
361
  appReleaseTagNames?: string[]
360
362
  tagsEditable?: boolean
363
+ forceReInit?: boolean
361
364
  setAppReleaseTagNames?: (appReleaseTags: string[]) => void
362
365
  setTagsEditable?: (tagsEditable: boolean) => void
363
366
  toggleCardMode?: (id: number) => void
@@ -374,6 +377,7 @@ export interface ImageButtonType {
374
377
  softDeleteTags: any
375
378
  isSuperAdmin: any
376
379
  duplicateTag?: boolean
380
+ hideHardDelete?: boolean
377
381
  }
378
382
 
379
383