Skip to content

Commit 225adb9

Browse files
committed
chore: creatable changes reverted
1 parent 0b7ff7d commit 225adb9

File tree

3 files changed

+102
-25
lines changed

3 files changed

+102
-25
lines changed

src/components/CIPipelineN/TaskTypeDetailComponent.tsx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import {
2525
ScriptType,
2626
CustomInput,
2727
ClipboardButton,
28-
SelectPicker,
29-
ComponentSizeType,
3028
} from '@devtron-labs/devtron-fe-common-lib'
3129
import { components } from 'react-select'
3230
import { TaskFieldDescription, TaskFieldLabel } from '../ciPipeline/types'
@@ -41,6 +39,9 @@ import { OptionType } from '../app/types'
4139
import { ValidationRules } from '../ciPipeline/validationRules'
4240
import { ReactComponent as Info } from '../../assets/icons/ic-info-filled.svg'
4341
import { pipelineContext } from '../workflowEditor/workflowEditor'
42+
import CreatableSelect from 'react-select/creatable'
43+
import { containerImageSelectStyles } from './ciPipeline.utils'
44+
import { ValueContainer } from '@Components/app/details/appDetails/utils'
4445

4546
export const TaskTypeDetailComponent = () => {
4647
const {
@@ -239,17 +240,25 @@ export const TaskTypeDetailComponent = () => {
239240
/>
240241

241242
<div className="dc__position-rel">
242-
<SelectPicker
243-
inputId='container-image-select'
244-
isCreatableSingleSelect
243+
<CreatableSelect
244+
tabIndex={1}
245245
value={selectedContainerImage}
246246
options={containerImageOptions}
247247
placeholder="Select container image or input value"
248248
onChange={handleContainerImageSelector}
249+
styles={containerImageSelectStyles}
249250
classNamePrefix="select"
250-
renderMenuListFooter={renderMenuListFooter}
251-
size={ComponentSizeType.large}
251+
components={{
252+
MenuList: menuList,
253+
Option,
254+
IndicatorSeparator: null,
255+
ValueContainer,
256+
}}
257+
noOptionsMessage={(): string => {
258+
return 'No matching options'
259+
}}
252260
onBlur={handleCreatableBlur}
261+
isValidNewOption={() => false}
253262
onKeyDown={handleKeyDown}
254263
/>
255264
{selectedContainerImage?.label && (

src/components/app/details/appDetails/utils.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ import React from 'react'
1919
import { components } from 'react-select'
2020
import { AggregationKeys } from '../../types'
2121
import { getVersionArr, isVersionLessThanOrEqualToTarget, DayPickerRangeControllerPresets } from '../../../common'
22+
import { ReactComponent as ArrowDown } from '../../../../assets/icons/ic-chevron-down.svg'
2223
import { ChartTypes, AppMetricsTabType, StatusType, StatusTypes } from './appDetails.type'
23-
import { ZERO_TIME_STRING, Nodes, NodeType, SelectPicker } from '@devtron-labs/devtron-fe-common-lib'
24+
import { ZERO_TIME_STRING, Nodes, NodeType } from '@devtron-labs/devtron-fe-common-lib'
25+
import CreatableSelect from 'react-select/creatable'
2426

2527
export function getAggregator(nodeType: NodeType, defaultAsOtherResources?: boolean): AggregationKeys {
2628
switch (nodeType) {
@@ -72,6 +74,13 @@ export function getAggregator(nodeType: NodeType, defaultAsOtherResources?: bool
7274
}
7375
}
7476

77+
export const DropdownIndicator = (props) => {
78+
return (
79+
<components.DropdownIndicator {...props}>
80+
<ArrowDown className="icon-dim-20 fcn-6" />
81+
</components.DropdownIndicator>
82+
)
83+
}
7584

7685
const throughputAndLatencySelectStyle = {
7786
container: (base, state) => ({
@@ -109,8 +118,8 @@ const throughputAndLatencySelectStyle = {
109118

110119
export const ThroughputSelect = (props) => {
111120
return (
112-
<SelectPicker
113-
isCreatableSingleSelect
121+
<CreatableSelect
122+
className=""
114123
inputId="throughput-select"
115124
placeholder="Status Code"
116125
value={{ label: props.status, value: props.status }}
@@ -124,15 +133,19 @@ export const ThroughputSelect = (props) => {
124133
{ label: 'Throughput', value: 'Throughput' },
125134
]}
126135
onChange={props.handleStatusChange}
136+
styles={throughputAndLatencySelectStyle}
137+
components={{
138+
IndicatorSeparator: null,
139+
DropdownIndicator,
140+
}}
127141
/>
128142
)
129143
}
130144

131145
export const LatencySelect = (props) => {
132146
return (
133-
<SelectPicker
134-
inputId='latency-select'
135-
isCreatableSingleSelect
147+
<CreatableSelect
148+
className=""
136149
placeholder="Latency"
137150
value={{ label: props.latency, value: props.latency }}
138151
options={[
@@ -142,6 +155,12 @@ export const LatencySelect = (props) => {
142155
{ label: '95', value: '95' },
143156
]}
144157
onChange={props.handleLatencyChange}
158+
styles={throughputAndLatencySelectStyle}
159+
components={{
160+
IndicatorSeparator: null,
161+
DropdownIndicator,
162+
}}
163+
formatCreateLabel={(inputValue) => inputValue}
145164
/>
146165
)
147166
}

src/components/ciConfig/CIBuildpackBuildOptions.tsx

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616

1717
import { useEffect, useState } from 'react'
1818
import { components } from 'react-select'
19-
import { CIBuildType, ComponentSizeType, CustomInput, InfoIconTippy, SelectPicker } from '@devtron-labs/devtron-fe-common-lib'
19+
import { CIBuildType, ComponentSizeType, CustomInput, InfoIconTippy, SelectPicker, stopPropagation } from '@devtron-labs/devtron-fe-common-lib'
20+
import {
21+
DropdownIndicator,
22+
getCommonSelectStyle,
23+
getCustomOptionSelectionStyle,
24+
Option,
25+
} from '../v2/common/ReactSelect.utils'
2026
import { ReactComponent as GitLab } from '../../assets/icons/git/gitlab.svg'
2127
import { ReactComponent as Git } from '../../assets/icons/git/git.svg'
2228
import { ReactComponent as GitHub } from '../../assets/icons/git/github.svg'
@@ -41,6 +47,7 @@ import {
4147
VERSION_DETECT_OPTION,
4248
} from './ciConfigConstant'
4349
import { getSelectStartIcon } from './utils'
50+
import CreatableSelect from 'react-select/creatable'
4451

4552
export const renderOptionIcon = (option: string) => {
4653
if (!option) {
@@ -70,6 +77,47 @@ const menuListComponent = (props): JSX.Element => {
7077
)
7178
}
7279

80+
81+
export const repositoryOption = (props): JSX.Element => {
82+
props.selectProps.styles.option = getCustomOptionSelectionStyle()
83+
return (
84+
<components.Option {...props}>
85+
{props.data.url && renderOptionIcon(props.data.url)}
86+
{props.label}
87+
</components.Option>
88+
)
89+
}
90+
91+
export const releaseTagOption = (props): JSX.Element => {
92+
props.selectProps.styles.option = getCustomOptionSelectionStyle()
93+
return (
94+
<components.Option {...props} onClick={stopPropagation}>
95+
{props.value}
96+
</components.Option>
97+
)
98+
}
99+
100+
export const checkoutPathOption = (props): JSX.Element => {
101+
props.selectProps.styles.option = getCustomOptionSelectionStyle()
102+
return <components.Option {...props}>{props.value}</components.Option>
103+
}
104+
export const repositoryControls = (props): JSX.Element => {
105+
let value = ''
106+
if (props.hasValue) {
107+
value = props.getValue()[0].url
108+
}
109+
const showGit = value && !value.includes('github') && !value.includes('gitlab') && !value.includes('bitbucket')
110+
return (
111+
<components.Control {...props}>
112+
{value.includes('github') && <GitHub className="icon-dim-20 ml-10" />}
113+
{value.includes('gitlab') && <GitLab className="icon-dim-20 ml-10" />}
114+
{value.includes('bitbucket') && <BitBucket className="icon-dim-20 ml-10" />}
115+
{showGit && <Git className="icon-dim-20 ml-10" />}
116+
{props.children}
117+
</components.Control>
118+
)
119+
}
120+
73121
const BuildContextLabel = () => {
74122
return (
75123
<label htmlFor="" className="form__label flexbox-imp flex-align-center">
@@ -454,14 +502,7 @@ export default function CIBuildpackBuildOptions({
454502
setBuildEnvArgs(_buildEnvArgs)
455503
}
456504

457-
const formatOptionLabel = (option: VersionsOptionType) => {
458-
return (
459-
<div className="flex left column w-100 dc__ellipsis-right">
460-
<span>{option.label}</span>
461-
{option.infoText && <small className="cn-6">{option.infoText}</small>}
462-
</div>
463-
)
464-
}
505+
const formatCreateLabel = (inputValue: string) => `Use '${inputValue}'`
465506

466507
const projectPathVal = readOnly ? ciBuildConfig.buildPackConfig?.projectPath : projectPath.value
467508

@@ -617,17 +658,25 @@ export default function CIBuildpackBuildOptions({
617658
<BuilderTippy />
618659
</label>
619660

620-
<SelectPicker
621-
inputId="build-pack-builder"
622-
isCreatableSingleSelect
661+
<CreatableSelect
623662
classNamePrefix="build-pack-select-builder-dropdown"
624663
placeholder={CI_BUILDPACK_OPTION_TEXTS.BuilderTippyContent.selectBuilder}
664+
className="m-0"
665+
tabIndex={3}
625666
isLoading={!builderLanguageSupportMap?.[buildersAndFrameworks.selectedLanguage?.value]}
626667
options={
627668
builderLanguageSupportMap?.[buildersAndFrameworks.selectedLanguage?.value]
628669
?.BuilderLanguageMetadata
629670
}
630671
value={buildersAndFrameworks.selectedBuilder}
672+
formatCreateLabel={formatCreateLabel}
673+
styles={getCommonSelectStyle(BUILDER_SELECT_STYLES)}
674+
components={{
675+
IndicatorSeparator: null,
676+
DropdownIndicator,
677+
Option,
678+
MenuList: menuListComponent,
679+
}}
631680
onChange={handleBuilderSelection}
632681
/>
633682
</div>

0 commit comments

Comments
 (0)