@devtron-labs/devtron-fe-common-lib 0.0.31 → 0.0.32-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.
- package/dist/Common/CustomTagSelector/ResizableTagTextArea.d.ts +1 -1
- package/dist/Common/CustomTagSelector/Types.d.ts +1 -0
- package/dist/Common/ImageTags.Types.d.ts +1 -0
- package/dist/Common/ImageTags.d.ts +1 -1
- package/dist/index.js +16 -37
- package/package.json +1 -1
- package/src/Common/CustomTagSelector/ResizableTagTextArea.tsx +14 -6
- package/src/Common/CustomTagSelector/Types.ts +1 -0
- package/src/Common/Helper.tsx +1 -1
- package/src/Common/ImageTags.Types.ts +1 -0
- package/src/Common/ImageTags.tsx +1 -14
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ResizableTagTextAreaProps } from './Types';
|
|
3
|
-
export declare function ResizableTagTextArea({ className, minHeight, maxHeight, value, onChange, onBlur, onFocus, placeholder, tabIndex, refVar, dependentRef, dataTestId, }: ResizableTagTextAreaProps): JSX.Element;
|
|
3
|
+
export declare function ResizableTagTextArea({ className, minHeight, maxHeight, value, onChange, onBlur, onFocus, placeholder, tabIndex, refVar, dependentRef, dataTestId, handleKeyDown, }: ResizableTagTextAreaProps): JSX.Element;
|
|
@@ -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;
|
package/dist/index.js
CHANGED
|
@@ -10071,7 +10071,7 @@ function CustomInput(_a) {
|
|
|
10071
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) {
|
|
10072
10072
|
e.persist();
|
|
10073
10073
|
onChange(e);
|
|
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] }))); })] })));
|
|
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)); })] })));
|
|
10075
10075
|
}
|
|
10076
10076
|
function handleUTCTime(ts, isRelativeTime) {
|
|
10077
10077
|
if (isRelativeTime === void 0) { isRelativeTime = false; }
|
|
@@ -14777,7 +14777,7 @@ var SvgIcInfoOutlined = function SvgIcInfoOutlined(props) {
|
|
|
14777
14777
|
};
|
|
14778
14778
|
|
|
14779
14779
|
function ResizableTagTextArea(_a) {
|
|
14780
|
-
var className = _a.className, minHeight = _a.minHeight, maxHeight = _a.maxHeight, value = _a.value, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, placeholder = _a.placeholder, tabIndex = _a.tabIndex, refVar = _a.refVar, dependentRef = _a.dependentRef, dataTestId = _a.dataTestId;
|
|
14780
|
+
var className = _a.className, minHeight = _a.minHeight, maxHeight = _a.maxHeight, value = _a.value, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, placeholder = _a.placeholder, tabIndex = _a.tabIndex, refVar = _a.refVar, dependentRef = _a.dependentRef, dataTestId = _a.dataTestId, handleKeyDown = _a.handleKeyDown;
|
|
14781
14781
|
var _b = __read(React.useState(''), 2), text = _b[0], setText = _b[1];
|
|
14782
14782
|
React.useEffect(function () {
|
|
14783
14783
|
setText(value);
|
|
@@ -14790,9 +14790,11 @@ function ResizableTagTextArea(_a) {
|
|
|
14790
14790
|
if (document.activeElement !== refVar.current)
|
|
14791
14791
|
return;
|
|
14792
14792
|
refVar.current.style.height = minHeight + 'px';
|
|
14793
|
-
dependentRef
|
|
14793
|
+
if (dependentRef) {
|
|
14794
|
+
dependentRef.current.style.height = minHeight + 'px';
|
|
14795
|
+
}
|
|
14794
14796
|
var nextHeight = refVar.current.scrollHeight;
|
|
14795
|
-
if (nextHeight < dependentRef.current.scrollHeight) {
|
|
14797
|
+
if (dependentRef && nextHeight < dependentRef.current.scrollHeight) {
|
|
14796
14798
|
nextHeight = dependentRef.current.scrollHeight;
|
|
14797
14799
|
}
|
|
14798
14800
|
if (minHeight && nextHeight < minHeight) {
|
|
@@ -14802,19 +14804,23 @@ function ResizableTagTextArea(_a) {
|
|
|
14802
14804
|
nextHeight = maxHeight;
|
|
14803
14805
|
}
|
|
14804
14806
|
refVar.current.style.height = nextHeight + 'px';
|
|
14805
|
-
dependentRef
|
|
14807
|
+
if (dependentRef) {
|
|
14808
|
+
dependentRef.current.style.height = nextHeight + 'px';
|
|
14809
|
+
}
|
|
14806
14810
|
};
|
|
14807
14811
|
useThrottledEffect(reInitHeight, 500, [text]);
|
|
14808
14812
|
var handleOnBlur = function (event) {
|
|
14809
14813
|
refVar.current.style.height = minHeight + 'px';
|
|
14810
|
-
dependentRef
|
|
14814
|
+
if (dependentRef) {
|
|
14815
|
+
dependentRef.current.style.height = minHeight + 'px';
|
|
14816
|
+
}
|
|
14811
14817
|
onBlur && onBlur(event);
|
|
14812
14818
|
};
|
|
14813
14819
|
var handleOnFocus = function (event) {
|
|
14814
14820
|
reInitHeight();
|
|
14815
14821
|
onFocus && onFocus(event);
|
|
14816
14822
|
};
|
|
14817
|
-
return (jsxRuntime.jsx("textarea", { rows: 1, ref: refVar, value: text, placeholder: placeholder, className: "".concat(className || '', " lh-20"), style: { resize: 'none' }, onChange: handleChange, onBlur: handleOnBlur, onFocus: handleOnFocus, tabIndex: tabIndex, "data-testid": dataTestId }));
|
|
14823
|
+
return (jsxRuntime.jsx("textarea", { rows: 1, ref: refVar, value: text, placeholder: placeholder, className: "".concat(className || '', " lh-20"), style: { resize: 'none' }, onChange: handleChange, onBlur: handleOnBlur, onFocus: handleOnFocus, tabIndex: tabIndex, "data-testid": dataTestId, onKeyDown: handleKeyDown }));
|
|
14818
14824
|
}
|
|
14819
14825
|
|
|
14820
14826
|
var validateTagValue = function (value) {
|
|
@@ -23114,7 +23120,7 @@ var SvgIcEnter = function SvgIcEnter(props) {
|
|
|
23114
23120
|
};
|
|
23115
23121
|
|
|
23116
23122
|
var ImageTagsContainer = function (_a) {
|
|
23117
|
-
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;
|
|
23123
|
+
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;
|
|
23118
23124
|
var _b = __read(React.useState(imageReleaseTags ? imageReleaseTags : []), 2), initialTags = _b[0], setInitialTags = _b[1];
|
|
23119
23125
|
var _c = __read(React.useState(imageComment ? imageComment.comment : ''), 2), initialDescription = _c[0], setInitialDescription = _c[1];
|
|
23120
23126
|
var _d = __read(React.useState(appReleaseTagNames ? appReleaseTagNames : []), 2), existingTags = _d[0], setExistingTags = _d[1];
|
|
@@ -23126,41 +23132,14 @@ var ImageTagsContainer = function (_a) {
|
|
|
23126
23132
|
var _k = __read(React.useState([]), 2), createTags = _k[0], setCreateTags = _k[1];
|
|
23127
23133
|
var _l = __read(React.useState([]), 2), softDeleteTags = _l[0], setSoftDeleteTags = _l[1];
|
|
23128
23134
|
var _m = __read(React.useState([]), 2), hardDeleteTags = _m[0], setHardDeleteTags = _m[1];
|
|
23129
|
-
var _o = __read(React.useState(
|
|
23130
|
-
var _p = __read(React.useState(''), 2),
|
|
23131
|
-
var _q = __read(React.useState(''), 2), textInput = _q[0], setTextInput = _q[1];
|
|
23132
|
-
React.useEffect(function () {
|
|
23133
|
-
initialise();
|
|
23134
|
-
}, []);
|
|
23135
|
+
var _o = __read(React.useState(''), 2), descriptionValidationMessage = _o[0], setDescriptionValidationMessage = _o[1];
|
|
23136
|
+
var _p = __read(React.useState(''), 2), textInput = _p[0], setTextInput = _p[1];
|
|
23135
23137
|
React.useEffect(function () {
|
|
23136
23138
|
reInitState();
|
|
23137
23139
|
}, [imageReleaseTags, imageComment, tagsEditable]);
|
|
23138
23140
|
React.useEffect(function () {
|
|
23139
23141
|
setExistingTags(appReleaseTagNames ? appReleaseTagNames : []);
|
|
23140
23142
|
}, [appReleaseTagNames]);
|
|
23141
|
-
function initialise() {
|
|
23142
|
-
var _a, _b;
|
|
23143
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
23144
|
-
var userRole, superAdmin, err_1;
|
|
23145
|
-
return __generator(this, function (_c) {
|
|
23146
|
-
switch (_c.label) {
|
|
23147
|
-
case 0:
|
|
23148
|
-
_c.trys.push([0, 2, , 3]);
|
|
23149
|
-
return [4 /*yield*/, getUserRole()];
|
|
23150
|
-
case 1:
|
|
23151
|
-
userRole = _c.sent();
|
|
23152
|
-
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___');
|
|
23153
|
-
setSuperAdmin(superAdmin);
|
|
23154
|
-
return [3 /*break*/, 3];
|
|
23155
|
-
case 2:
|
|
23156
|
-
err_1 = _c.sent();
|
|
23157
|
-
showError(err_1);
|
|
23158
|
-
return [3 /*break*/, 3];
|
|
23159
|
-
case 3: return [2 /*return*/];
|
|
23160
|
-
}
|
|
23161
|
-
});
|
|
23162
|
-
});
|
|
23163
|
-
}
|
|
23164
23143
|
var reInitState = function () {
|
|
23165
23144
|
if (forceReInit || !isEditing) {
|
|
23166
23145
|
setInitialTags(imageReleaseTags ? imageReleaseTags : []);
|
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ export function ResizableTagTextArea({
|
|
|
15
15
|
refVar,
|
|
16
16
|
dependentRef,
|
|
17
17
|
dataTestId,
|
|
18
|
+
handleKeyDown,
|
|
18
19
|
}: ResizableTagTextAreaProps) {
|
|
19
20
|
const [text, setText] = useState('')
|
|
20
21
|
|
|
@@ -29,10 +30,12 @@ export function ResizableTagTextArea({
|
|
|
29
30
|
|
|
30
31
|
const reInitHeight = () => {
|
|
31
32
|
if (document.activeElement !== refVar.current) return
|
|
32
|
-
refVar.current.style.height = minHeight+ 'px'
|
|
33
|
-
dependentRef
|
|
33
|
+
refVar.current.style.height = minHeight + 'px'
|
|
34
|
+
if (dependentRef) {
|
|
35
|
+
dependentRef.current.style.height = minHeight + 'px'
|
|
36
|
+
}
|
|
34
37
|
let nextHeight = refVar.current.scrollHeight
|
|
35
|
-
if (nextHeight < dependentRef.current.scrollHeight) {
|
|
38
|
+
if (dependentRef && nextHeight < dependentRef.current.scrollHeight) {
|
|
36
39
|
nextHeight = dependentRef.current.scrollHeight
|
|
37
40
|
}
|
|
38
41
|
if (minHeight && nextHeight < minHeight) {
|
|
@@ -42,14 +45,18 @@ export function ResizableTagTextArea({
|
|
|
42
45
|
nextHeight = maxHeight
|
|
43
46
|
}
|
|
44
47
|
refVar.current.style.height = nextHeight + 'px'
|
|
45
|
-
dependentRef
|
|
48
|
+
if (dependentRef) {
|
|
49
|
+
dependentRef.current.style.height = nextHeight + 'px'
|
|
50
|
+
}
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
useThrottledEffect(reInitHeight, 500, [text])
|
|
49
54
|
|
|
50
55
|
const handleOnBlur = (event) => {
|
|
51
|
-
refVar.current.style.height = minHeight+ 'px'
|
|
52
|
-
dependentRef
|
|
56
|
+
refVar.current.style.height = minHeight + 'px'
|
|
57
|
+
if (dependentRef) {
|
|
58
|
+
dependentRef.current.style.height = minHeight + 'px'
|
|
59
|
+
}
|
|
53
60
|
onBlur && onBlur(event)
|
|
54
61
|
}
|
|
55
62
|
|
|
@@ -71,6 +78,7 @@ export function ResizableTagTextArea({
|
|
|
71
78
|
onFocus={handleOnFocus}
|
|
72
79
|
tabIndex={tabIndex}
|
|
73
80
|
data-testid={dataTestId}
|
|
81
|
+
onKeyDown={handleKeyDown}
|
|
74
82
|
/>
|
|
75
83
|
)
|
|
76
84
|
}
|
package/src/Common/Helper.tsx
CHANGED
|
@@ -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>
|
package/src/Common/ImageTags.tsx
CHANGED
|
@@ -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) {
|