Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtron-labs/devtron-fe-common-lib",
"version": "1.23.5-pre-3",
"version": "4.0.3-pre-0",
"description": "Supporting common component library",
"type": "module",
"main": "dist/index.js",
Expand Down
17 changes: 13 additions & 4 deletions src/Shared/Components/Plugin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { MutableRefObject } from 'react'

import { ConsequenceType, ServerErrors, VariableType } from '../../../Common'
import { ConditionDetails, ConsequenceType, ServerErrors, VariableType } from '../../../Common'
import { BaseFilterQueryParams } from '../../types'
import { ImageWithFallbackProps } from '../ImageWithFallback'
import { getPluginStoreData } from './service'
Expand Down Expand Up @@ -50,10 +50,19 @@ interface MinimalPluginVersionDataDTO {
isLatest: boolean
}

export interface PluginStepConditionDTO extends Pick<ConditionDetails, 'conditionType' | 'conditionalValue'> {
conditionalOperator: ConditionDetails['conditionOperator']
id: number
}

interface PluginVariableType extends VariableType {
pluginStepCondition?: PluginStepConditionDTO[]
}

interface DetailedPluginVersionDTO extends MinimalPluginVersionDataDTO {
tags: string[]
inputVariables: VariableType[]
outputVariables: VariableType[]
inputVariables: PluginVariableType[]
outputVariables: PluginVariableType[]
/**
* Present in case of shared plugin
*/
Expand Down Expand Up @@ -112,7 +121,7 @@ export interface ParentPluginType extends Pick<
pluginVersions: MinimalPluginVersionDataDTO[]
}

interface DetailedPluginVersionType
export interface DetailedPluginVersionType
extends
Pick<MinimalPluginVersionDataDTO, 'id' | 'description' | 'name' | 'pluginVersion'>,
Pick<DetailedPluginVersionDTO, 'tags' | 'inputVariables' | 'outputVariables' | 'updatedBy' | 'docLink'>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ export const SelectPickerTextArea = ({
maxHeight,
refVar,
dependentRefs,
filterOption: filterOptionProp,
...props
}: SelectPickerTextAreaProps) => {
// STATES
const [inputValue, setInputValue] = useState((value as SingleValue<SelectPickerOptionType<string>>)?.value || '')
const [isInputDirty, setIsInputDirty] = useState(false)

// REFS
const selectRef = useRef<SelectInstance<SelectPickerOptionType<string>>>(null)
Expand All @@ -50,6 +52,7 @@ export const SelectPickerTextArea = ({
useEffect(() => {
const selectValue = value as SingleValue<SelectPickerOptionType<string>>
setInputValue(selectValue?.value || '')
setIsInputDirty(false)
}, [value])

// METHODS
Expand Down Expand Up @@ -120,9 +123,23 @@ export const SelectPickerTextArea = ({
return false
}

const filterOption: SelectPickerTextAreaProps['filterOption'] = (...filterOptionArgs) => {
if (!isInputDirty) {
return true
}

if (filterOptionProp) {
return filterOptionProp(...filterOptionArgs)
}

const [option, rawInput] = filterOptionArgs
return option.label.toLowerCase().includes(rawInput.toLowerCase())
}

const onInputChange = (newValue: string, { action }: InputActionMeta) => {
if (action === ReactSelectInputAction.inputChange) {
setInputValue(newValue)
setIsInputDirty(true)

if (!newValue) {
onChange?.(null, {
Expand All @@ -137,6 +154,7 @@ export const SelectPickerTextArea = ({
const selectValue = value as SingleValue<SelectPickerOptionType<string>>
// Reverting input to previously selected value in case of blur event. (no-selection)
setInputValue(selectValue?.value || '')
setIsInputDirty(false)
}
}

Expand Down Expand Up @@ -195,6 +213,7 @@ export const SelectPickerTextArea = ({
selectRef={selectRef}
inputValue={inputValue}
value={value}
filterOption={filterOption}
onInputChange={onInputChange}
controlShouldRenderValue={false}
onChange={onChange}
Expand Down
Loading