@devtron-labs/devtron-fe-common-lib 0.0.17-beta-8 → 0.0.17-beta-11
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/Common.service.d.ts +1 -3
- package/dist/Common/Helper.d.ts +0 -2
- package/dist/Common/ResizableTextarea.d.ts +3 -0
- package/dist/Common/Types.d.ts +14 -5
- package/dist/Common/index.d.ts +1 -0
- package/dist/index.js +37 -90
- package/package.json +1 -1
- package/src/Common/Common.service.ts +1 -81
- package/src/Common/EmptyState/GenericEmptyState.tsx +1 -0
- package/src/Common/Helper.tsx +1 -24
- package/src/Common/ResizableTextarea.tsx +73 -0
- package/src/Common/Types.ts +14 -5
- package/src/Common/index.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TeamList, ResponseType
|
|
1
|
+
import { TeamList, ResponseType } from './Types';
|
|
2
2
|
export declare const getTeamListMin: () => Promise<TeamList>;
|
|
3
3
|
interface UserRole extends ResponseType {
|
|
4
4
|
result?: {
|
|
@@ -8,6 +8,4 @@ interface UserRole extends ResponseType {
|
|
|
8
8
|
}
|
|
9
9
|
export declare function getUserRole(appName?: string): Promise<UserRole>;
|
|
10
10
|
export declare function setImageTags(request: any, pipelineId: number, artifactId: number): Promise<ResponseType>;
|
|
11
|
-
export declare const getCDMaterials: (cdMaterialId: any, stageType: DeploymentNodeType, abortSignal: AbortSignal, isApprovalNode?: boolean, imageTag?: string) => Promise<any>;
|
|
12
|
-
export declare function extractImage(image: string): string;
|
|
13
11
|
export {};
|
package/dist/Common/Helper.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { UseSearchString } from './Types';
|
|
3
2
|
export declare function showError(serverError: any, showToastOnUnknownError?: boolean, hideAccessError?: boolean): void;
|
|
4
3
|
interface ConditionalWrapper<T> {
|
|
5
4
|
condition: boolean;
|
|
@@ -41,5 +40,4 @@ export declare function CustomInput({ name, value, error, onChange, onBlur, onFo
|
|
|
41
40
|
dataTestid?: string;
|
|
42
41
|
}): JSX.Element;
|
|
43
42
|
export declare function handleUTCTime(ts: string, isRelativeTime?: boolean): string;
|
|
44
|
-
export declare function useSearchString(): UseSearchString;
|
|
45
43
|
export {};
|
package/dist/Common/Types.d.ts
CHANGED
|
@@ -332,10 +332,19 @@ export interface RegistryTypeDetailType {
|
|
|
332
332
|
id: InputDetailType;
|
|
333
333
|
password: InputDetailType;
|
|
334
334
|
}
|
|
335
|
-
export interface
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
335
|
+
export interface ResizableTextareaProps {
|
|
336
|
+
minHeight?: number;
|
|
337
|
+
maxHeight?: number;
|
|
338
|
+
value?: string;
|
|
339
|
+
onChange?: (e: any) => void;
|
|
340
|
+
onBlur?: (e: any) => void;
|
|
341
|
+
onFocus?: (e: any) => void;
|
|
342
|
+
className?: string;
|
|
343
|
+
placeholder?: string;
|
|
344
|
+
lineHeight?: number;
|
|
345
|
+
padding?: number;
|
|
346
|
+
disabled?: boolean;
|
|
347
|
+
name?: string;
|
|
348
|
+
dataTestId?: string;
|
|
340
349
|
}
|
|
341
350
|
export {};
|
package/dist/Common/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2162,6 +2162,7 @@ var AppNotDeployed = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAGQCAYA
|
|
|
2162
2162
|
|
|
2163
2163
|
function GenericEmptyState(_a) {
|
|
2164
2164
|
var title = _a.title, image = _a.image, subTitle = _a.subTitle, isButtonAvailable = _a.isButtonAvailable, classname = _a.classname, styles = _a.styles, heightToDeduct = _a.heightToDeduct, imageType = _a.imageType, renderButton = _a.renderButton, imageClassName = _a.imageClassName, children = _a.children, SvgImage = _a.SvgImage, noImage = _a.noImage;
|
|
2165
|
+
console.log(image);
|
|
2165
2166
|
return (jsxRuntime.jsxs("div", __assign({ className: "flex column empty-state ".concat(classname ? classname : ''), style: styles, "data-testid": "generic-empty-state" }, (heightToDeduct >= 0 && { style: __assign(__assign({}, styles), { height: "calc(100vh - ".concat(heightToDeduct, "px)") }) }), { children: [!SvgImage ? !noImage && jsxRuntime.jsx("img", { className: imageClassName ? imageClassName : '', src: image || AppNotDeployed, width: imageType === exports.ImageType.Medium ? '200' : '250', height: imageType === exports.ImageType.Medium ? '160' : '200', alt: "empty-state" }) : jsxRuntime.jsx(SvgImage, {}), jsxRuntime.jsx("h4", __assign({ className: "title fw-6 cn-9 mb-8" }, { children: title })), subTitle && jsxRuntime.jsx("p", __assign({ className: "subtitle" }, { children: subTitle })), isButtonAvailable && renderButton(), children] })));
|
|
2166
2167
|
}
|
|
2167
2168
|
|
|
@@ -10078,22 +10079,6 @@ function handleUTCTime(ts, isRelativeTime) {
|
|
|
10078
10079
|
console.error("Error Parsing Date:", ts);
|
|
10079
10080
|
}
|
|
10080
10081
|
return timestamp;
|
|
10081
|
-
}
|
|
10082
|
-
function useSearchString() {
|
|
10083
|
-
var location = reactRouterDom.useLocation();
|
|
10084
|
-
var queryParams = React.useMemo(function () {
|
|
10085
|
-
var queryParams = new URLSearchParams(location.search);
|
|
10086
|
-
return queryParams;
|
|
10087
|
-
}, [location]);
|
|
10088
|
-
// const searchParams={}
|
|
10089
|
-
// for (let [key, value] of queryParams.entries()){
|
|
10090
|
-
// searchParams[key]=value
|
|
10091
|
-
// }
|
|
10092
|
-
var searchParams = Array.from(queryParams.entries()).reduce(function (agg, curr, idx) {
|
|
10093
|
-
agg[curr[0]] = curr[1];
|
|
10094
|
-
return agg;
|
|
10095
|
-
}, {});
|
|
10096
|
-
return { queryParams: queryParams, searchParams: searchParams };
|
|
10097
10082
|
}
|
|
10098
10083
|
|
|
10099
10084
|
function Progressing(_a) {
|
|
@@ -22539,82 +22524,11 @@ var getTeamListMin = function () {
|
|
|
22539
22524
|
};
|
|
22540
22525
|
});
|
|
22541
22526
|
};
|
|
22542
|
-
var stageMap = {
|
|
22543
|
-
PRECD: 'PRE',
|
|
22544
|
-
CD: 'DEPLOY',
|
|
22545
|
-
POSTCD: 'POST',
|
|
22546
|
-
APPROVAL: 'APPROVAL',
|
|
22547
|
-
};
|
|
22548
22527
|
function getUserRole(appName) {
|
|
22549
22528
|
return get("".concat(ROUTES.USER_CHECK_ROLE).concat(appName ? "?appName=".concat(appName) : ''));
|
|
22550
22529
|
}
|
|
22551
22530
|
function setImageTags(request, pipelineId, artifactId) {
|
|
22552
22531
|
return post("".concat(ROUTES.IMAGE_TAGGING, "/").concat(pipelineId, "/").concat(artifactId), request);
|
|
22553
|
-
}
|
|
22554
|
-
var getCDMaterials = function (cdMaterialId, stageType, abortSignal, isApprovalNode, imageTag) {
|
|
22555
|
-
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);
|
|
22556
|
-
return get(URL, {
|
|
22557
|
-
signal: abortSignal,
|
|
22558
|
-
}).then(function (response) {
|
|
22559
|
-
var _a;
|
|
22560
|
-
var artifacts = (_a = response.result.ci_artifacts) !== null && _a !== void 0 ? _a : [];
|
|
22561
|
-
if (!response.result) {
|
|
22562
|
-
return {
|
|
22563
|
-
materials: [],
|
|
22564
|
-
};
|
|
22565
|
-
}
|
|
22566
|
-
else {
|
|
22567
|
-
var materials = artifacts.map(function (material, index) {
|
|
22568
|
-
var artifactStatusValue = '';
|
|
22569
|
-
return {
|
|
22570
|
-
index: index,
|
|
22571
|
-
id: material.id,
|
|
22572
|
-
deployedTime: material.deployed_time
|
|
22573
|
-
? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
|
|
22574
|
-
: 'Not Deployed',
|
|
22575
|
-
deployedBy: material.deployedBy,
|
|
22576
|
-
wfrId: material.wfrId,
|
|
22577
|
-
image: extractImage(material.image),
|
|
22578
|
-
showChanges: false,
|
|
22579
|
-
vulnerabilities: [],
|
|
22580
|
-
buildTime: material.build_time || '',
|
|
22581
|
-
showSourceInfo: false,
|
|
22582
|
-
deployed: material.deployed || false,
|
|
22583
|
-
latest: material.latest || false,
|
|
22584
|
-
vulnerabilitiesLoading: true,
|
|
22585
|
-
scanned: material.scanned,
|
|
22586
|
-
scanEnabled: material.scanEnabled,
|
|
22587
|
-
vulnerable: material.vulnerable,
|
|
22588
|
-
runningOnParentCd: material.runningOnParentCd,
|
|
22589
|
-
artifactStatus: artifactStatusValue,
|
|
22590
|
-
userApprovalMetadata: material.userApprovalMetadata,
|
|
22591
|
-
triggeredBy: material.triggeredBy,
|
|
22592
|
-
isVirtualEnvironment: material.isVirtualEnvironment,
|
|
22593
|
-
imageComment: material.imageComment,
|
|
22594
|
-
imageReleaseTags: material.imageReleaseTags,
|
|
22595
|
-
materialInfo: material.material_info
|
|
22596
|
-
? material.material_info.map(function (mat) {
|
|
22597
|
-
return {
|
|
22598
|
-
author: mat.author || '',
|
|
22599
|
-
message: mat.message || '',
|
|
22600
|
-
revision: mat.revision || '',
|
|
22601
|
-
tag: mat.tag || '',
|
|
22602
|
-
webhookData: mat.webhookData || '',
|
|
22603
|
-
url: mat.url || '',
|
|
22604
|
-
type: material.ciConfigureSourceType || '',
|
|
22605
|
-
};
|
|
22606
|
-
})
|
|
22607
|
-
: [],
|
|
22608
|
-
};
|
|
22609
|
-
});
|
|
22610
|
-
return {
|
|
22611
|
-
materials: materials
|
|
22612
|
-
};
|
|
22613
|
-
}
|
|
22614
|
-
});
|
|
22615
|
-
};
|
|
22616
|
-
function extractImage(image) {
|
|
22617
|
-
return image ? image.split(':').pop() : '';
|
|
22618
22532
|
}
|
|
22619
22533
|
|
|
22620
22534
|
/*
|
|
@@ -23271,6 +23185,41 @@ var AddImageButton = function (_a) {
|
|
|
23271
23185
|
return (jsxRuntime.jsx("div", __assign({ className: "add-tag-button flex pt-12 pr-12", "data-testid": "add-tags-button", onClick: handleClick }, { children: jsxRuntime.jsxs("div", __assign({ className: "lh-16 flex" }, { children: [jsxRuntime.jsx(SvgIcAdd, { className: "icon-dim-16 cn-6" }), jsxRuntime.jsx("span", __assign({ className: "cn-7" }, { children: "Add tags/comment" }))] })) })));
|
|
23272
23186
|
};
|
|
23273
23187
|
|
|
23188
|
+
var ResizableTextarea = function (_a) {
|
|
23189
|
+
var minHeight = _a.minHeight, maxHeight = _a.maxHeight, value = _a.value, _b = _a.onChange, onChange = _b === void 0 ? null : _b, _c = _a.onBlur, onBlur = _c === void 0 ? null : _c, _d = _a.onFocus, onFocus = _d === void 0 ? null : _d, _e = _a.className, className = _e === void 0 ? '' : _e, _f = _a.placeholder, placeholder = _f === void 0 ? 'Enter your text here..' : _f, _g = _a.lineHeight, lineHeight = _g === void 0 ? 14 : _g, _h = _a.padding, padding = _h === void 0 ? 12 : _h, _j = _a.disabled, disabled = _j === void 0 ? false : _j, dataTestId = _a.dataTestId, props = __rest(_a, ["minHeight", "maxHeight", "value", "onChange", "onBlur", "onFocus", "className", "placeholder", "lineHeight", "padding", "disabled", "dataTestId"]);
|
|
23190
|
+
var _k = __read(React.useState(''), 2), text = _k[0], setText = _k[1];
|
|
23191
|
+
var _textRef = React.useRef(null);
|
|
23192
|
+
React.useEffect(function () {
|
|
23193
|
+
setText(value);
|
|
23194
|
+
}, [value]);
|
|
23195
|
+
function handleChange(e) {
|
|
23196
|
+
e.persist();
|
|
23197
|
+
setText(e.target.value);
|
|
23198
|
+
if (typeof onChange === 'function')
|
|
23199
|
+
onChange(e);
|
|
23200
|
+
}
|
|
23201
|
+
function handleBlur(e) {
|
|
23202
|
+
if (typeof onBlur === 'function')
|
|
23203
|
+
onBlur(e);
|
|
23204
|
+
}
|
|
23205
|
+
function handleFocus(e) {
|
|
23206
|
+
if (typeof onFocus === 'function')
|
|
23207
|
+
onFocus(e);
|
|
23208
|
+
}
|
|
23209
|
+
useThrottledEffect(function () {
|
|
23210
|
+
_textRef.current.style.height = 'auto';
|
|
23211
|
+
var nextHeight = _textRef.current.scrollHeight;
|
|
23212
|
+
if (minHeight && nextHeight < minHeight) {
|
|
23213
|
+
nextHeight = minHeight;
|
|
23214
|
+
}
|
|
23215
|
+
if (maxHeight && nextHeight > maxHeight) {
|
|
23216
|
+
nextHeight = maxHeight;
|
|
23217
|
+
}
|
|
23218
|
+
_textRef.current.style.height = nextHeight + 2 + 'px';
|
|
23219
|
+
}, 500, [text]);
|
|
23220
|
+
return (jsxRuntime.jsx("textarea", __assign({ "data-testid": dataTestId, ref: function (el) { return (_textRef.current = el); }, value: text, placeholder: placeholder, className: "dc__resizable-textarea ".concat(className), onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, style: { lineHeight: "".concat(lineHeight, "px"), padding: "".concat(padding, "px") }, spellCheck: false, disabled: disabled }, props)));
|
|
23221
|
+
};
|
|
23222
|
+
|
|
23274
23223
|
exports.BreadCrumb = BreadCrumb;
|
|
23275
23224
|
exports.BreadcrumbStore = Store;
|
|
23276
23225
|
exports.BuildStageVariable = BuildStageVariable;
|
|
@@ -23317,6 +23266,7 @@ exports.RadioGroupItem = RadioGroupItem;
|
|
|
23317
23266
|
exports.Reload = Reload;
|
|
23318
23267
|
exports.RequestTimeout = RequestTimeout;
|
|
23319
23268
|
exports.ResizableTagTextArea = ResizableTagTextArea;
|
|
23269
|
+
exports.ResizableTextarea = ResizableTextarea;
|
|
23320
23270
|
exports.ScanVulnerabilitiesTable = ScanVulnerabilitiesTable;
|
|
23321
23271
|
exports.ServerError = ServerError;
|
|
23322
23272
|
exports.ServerErrors = ServerErrors;
|
|
@@ -23336,10 +23286,8 @@ exports.TriggerTypeMap = TriggerTypeMap;
|
|
|
23336
23286
|
exports.URLS = URLS;
|
|
23337
23287
|
exports.VisibleModal = VisibleModal;
|
|
23338
23288
|
exports.VisibleModal2 = VisibleModal2;
|
|
23339
|
-
exports.extractImage = extractImage;
|
|
23340
23289
|
exports.get = get;
|
|
23341
23290
|
exports.getAlphabetIcon = getAlphabetIcon;
|
|
23342
|
-
exports.getCDMaterials = getCDMaterials;
|
|
23343
23291
|
exports.getCookie = getCookie;
|
|
23344
23292
|
exports.getEmptyArrayOfLength = getEmptyArrayOfLength;
|
|
23345
23293
|
exports.getLoginInfo = getLoginInfo;
|
|
@@ -23361,5 +23309,4 @@ exports.trash = trash;
|
|
|
23361
23309
|
exports.useBreadcrumb = useBreadcrumb;
|
|
23362
23310
|
exports.useEffectAfterMount = useEffectAfterMount;
|
|
23363
23311
|
exports.useForm = useForm;
|
|
23364
|
-
exports.useSearchString = useSearchString;
|
|
23365
23312
|
exports.useThrottledEffect = useThrottledEffect;
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
1
|
import {get, post} from './Api';
|
|
3
2
|
import { ROUTES } from './Constants'
|
|
4
3
|
import { sortCallback } from './Helper';
|
|
5
|
-
import { TeamList ,ResponseType
|
|
4
|
+
import { TeamList ,ResponseType } from './Types';
|
|
6
5
|
|
|
7
6
|
export const getTeamListMin = (): Promise<TeamList> => {
|
|
8
7
|
// ignore active field
|
|
@@ -30,89 +29,10 @@ interface UserRole extends ResponseType {
|
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
let stageMap = {
|
|
34
|
-
PRECD: 'PRE',
|
|
35
|
-
CD: 'DEPLOY',
|
|
36
|
-
POSTCD: 'POST',
|
|
37
|
-
APPROVAL: 'APPROVAL',
|
|
38
|
-
}
|
|
39
|
-
|
|
40
32
|
export function getUserRole(appName?: string): Promise<UserRole> {
|
|
41
33
|
return get(`${ROUTES.USER_CHECK_ROLE}${appName ? `?appName=${appName}` : ''}`)
|
|
42
34
|
}
|
|
43
35
|
|
|
44
36
|
export function setImageTags(request, pipelineId: number, artifactId: number){
|
|
45
37
|
return post(`${ROUTES.IMAGE_TAGGING}/${pipelineId}/${artifactId}`,request )
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const getCDMaterials = (
|
|
49
|
-
cdMaterialId,
|
|
50
|
-
stageType: DeploymentNodeType,
|
|
51
|
-
abortSignal: AbortSignal,
|
|
52
|
-
isApprovalNode?: boolean,
|
|
53
|
-
imageTag?: string): Promise<any> => {
|
|
54
|
-
const URL = (!imageTag) ? `app/cd-pipeline/${cdMaterialId}/material?stage=${stageMap[stageType]}` : `app/cd-pipeline/${cdMaterialId}/material?stage=${stageMap[stageType]}&search=${imageTag}`
|
|
55
|
-
|
|
56
|
-
return get(URL, {
|
|
57
|
-
signal: abortSignal,
|
|
58
|
-
}).then((response) => {
|
|
59
|
-
let artifacts = response.result.ci_artifacts ?? []
|
|
60
|
-
if (!response.result) {
|
|
61
|
-
return {
|
|
62
|
-
materials: [],
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
const materials = artifacts.map((material, index) => {
|
|
67
|
-
let artifactStatusValue = ''
|
|
68
|
-
return {
|
|
69
|
-
index,
|
|
70
|
-
id: material.id,
|
|
71
|
-
deployedTime: material.deployed_time
|
|
72
|
-
? moment(material.deployed_time).format('ddd, DD MMM YYYY, hh:mm A')
|
|
73
|
-
: 'Not Deployed',
|
|
74
|
-
deployedBy: material.deployedBy,
|
|
75
|
-
wfrId: material.wfrId,
|
|
76
|
-
image: extractImage(material.image),
|
|
77
|
-
showChanges: false,
|
|
78
|
-
vulnerabilities: [],
|
|
79
|
-
buildTime: material.build_time || '',
|
|
80
|
-
showSourceInfo: false,
|
|
81
|
-
deployed: material.deployed || false,
|
|
82
|
-
latest: material.latest || false,
|
|
83
|
-
vulnerabilitiesLoading: true,
|
|
84
|
-
scanned: material.scanned,
|
|
85
|
-
scanEnabled: material.scanEnabled,
|
|
86
|
-
vulnerable: material.vulnerable,
|
|
87
|
-
runningOnParentCd: material.runningOnParentCd,
|
|
88
|
-
artifactStatus: artifactStatusValue,
|
|
89
|
-
userApprovalMetadata: material.userApprovalMetadata,
|
|
90
|
-
triggeredBy: material.triggeredBy,
|
|
91
|
-
isVirtualEnvironment: material.isVirtualEnvironment,
|
|
92
|
-
imageComment: material.imageComment,
|
|
93
|
-
imageReleaseTags: material.imageReleaseTags,
|
|
94
|
-
materialInfo: material.material_info
|
|
95
|
-
? material.material_info.map((mat) => {
|
|
96
|
-
return {
|
|
97
|
-
author: mat.author || '',
|
|
98
|
-
message: mat.message || '',
|
|
99
|
-
revision: mat.revision || '',
|
|
100
|
-
tag: mat.tag || '',
|
|
101
|
-
webhookData: mat.webhookData || '',
|
|
102
|
-
url: mat.url || '',
|
|
103
|
-
type: material.ciConfigureSourceType || '',
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
: [],
|
|
107
|
-
}
|
|
108
|
-
})
|
|
109
|
-
return {
|
|
110
|
-
materials: materials
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function extractImage(image: string): string {
|
|
117
|
-
return image ? image.split(':').pop() : ''
|
|
118
38
|
}
|
package/src/Common/Helper.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useEffect,
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
2
2
|
import { ServerErrors } from './ServerError'
|
|
3
3
|
import { toast } from 'react-toastify'
|
|
4
4
|
import * as Sentry from '@sentry/browser'
|
|
@@ -6,8 +6,6 @@ import { toastAccessDenied } from './ToastBody'
|
|
|
6
6
|
import { ERROR_EMPTY_SCREEN, TOKEN_COOKIE_NAME } from './Constants'
|
|
7
7
|
import { ReactComponent as FormError } from '../Assets/Icon/ic-warning.svg'
|
|
8
8
|
import moment from 'moment';
|
|
9
|
-
import { UseSearchString } from './Types'
|
|
10
|
-
import { useLocation } from 'react-router-dom'
|
|
11
9
|
|
|
12
10
|
toast.configure({
|
|
13
11
|
autoClose: 3000,
|
|
@@ -348,24 +346,3 @@ export function handleUTCTime(ts: string, isRelativeTime = false) {
|
|
|
348
346
|
}
|
|
349
347
|
return timestamp;
|
|
350
348
|
}
|
|
351
|
-
|
|
352
|
-
export function useSearchString(): UseSearchString {
|
|
353
|
-
const location = useLocation()
|
|
354
|
-
const queryParams: URLSearchParams = useMemo(() => {
|
|
355
|
-
const queryParams = new URLSearchParams(location.search)
|
|
356
|
-
return queryParams
|
|
357
|
-
}, [location])
|
|
358
|
-
|
|
359
|
-
// const searchParams={}
|
|
360
|
-
// for (let [key, value] of queryParams.entries()){
|
|
361
|
-
// searchParams[key]=value
|
|
362
|
-
// }
|
|
363
|
-
const searchParams = Array.from(queryParams.entries()).reduce((agg, curr, idx) => {
|
|
364
|
-
agg[curr[0]] = curr[1]
|
|
365
|
-
return agg
|
|
366
|
-
}, {})
|
|
367
|
-
|
|
368
|
-
return { queryParams, searchParams }
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react'
|
|
2
|
+
import { useThrottledEffect } from './Helper'
|
|
3
|
+
import { ResizableTextareaProps } from './Types'
|
|
4
|
+
|
|
5
|
+
export const ResizableTextarea: React.FC<ResizableTextareaProps> = ({
|
|
6
|
+
minHeight,
|
|
7
|
+
maxHeight,
|
|
8
|
+
value,
|
|
9
|
+
onChange = null,
|
|
10
|
+
onBlur = null,
|
|
11
|
+
onFocus = null,
|
|
12
|
+
className = '',
|
|
13
|
+
placeholder = 'Enter your text here..',
|
|
14
|
+
lineHeight = 14,
|
|
15
|
+
padding = 12,
|
|
16
|
+
disabled = false,
|
|
17
|
+
dataTestId,
|
|
18
|
+
...props
|
|
19
|
+
}) => {
|
|
20
|
+
const [text, setText] = useState('')
|
|
21
|
+
const _textRef = useRef(null)
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
setText(value)
|
|
25
|
+
}, [value])
|
|
26
|
+
|
|
27
|
+
function handleChange(e) {
|
|
28
|
+
e.persist()
|
|
29
|
+
setText(e.target.value)
|
|
30
|
+
if (typeof onChange === 'function') onChange(e)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function handleBlur(e) {
|
|
34
|
+
if (typeof onBlur === 'function') onBlur(e)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function handleFocus(e) {
|
|
38
|
+
if (typeof onFocus === 'function') onFocus(e)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
useThrottledEffect(
|
|
42
|
+
() => {
|
|
43
|
+
_textRef.current.style.height = 'auto'
|
|
44
|
+
let nextHeight = _textRef.current.scrollHeight
|
|
45
|
+
if (minHeight && nextHeight < minHeight) {
|
|
46
|
+
nextHeight = minHeight
|
|
47
|
+
}
|
|
48
|
+
if (maxHeight && nextHeight > maxHeight) {
|
|
49
|
+
nextHeight = maxHeight
|
|
50
|
+
}
|
|
51
|
+
_textRef.current.style.height = nextHeight + 2 + 'px'
|
|
52
|
+
},
|
|
53
|
+
500,
|
|
54
|
+
[text],
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<textarea
|
|
59
|
+
data-testid={dataTestId}
|
|
60
|
+
ref={(el) => (_textRef.current = el)}
|
|
61
|
+
value={text}
|
|
62
|
+
placeholder={placeholder}
|
|
63
|
+
className={`dc__resizable-textarea ${className}`}
|
|
64
|
+
onChange={handleChange}
|
|
65
|
+
onBlur={handleBlur}
|
|
66
|
+
onFocus={handleFocus}
|
|
67
|
+
style={{ lineHeight: `${lineHeight}px`, padding: `${padding}px` }}
|
|
68
|
+
spellCheck={false}
|
|
69
|
+
disabled={disabled}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
)
|
|
73
|
+
}
|
package/src/Common/Types.ts
CHANGED
|
@@ -366,9 +366,18 @@ export interface RegistryTypeDetailType {
|
|
|
366
366
|
password: InputDetailType
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
-
export interface
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
369
|
+
export interface ResizableTextareaProps {
|
|
370
|
+
minHeight?: number
|
|
371
|
+
maxHeight?: number
|
|
372
|
+
value?: string
|
|
373
|
+
onChange?: (e) => void
|
|
374
|
+
onBlur?: (e) => void
|
|
375
|
+
onFocus?: (e) => void
|
|
376
|
+
className?: string
|
|
377
|
+
placeholder?: string
|
|
378
|
+
lineHeight?: number
|
|
379
|
+
padding?: number
|
|
380
|
+
disabled?: boolean
|
|
381
|
+
name?: string
|
|
382
|
+
dataTestId?: string
|
|
374
383
|
}
|
package/src/Common/index.ts
CHANGED