@devtron-labs/devtron-fe-common-lib 0.0.10-beta-12 → 0.0.10-beta-14

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, }: ImageTaggingContainerType) => JSX.Element;
3
+ export declare const ImageTagsContainer: ({ ciPipelineId, artifactId, imageComment, imageReleaseTags, appReleaseTagNames, setAppReleaseTagNames, tagsEditable, setTagsEditable, toggleCardMode, hideHardDelete, }: ImageTaggingContainerType) => JSX.Element;
4
4
  export declare const ImageTagButton: ({ text, isSoftDeleted, isEditing, onSoftDeleteClick, onHardDeleteClick, tagId, softDeleteTags, isSuperAdmin, duplicateTag, }: ImageButtonType) => JSX.Element;
@@ -328,6 +328,7 @@ export interface ImageTaggingContainerType {
328
328
  setAppReleaseTagNames?: (appReleaseTags: string[]) => void;
329
329
  setTagsEditable?: (tagsEditable: boolean) => void;
330
330
  toggleCardMode?: (id: number) => void;
331
+ hideHardDelete?: boolean;
331
332
  }
332
333
  export interface ImageButtonType {
333
334
  text: string;
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;
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;
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];
@@ -22944,7 +22944,8 @@ var ImageTagsContainer = function (_a) {
22944
22944
  var setInputValue = function (e) {
22945
22945
  setTextInput(e.target.value);
22946
22946
  };
22947
- var enterTagCreate = function () {
22947
+ var enterTagCreate = function (e) {
22948
+ stopPropagation(e);
22948
22949
  if (textInput.trim()) {
22949
22950
  handleTagCreate(textInput.trim());
22950
22951
  }
@@ -22986,17 +22987,6 @@ var ImageTagsContainer = function (_a) {
22986
22987
  var ImageTagButton = function (_a) {
22987
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;
22988
22989
  var IconComponent = isSoftDeleted ? SvgIcArrowCounterClockwise : SvgIcMinus;
22989
- var _b = __read(React.useState(false), 2), isHovered = _b[0], setIsHovered = _b[1];
22990
- var handleMouseEnter = function () {
22991
- if (isEditing) {
22992
- setIsHovered(true);
22993
- }
22994
- };
22995
- var handleMouseLeave = function () {
22996
- if (isEditing) {
22997
- setIsHovered(false);
22998
- }
22999
- };
23000
22990
  var isInSoftDeleteTags = isSoftDeleted && softDeleteTags.some(function (tag) { return tag.tagName === text; });
23001
22991
  var canTagBeHardDelete = tagId === 0 || isSuperAdmin;
23002
22992
  var tabColor = function () {
@@ -23010,9 +23000,7 @@ var ImageTagButton = function (_a) {
23010
23000
  return 'cn-9';
23011
23001
  }
23012
23002
  };
23013
- return (jsxRuntime.jsx("div", __assign({ className: "br-4 en-2 bw-1 dc__w-fit-content dc__word-wrap-anywhere mr-8 bcn-0 flex mb-4 ".concat(tabColor()), onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }, { children: jsxRuntime.jsxs("div", __assign({ className: "flex pt-2 pl-8 pr-8 pb-2" }, { children: [duplicateTag ? (jsxRuntime.jsx(SvgIcErrorExclamation, { className: "icon-dim-12 mr-4" })) : (isHovered &&
23014
- isEditing &&
23015
- (isInSoftDeleteTags || (tagId !== 0 && !isSoftDeleted)) && (jsxRuntime.jsx(Tippy, __assign({ className: "default-tt", arrow: true, placement: "top", content: isInSoftDeleteTags ? 'Restore tag' : 'Soft delete tag' }, { children: jsxRuntime.jsx(IconComponent, { className: "icon-dim-12 mr-4 cursor ".concat(isSoftDeleted ? 'scn-6' : 'fcn-6'), "data-testid": "".concat(text, "-tag-soft-delete"), onClick: onSoftDeleteClick }) })))), text, isHovered && isEditing && canTagBeHardDelete && (jsxRuntime.jsx(Tippy, __assign({ className: "default-tt", arrow: true, placement: "top", content: "Remove tag" }, { children: jsxRuntime.jsx(SvgIcCross, { className: "icon-dim-12 ml-4 fcn-6 cn-5 cursor", "data-testid": "".concat(text, "-tag-hard-delete"), onClick: onHardDeleteClick }) })))] })) })));
23003
+ return (jsxRuntime.jsxs("div", __assign({ className: "br-4 en-2 bw-1 mr-8 bcn-0 mb-4 pt-2 pr-8 pb-2 pl-8 tag-class flex ".concat(isEditing ? 'icon-hover' : '', " ").concat(tabColor()) }, { children: [duplicateTag ? (jsxRuntime.jsx(SvgIcErrorExclamation, { className: "icon-dim-12 mr-4" })) : (jsxRuntime.jsx(Tippy, __assign({ className: "default-tt", arrow: true, placement: "top", content: isInSoftDeleteTags ? 'Restore tag' : 'Soft delete tag' }, { children: jsxRuntime.jsx("div", __assign({ className: "action-icon mr-4 lh-16 pt-3 ".concat(isInSoftDeleteTags || (tagId !== 0 && !isSoftDeleted) ? 'show-icon' : '') }, { children: jsxRuntime.jsx(IconComponent, { className: "icon-dim-12 cursor".concat(isSoftDeleted ? 'scn-6' : 'fcn-6', " "), "data-testid": "".concat(text, "-tag-soft-delete"), onClick: onSoftDeleteClick }) })) }))), text, jsxRuntime.jsx(Tippy, __assign({ className: "default-tt", arrow: true, placement: "top", content: "Remove tag" }, { children: jsxRuntime.jsx("div", __assign({ className: "action-icon ml-4 lh-16 pt-3 ".concat(canTagBeHardDelete ? 'show-icon' : '') }, { children: jsxRuntime.jsx(SvgIcCross, { className: "icon-dim-12 fcn-6 cursor", "data-testid": "".concat(text, "-tag-hard-delete"), onClick: onHardDeleteClick }) })) }))] })));
23016
23004
  };
23017
23005
  var AddImageButton = function (_a) {
23018
23006
  var handleEditClick = _a.handleEditClick;
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-12",
3
+ "version": "0.0.10-beta-14",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -29,6 +29,7 @@ export const ImageTagsContainer = ({
29
29
  tagsEditable,
30
30
  setTagsEditable,
31
31
  toggleCardMode,
32
+ hideHardDelete,
32
33
  }: ImageTaggingContainerType) => {
33
34
  const [initialTags, setInitialTags] = useState<ReleaseTag[]>(imageReleaseTags ? imageReleaseTags : [])
34
35
  const [initialDescription, setInitialDescription] = useState(imageComment ? imageComment.comment : '')
@@ -59,11 +60,11 @@ export const ImageTagsContainer = ({
59
60
  }, [appReleaseTagNames])
60
61
 
61
62
  useEffect(() => {
62
- if(saveData){
63
+ if (saveData) {
63
64
  handleSave()
64
65
  setSaveData(false)
65
66
  }
66
- },[saveData])
67
+ }, [saveData])
67
68
 
68
69
  async function initialise() {
69
70
  try {
@@ -207,8 +208,8 @@ export const ImageTagsContainer = ({
207
208
  }
208
209
 
209
210
  const handleSave = async () => {
210
- if(tagErrorMessage) return
211
-
211
+ if (tagErrorMessage) return
212
+
212
213
  const payload = {
213
214
  createTags: createTags,
214
215
  softDeleteTags: softDeleteTags,
@@ -330,14 +331,15 @@ export const ImageTagsContainer = ({
330
331
  setTextInput(e.target.value)
331
332
  }
332
333
 
333
- const enterTagCreate = () => {
334
+ const enterTagCreate = (e) => {
335
+ stopPropagation(e)
334
336
  if (textInput.trim()) {
335
337
  handleTagCreate(textInput.trim())
336
338
  }
337
339
  }
338
340
 
339
341
  const onClickSave = () => {
340
- if(textInput.trim()){
342
+ if (textInput.trim()) {
341
343
  handleTagCreate(textInput)
342
344
  }
343
345
  setSaveData(true)
@@ -515,19 +517,6 @@ export const ImageTagButton = ({
515
517
  duplicateTag,
516
518
  }: ImageButtonType) => {
517
519
  const IconComponent = isSoftDeleted ? Redo : Minus
518
-
519
- const [isHovered, setIsHovered] = useState(false)
520
- const handleMouseEnter = () => {
521
- if (isEditing) {
522
- setIsHovered(true)
523
- }
524
- }
525
- const handleMouseLeave = () => {
526
- if (isEditing) {
527
- setIsHovered(false)
528
- }
529
- }
530
-
531
520
  const isInSoftDeleteTags = isSoftDeleted && softDeleteTags.some((tag) => tag.tagName === text)
532
521
  const canTagBeHardDelete = tagId === 0 || isSuperAdmin
533
522
 
@@ -543,42 +532,42 @@ export const ImageTagButton = ({
543
532
 
544
533
  return (
545
534
  <div
546
- className={`br-4 en-2 bw-1 dc__w-fit-content dc__word-wrap-anywhere mr-8 bcn-0 flex mb-4 ${tabColor()}`}
547
- onMouseEnter={handleMouseEnter}
548
- onMouseLeave={handleMouseLeave}
535
+ className={`br-4 en-2 bw-1 mr-8 bcn-0 mb-4 pt-2 pr-8 pb-2 pl-8 tag-class flex ${
536
+ isEditing ? 'icon-hover' : ''
537
+ } ${tabColor()}`}
549
538
  >
550
- <div className="flex pt-2 pl-8 pr-8 pb-2">
551
- {duplicateTag ? (
552
- <Warning className="icon-dim-12 mr-4" />
553
- ) : (
554
- isHovered &&
555
- isEditing &&
556
- (isInSoftDeleteTags || (tagId !== 0 && !isSoftDeleted)) && (
557
- <Tippy
558
- className="default-tt"
559
- arrow={true}
560
- placement="top"
561
- content={isInSoftDeleteTags ? 'Restore tag' : 'Soft delete tag'}
562
- >
563
- <IconComponent
564
- className={`icon-dim-12 mr-4 cursor ${isSoftDeleted ? 'scn-6' : 'fcn-6'}`}
565
- data-testid={`${text}-tag-soft-delete`}
566
- onClick={onSoftDeleteClick}
567
- />
568
- </Tippy>
569
- )
570
- )}
571
- {text}
572
- {isHovered && isEditing && canTagBeHardDelete && (
573
- <Tippy className="default-tt" arrow={true} placement="top" content="Remove tag">
574
- <Close
575
- className="icon-dim-12 ml-4 fcn-6 cn-5 cursor"
576
- data-testid={`${text}-tag-hard-delete`}
577
- onClick={onHardDeleteClick}
539
+ {duplicateTag ? (
540
+ <Warning className="icon-dim-12 mr-4" />
541
+ ) : (
542
+ <Tippy
543
+ className="default-tt"
544
+ arrow={true}
545
+ placement="top"
546
+ content={isInSoftDeleteTags ? 'Restore tag' : 'Soft delete tag'}
547
+ >
548
+ <div
549
+ className={`action-icon mr-4 lh-16 pt-3 ${
550
+ isInSoftDeleteTags || (tagId !== 0 && !isSoftDeleted) ? 'show-icon' : ''
551
+ }`}
552
+ >
553
+ <IconComponent
554
+ className={`icon-dim-12 cursor${isSoftDeleted ? 'scn-6' : 'fcn-6'} `}
555
+ data-testid={`${text}-tag-soft-delete`}
556
+ onClick={onSoftDeleteClick}
578
557
  />
579
- </Tippy>
580
- )}
581
- </div>
558
+ </div>
559
+ </Tippy>
560
+ )}
561
+ {text}
562
+ <Tippy className="default-tt" arrow={true} placement="top" content="Remove tag">
563
+ <div className={`action-icon ml-4 lh-16 pt-3 ${canTagBeHardDelete ? 'show-icon' : ''}`}>
564
+ <Close
565
+ className="icon-dim-12 fcn-6 cursor"
566
+ data-testid={`${text}-tag-hard-delete`}
567
+ onClick={onHardDeleteClick}
568
+ />
569
+ </div>
570
+ </Tippy>
582
571
  </div>
583
572
  )
584
573
  }
@@ -361,6 +361,7 @@ export interface ImageTaggingContainerType {
361
361
  setAppReleaseTagNames?: (appReleaseTags: string[]) => void
362
362
  setTagsEditable?: (tagsEditable: boolean) => void
363
363
  toggleCardMode?: (id: number) => void
364
+ hideHardDelete?: boolean
364
365
  }
365
366
 
366
367
  export interface ImageButtonType {