Skip to content

Commit 44df859

Browse files
committed
feat: add semantic version validator and fix multi select styles
1 parent 9a19767 commit 44df859

File tree

9 files changed

+51
-13
lines changed

9 files changed

+51
-13
lines changed

src/Common/Constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,3 +517,5 @@ export const DATE_TIME_FORMATS = {
517517
DD_MMM_YYYY_HH_MM: 'DD MMM YYYY, hh:mm',
518518
DD_MMM_YYYY: 'DD MMM YYYY',
519519
}
520+
521+
export const SEMANTIC_VERSION_DOCUMENTATION_LINK = 'https://semver.org/'

src/Common/CustomInput/CustomInput.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ export const CustomInput = ({
135135

136136
{getInputError()}
137137
{helperText && (
138-
<div className="flex left top dc__gap-4 fs-11 lh-16 cn-7">
139-
<Info className="icon-dim-16" />
140-
<div>{helperText}</div>
138+
<div className="flex left top dc__gap-4 fs-11 lh-16 cn-7 pt-4">
139+
<Info className="icon-dim-16" />
140+
<div>{helperText}</div>
141141
</div>
142142
)}
143143
</div>

src/Common/CustomInput/Types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React, { HTMLInputTypeAttribute, InputHTMLAttributes } from 'react'
17+
import React, { HTMLInputTypeAttribute, InputHTMLAttributes, ReactNode } from 'react'
1818

1919
export interface CustomInputProps {
2020
name: string
@@ -33,7 +33,7 @@ export interface CustomInputProps {
3333
autoFocus?: boolean
3434
rootClassName?: string
3535
error?: string[] | string
36-
helperText?: string
36+
helperText?: ReactNode
3737
handleOnBlur?: (e) => void
3838
readOnly?: boolean
3939
noTrim?: boolean

src/Common/MultiSelectCustomization.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import React from 'react'
1818
import Select, { components } from 'react-select'
1919
import { ReactComponent as ClearIcon } from '../Assets/Icon/ic-appstatus-cancelled.svg'
20+
import { ReactComponent as ICErrorCross } from '@Icons/ic-error-cross.svg'
2021
import { ReactComponent as Check } from '../Assets/Icon/ic-check.svg'
2122
import { ReactComponent as RedWarning } from '../Assets/Icon/ic-error-medium.svg'
2223
import { Checkbox } from './Checkbox'
@@ -62,8 +63,8 @@ export const SingleSelectOption = (props) => {
6263
}
6364

6465
/**
65-
* Multi value container
66-
*/
66+
* Multi value container
67+
*/
6768

6869
export const MultiValueContainer = (props) => {
6970
const { children, data, innerProps, selectProps } = props
@@ -76,7 +77,7 @@ export const MultiValueContainer = (props) => {
7677
)
7778
}
7879
/**
79-
*
80+
*
8081
* Multi value container with count
8182
*/
8283
export const MultiValueContainerWithCount = (props: any) => {
@@ -119,10 +120,11 @@ export const MultiValueRemove = (props) => {
119120
} = props
120121
return (
121122
<components.MultiValueRemove {...props}>
122-
<ClearIcon
123+
<ICErrorCross
123124
{...{ onClick, onMouseDown }}
124125
onClick={(e) => onClick(data)}
125-
style={{ height: '18px', width: '18px' }}
126+
className="icon-n5"
127+
style={{ height: '14px', width: '14px' }}
126128
/>
127129
</components.MultiValueRemove>
128130
)
@@ -138,7 +140,7 @@ export const MultiValueChipContainer = ({ validator, isAllSelected = false, ...p
138140
return (
139141
<components.MultiValueContainer {...{ data, innerProps, selectProps }}>
140142
<div className="flex left fs-12 pl-4 pr-4 dc__ellipsis-right">
141-
{!isValidEmail && <RedWarning className="mr-4 icon-dim-16" />}
143+
{!isValidEmail && <RedWarning className="mr-4 icon-dim-16 dc__no-shrink" />}
142144
<div className={`dc__ellipsis-right ${isValidEmail ? 'cn-9' : 'cr-5'}`}>{label}</div>
143145
</div>
144146
{children[1]}

src/Shared/Components/EditImageFormField/EditImageFormField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const EditImageFormField = ({
8585

8686
const blob = await response.blob()
8787
if (blob.size > DEFAULT_MAX_IMAGE_SIZE) {
88-
throw new Error(`Please add an image smaller than ${DEFAULT_MAX_IMAGE_SIZE}`)
88+
throw new Error(`Please add an image smaller than ${DEFAULT_MAX_IMAGE_SIZE} bytes`)
8989
}
9090

9191
const src = URL.createObjectURL(blob)

src/Shared/Components/Plugin/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ interface DetailedPluginVersionType
9696
DetailedPluginVersionDTO,
9797
'tags' | 'isLatest' | 'inputVariables' | 'outputVariables' | 'updatedBy' | 'docLink'
9898
>,
99-
Pick<ParentPluginType, 'icon' | 'type'> {
99+
Pick<ParentPluginType, 'icon' | 'type' | 'pluginIdentifier'> {
100100
parentPluginId: ParentPluginType['id']
101101
}
102102

src/Shared/Components/Plugin/utils.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export const parsePluginDetailsDTOIntoPluginStore = (pluginData: ParentPluginDTO
7070
parentPluginId: plugin.id,
7171
icon: plugin.icon || '',
7272
type: plugin.type,
73+
pluginIdentifier: plugin.pluginIdentifier || '',
7374
}
7475
})
7576
})

src/Shared/Components/SelectPicker/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export interface SelectPickerProps
4040
| 'isOptionDisabled'
4141
| 'placeholder'
4242
| 'autoFocus'
43+
| 'onKeyDown'
4344
>,
4445
Required<Pick<SelectProps, 'classNamePrefix' | 'inputId' | 'name'>> {
4546
/**

src/Shared/validations.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@ export const MESSAGES = {
2929
VALID_POSITIVE_NUMBER: 'This field should be a valid positive number',
3030
VALID_POSITIVE_INTEGER: 'This field should be a valid positive integer',
3131
MAX_SAFE_INTEGER: `Maximum allowed value is ${Number.MAX_SAFE_INTEGER}`,
32+
INVALID_SEMANTIC_VERSION: 'Please follow semantic versioning',
3233
}
3334

3435
const MAX_DESCRIPTION_LENGTH = 350
36+
const DISPLAY_NAME_CONSTRAINTS = {
37+
MAX_LIMIT: 50,
38+
MIN_LIMIT: 3,
39+
}
3540

3641
export const requiredField = (value: string): ValidationResponseType => {
3742
if (!value) {
@@ -248,3 +253,30 @@ export const validateUniqueKeys = (keys: string[]) => {
248253
message: `Duplicate variable name: ${duplicateKeys.join(', ')}`,
249254
}
250255
}
256+
257+
export const validateSematicVersioning = (version: string): ValidationResponseType => {
258+
if (!/^.{0,128}$/.test(version)) {
259+
return {
260+
isValid: false,
261+
message: MESSAGES.getMaxCharMessage(128),
262+
}
263+
}
264+
265+
if (
266+
!/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/.test(
267+
version,
268+
)
269+
) {
270+
return {
271+
isValid: false,
272+
message: MESSAGES.INVALID_SEMANTIC_VERSION,
273+
}
274+
}
275+
276+
return {
277+
isValid: true,
278+
}
279+
}
280+
281+
export const validateDisplayName = (name: string): ValidationResponseType =>
282+
validateStringLength(name, DISPLAY_NAME_CONSTRAINTS.MAX_LIMIT, DISPLAY_NAME_CONSTRAINTS.MIN_LIMIT)

0 commit comments

Comments
 (0)