@devtron-labs/devtron-fe-common-lib 0.0.6-beta-16 → 0.0.6-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.
- package/dist/Common/CustomTagSelector/TagDetails.d.ts +2 -7
- package/dist/Common/CustomTagSelector/TagLabelSelect.d.ts +2 -5
- package/dist/Common/CustomTagSelector/TagLabelValueSelector.d.ts +2 -9
- package/dist/Common/Types.d.ts +18 -0
- package/dist/index.js +12 -17
- package/package.json +1 -1
- package/src/Common/CustomTagSelector/TagDetails.tsx +2 -7
- package/src/Common/CustomTagSelector/TagLabelSelect.tsx +2 -8
- package/src/Common/CustomTagSelector/TagLabelValueSelector.tsx +12 -24
- package/src/Common/CustomTagSelector/ValidationRules.ts +3 -3
- package/src/Common/Types.ts +31 -8
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export default function TagDetails({ index, tagData, setTagData, removeTag, }:
|
|
4
|
-
index: number;
|
|
5
|
-
tagData: TagType;
|
|
6
|
-
setTagData: (index: number, tagData: TagType) => void;
|
|
7
|
-
removeTag: (index: number) => void;
|
|
8
|
-
}): JSX.Element;
|
|
2
|
+
import { TagDetailType } from '../Types';
|
|
3
|
+
export default function TagDetails({ index, tagData, setTagData, removeTag, }: TagDetailType): JSX.Element;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export declare const TagLabelSelect: ({ labelTags, setLabelTags
|
|
4
|
-
labelTags: TagType[];
|
|
5
|
-
setLabelTags: (tagList: TagType[]) => void;
|
|
6
|
-
}) => JSX.Element;
|
|
2
|
+
import { TagLabelSelectType } from '../Types';
|
|
3
|
+
export declare const TagLabelSelect: ({ labelTags, setLabelTags }: TagLabelSelectType) => JSX.Element;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export declare const TagLabelValueSelector: ({ selectedTagIndex, tagData, setTagData, tagOptions, isRequired, type, }:
|
|
4
|
-
selectedTagIndex: number;
|
|
5
|
-
tagData: TagType;
|
|
6
|
-
setTagData: (index: number, tagData: TagType) => void;
|
|
7
|
-
tagOptions?: OptionType[];
|
|
8
|
-
isRequired?: boolean;
|
|
9
|
-
type?: string;
|
|
10
|
-
}) => JSX.Element;
|
|
2
|
+
import { TagLabelValueSelectorType } from '../Types';
|
|
3
|
+
export declare const TagLabelValueSelector: ({ selectedTagIndex, tagData, setTagData, tagOptions, isRequired, type, }: TagLabelValueSelectorType) => JSX.Element;
|
package/dist/Common/Types.d.ts
CHANGED
|
@@ -25,3 +25,21 @@ export declare enum TippyTheme {
|
|
|
25
25
|
black = "black",
|
|
26
26
|
white = "white"
|
|
27
27
|
}
|
|
28
|
+
export interface TagLabelSelectType {
|
|
29
|
+
labelTags: TagType[];
|
|
30
|
+
setLabelTags: (tagList: TagType[]) => void;
|
|
31
|
+
}
|
|
32
|
+
export interface TagDetailType {
|
|
33
|
+
index: number;
|
|
34
|
+
tagData: TagType;
|
|
35
|
+
setTagData: (index: number, tagData: TagType) => void;
|
|
36
|
+
removeTag: (index: number) => void;
|
|
37
|
+
}
|
|
38
|
+
export interface TagLabelValueSelectorType {
|
|
39
|
+
selectedTagIndex: number;
|
|
40
|
+
tagData: TagType;
|
|
41
|
+
setTagData: (index: number, tagData: TagType) => void;
|
|
42
|
+
tagOptions?: OptionType[];
|
|
43
|
+
isRequired?: boolean;
|
|
44
|
+
type?: string;
|
|
45
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -8429,13 +8429,12 @@ var TagLabelValueSelector = function (_a) {
|
|
|
8429
8429
|
var _c = __read(useState(false), 2), isPopupOpen = _c[0], togglePopup = _c[1];
|
|
8430
8430
|
var validationRules = new ValidationRules();
|
|
8431
8431
|
useEffect(function () {
|
|
8432
|
-
|
|
8433
|
-
setSelectedValue(_tagData[type]);
|
|
8432
|
+
setSelectedValue((tagData === null || tagData === void 0 ? void 0 : tagData[type]) || '');
|
|
8434
8433
|
}, [selectedTagIndex, tagData, type]);
|
|
8435
8434
|
var handleOnBlur = function (e) {
|
|
8436
8435
|
if (!e.relatedTarget ||
|
|
8437
8436
|
!e.relatedTarget.classList.value ||
|
|
8438
|
-
e.relatedTarget.classList.value.
|
|
8437
|
+
!e.relatedTarget.classList.value.includes("tag-".concat(selectedTagIndex, "-class"))) {
|
|
8439
8438
|
var _tagData = __assign({}, tagData);
|
|
8440
8439
|
_tagData[type] = selectedValue;
|
|
8441
8440
|
if (type === 'key') {
|
|
@@ -8443,15 +8442,13 @@ var TagLabelValueSelector = function (_a) {
|
|
|
8443
8442
|
? !validationRules.propagateTagKey(selectedValue).isValid
|
|
8444
8443
|
: _tagData.value !== '';
|
|
8445
8444
|
}
|
|
8445
|
+
else if (selectedValue) {
|
|
8446
|
+
_tagData.isInvalidValue = !validationRules.propagateTagValue(selectedValue).isValid;
|
|
8447
|
+
_tagData.isInvalidKey = !_tagData.key || _tagData.isInvalidKey;
|
|
8448
|
+
}
|
|
8446
8449
|
else {
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
_tagData.isInvalidKey = !_tagData.key || _tagData.isInvalidKey;
|
|
8450
|
-
}
|
|
8451
|
-
else {
|
|
8452
|
-
_tagData.isInvalidValue = false;
|
|
8453
|
-
_tagData.isInvalidKey = !_tagData.key ? false : _tagData.isInvalidKey;
|
|
8454
|
-
}
|
|
8450
|
+
_tagData.isInvalidValue = false;
|
|
8451
|
+
_tagData.isInvalidKey = !_tagData.key ? false : _tagData.isInvalidKey;
|
|
8455
8452
|
}
|
|
8456
8453
|
setTagData(selectedTagIndex, _tagData);
|
|
8457
8454
|
}
|
|
@@ -8466,14 +8463,12 @@ var TagLabelValueSelector = function (_a) {
|
|
|
8466
8463
|
};
|
|
8467
8464
|
var renderValidationsSuggestions = function () {
|
|
8468
8465
|
var field = { isValid: true, messages: [] };
|
|
8469
|
-
if (type === '
|
|
8470
|
-
if (isRequired || selectedValue) {
|
|
8471
|
-
field = validationRules.propagateTagValue(selectedValue);
|
|
8472
|
-
}
|
|
8473
|
-
}
|
|
8474
|
-
else {
|
|
8466
|
+
if (type === 'key') {
|
|
8475
8467
|
field = validationRules.propagateTagKey(selectedValue);
|
|
8476
8468
|
}
|
|
8469
|
+
else if (isRequired || selectedValue) {
|
|
8470
|
+
field = validationRules.propagateTagValue(selectedValue);
|
|
8471
|
+
}
|
|
8477
8472
|
if (!field.isValid) {
|
|
8478
8473
|
return (jsxs("div", __assign({ className: "p-4" }, { children: [field.messages.map(function (error) { return (jsxs("div", __assign({ className: "flexbox p-4" }, { children: [jsx("span", { children: jsx(SvgIcClose, { className: "icon-dim-14 scr-5 mt-3 mr-4" }) }), jsx("span", { children: error })] }), error)); }), type === 'key' && (jsxs("div", __assign({ className: "flexbox p-4" }, { children: [jsx("span", { children: jsx(SvgIcInfoOutlined, { className: "icon-dim-14 mt-3 mr-4" }) }), jsx("span", __assign({ className: "dc__italic-font-style" }, { children: "Key format: prefix/name or name" }))] })))] })));
|
|
8479
8474
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { ReactComponent as DeleteCross } from '../../Assets/Icon/ic-close.svg'
|
|
3
3
|
import { ReactComponent as InjectTag } from '../../Assets/Icon/inject-tag.svg'
|
|
4
|
-
import {
|
|
4
|
+
import { TagDetailType } from '../Types'
|
|
5
5
|
import { TagLabelValueSelector } from './TagLabelValueSelector'
|
|
6
6
|
|
|
7
7
|
export default function TagDetails({
|
|
@@ -9,12 +9,7 @@ export default function TagDetails({
|
|
|
9
9
|
tagData,
|
|
10
10
|
setTagData,
|
|
11
11
|
removeTag,
|
|
12
|
-
}: {
|
|
13
|
-
index: number
|
|
14
|
-
tagData: TagType
|
|
15
|
-
setTagData: (index: number, tagData: TagType) => void
|
|
16
|
-
removeTag: (index: number) => void
|
|
17
|
-
}) {
|
|
12
|
+
}: TagDetailType) {
|
|
18
13
|
const deleteTag = (): void => {
|
|
19
14
|
removeTag(index)
|
|
20
15
|
}
|
|
@@ -2,15 +2,9 @@ import React from 'react'
|
|
|
2
2
|
import PropagateTagInfo from './PropagateTagInfo'
|
|
3
3
|
import { ReactComponent as Add } from '../../Assets/Icon/ic-add.svg'
|
|
4
4
|
import TagDetails from './TagDetails'
|
|
5
|
-
import {
|
|
5
|
+
import { TagLabelSelectType } from '../Types'
|
|
6
6
|
|
|
7
|
-
export const TagLabelSelect = ({
|
|
8
|
-
labelTags,
|
|
9
|
-
setLabelTags,
|
|
10
|
-
}: {
|
|
11
|
-
labelTags: TagType[]
|
|
12
|
-
setLabelTags: (tagList: TagType[]) => void
|
|
13
|
-
}) => {
|
|
7
|
+
export const TagLabelSelect = ({ labelTags, setLabelTags }: TagLabelSelectType) => {
|
|
14
8
|
const setTagData = (index, tagValue): void => {
|
|
15
9
|
const _tags = [...labelTags]
|
|
16
10
|
_tags[index] = tagValue
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { TagLabelValueSelectorType } from '../Types'
|
|
3
3
|
import PopupMenu from '../PopupMenu'
|
|
4
4
|
import { ValidationRules } from './ValidationRules'
|
|
5
5
|
import { ReactComponent as ErrorCross } from '../../Assets/Icon/ic-close.svg'
|
|
@@ -12,29 +12,21 @@ export const TagLabelValueSelector = ({
|
|
|
12
12
|
tagOptions,
|
|
13
13
|
isRequired,
|
|
14
14
|
type,
|
|
15
|
-
}: {
|
|
16
|
-
selectedTagIndex: number
|
|
17
|
-
tagData: TagType
|
|
18
|
-
setTagData: (index: number, tagData: TagType) => void
|
|
19
|
-
tagOptions?: OptionType[]
|
|
20
|
-
isRequired?: boolean
|
|
21
|
-
type?: string
|
|
22
|
-
}) => {
|
|
15
|
+
}: TagLabelValueSelectorType) => {
|
|
23
16
|
const [selectedValue, setSelectedValue] = useState<string>('')
|
|
24
17
|
const [isPopupOpen, togglePopup] = useState<boolean>(false)
|
|
25
18
|
|
|
26
19
|
const validationRules = new ValidationRules()
|
|
27
20
|
|
|
28
21
|
useEffect(() => {
|
|
29
|
-
|
|
30
|
-
setSelectedValue(_tagData[type])
|
|
22
|
+
setSelectedValue(tagData?.[type] || '')
|
|
31
23
|
}, [selectedTagIndex, tagData, type])
|
|
32
24
|
|
|
33
25
|
const handleOnBlur = (e) => {
|
|
34
26
|
if (
|
|
35
27
|
!e.relatedTarget ||
|
|
36
28
|
!e.relatedTarget.classList.value ||
|
|
37
|
-
e.relatedTarget.classList.value.
|
|
29
|
+
!e.relatedTarget.classList.value.includes(`tag-${selectedTagIndex}-class`)
|
|
38
30
|
) {
|
|
39
31
|
const _tagData = { ...tagData }
|
|
40
32
|
_tagData[type] = selectedValue
|
|
@@ -42,14 +34,12 @@ export const TagLabelValueSelector = ({
|
|
|
42
34
|
_tagData.isInvalidKey = selectedValue
|
|
43
35
|
? !validationRules.propagateTagKey(selectedValue).isValid
|
|
44
36
|
: _tagData.value !== ''
|
|
37
|
+
} else if (selectedValue) {
|
|
38
|
+
_tagData.isInvalidValue = !validationRules.propagateTagValue(selectedValue).isValid
|
|
39
|
+
_tagData.isInvalidKey = !_tagData.key || _tagData.isInvalidKey
|
|
45
40
|
} else {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
_tagData.isInvalidKey = !_tagData.key || _tagData.isInvalidKey
|
|
49
|
-
} else {
|
|
50
|
-
_tagData.isInvalidValue = false
|
|
51
|
-
_tagData.isInvalidKey = !_tagData.key ? false : _tagData.isInvalidKey
|
|
52
|
-
}
|
|
41
|
+
_tagData.isInvalidValue = false
|
|
42
|
+
_tagData.isInvalidKey = !_tagData.key ? false : _tagData.isInvalidKey
|
|
53
43
|
}
|
|
54
44
|
setTagData(selectedTagIndex, _tagData)
|
|
55
45
|
}
|
|
@@ -67,12 +57,10 @@ export const TagLabelValueSelector = ({
|
|
|
67
57
|
|
|
68
58
|
const renderValidationsSuggestions = (): JSX.Element => {
|
|
69
59
|
let field = { isValid: true, messages: [] }
|
|
70
|
-
if (type === '
|
|
71
|
-
if (isRequired || selectedValue) {
|
|
72
|
-
field = validationRules.propagateTagValue(selectedValue)
|
|
73
|
-
}
|
|
74
|
-
} else {
|
|
60
|
+
if (type === 'key') {
|
|
75
61
|
field = validationRules.propagateTagKey(selectedValue)
|
|
62
|
+
} else if (isRequired || selectedValue) {
|
|
63
|
+
field = validationRules.propagateTagValue(selectedValue)
|
|
76
64
|
}
|
|
77
65
|
if (!field.isValid) {
|
|
78
66
|
return (
|
|
@@ -5,11 +5,11 @@ const validateTagValue = (value: string): string[] => {
|
|
|
5
5
|
if (value.length > 63) {
|
|
6
6
|
errorList.push('Can be max 63 characters')
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
const firstLastAlphanumeric = PATTERNS.START_END_ALPHANUMERIC.test(value)
|
|
9
9
|
if (!firstLastAlphanumeric) {
|
|
10
10
|
errorList.push('Must start and end with an alphanumeric character')
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
const validValue = PATTERNS.ALPHANUMERIC_WITH_SPECIAL_CHAR.test(value)
|
|
13
13
|
if (!validValue) {
|
|
14
14
|
errorList.push('Can only contain alphanumeric chars and (-), (_), (.)')
|
|
15
15
|
}
|
|
@@ -32,7 +32,7 @@ export class ValidationRules {
|
|
|
32
32
|
if (prefix.length > 253) {
|
|
33
33
|
errorList.push('Prefix: Can be max 253 characters')
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
const validPrefix = PATTERNS.KUBERNETES_KEY_PREFIX.test(prefix)
|
|
36
36
|
if (!validPrefix) {
|
|
37
37
|
errorList.push('Prefix: Must be a DNS subdomain (a series of DNS labels separated by dots (.)')
|
|
38
38
|
}
|
package/src/Common/Types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TagLabelSelect } from './CustomTagSelector'
|
|
2
|
+
|
|
1
3
|
export interface ResponseType {
|
|
2
4
|
code: number
|
|
3
5
|
status: string
|
|
@@ -12,20 +14,41 @@ export interface APIOptions {
|
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export interface TagType {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
key: string
|
|
18
|
+
value?: string
|
|
19
|
+
description?: string
|
|
20
|
+
propagate: boolean
|
|
21
|
+
isInvalidKey?: boolean
|
|
22
|
+
isInvalidValue?: boolean
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export interface OptionType {
|
|
24
|
-
label: string
|
|
25
|
-
value: string
|
|
26
|
+
label: string
|
|
27
|
+
value: string
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export enum TippyTheme {
|
|
29
31
|
black = 'black',
|
|
30
32
|
white = 'white',
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface TagLabelSelectType {
|
|
36
|
+
labelTags: TagType[]
|
|
37
|
+
setLabelTags: (tagList: TagType[]) => void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface TagDetailType {
|
|
41
|
+
index: number
|
|
42
|
+
tagData: TagType
|
|
43
|
+
setTagData: (index: number, tagData: TagType) => void
|
|
44
|
+
removeTag: (index: number) => void
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface TagLabelValueSelectorType {
|
|
48
|
+
selectedTagIndex: number
|
|
49
|
+
tagData: TagType
|
|
50
|
+
setTagData: (index: number, tagData: TagType) => void
|
|
51
|
+
tagOptions?: OptionType[]
|
|
52
|
+
isRequired?: boolean
|
|
53
|
+
type?: string
|
|
31
54
|
}
|