Skip to content

Commit 3eecfe2

Browse files
committed
fix for custom tag
1 parent 521e249 commit 3eecfe2

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

src/components/charts/AdvancedConfig.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect, useMemo } from 'react'
2-
import { showError, Progressing, VisibleModal, useAsync } from '@devtron-labs/devtron-fe-common-lib'
2+
import { showError, Progressing, VisibleModal, useAsync, CustomInput } from '@devtron-labs/devtron-fe-common-lib'
33
import { Select, mapByKey, useKeyDown, Info, Pencil } from '../common'
44
import CodeEditor from '../CodeEditor/CodeEditor'
55
import { getEnvironmentListMin } from '../../services/service'
@@ -11,6 +11,7 @@ import { ReactComponent as LockIcon } from '../../assets/icons/ic-locked.svg'
1111
import { ReactComponent as WarningIcon } from '../../assets/icons/ic-alert-triangle.svg';
1212
import { useHistory } from 'react-router'
1313
import { getSavedValuesListURL } from './charts.helper'
14+
import { renderAdditionalErrorInfo } from './charts.util'
1415

1516
interface AdvancedConfig extends AdvancedConfigHelpers {
1617
chart: ChartGroupEntry;
@@ -141,14 +142,18 @@ const AdvancedConfig: React.FC<AdvancedConfig> = ({ chart, index, fetchChartValu
141142
<div className="advanced-config flex">
142143
<form action="" className="advanced-config__form">
143144
<h1 className="form__title form__title--mb-24" data-testid="advanced-option-heading">{chartName}</h1>
144-
{handleNameChange && <div className="flex column left top mb-16">
145-
<label htmlFor="" className="form__label" data-testid="advanced-option-app-name">App name*</label>
146-
<input type="text" autoComplete="off" className={`form__input ${appName?.error ? 'form__input--error' : ''}`} value={appName.value} onChange={e => handleNameChange(index, e.target.value)} data-testid="advanced-option-app-name-box"/>
147-
{appName?.error &&
148-
<span className="form__error flex left">
149-
<WarningIcon className="mr-5 icon-dim-16" />{appName?.error || ""}
150-
{appName.suggestedName && <span>. Suggested name: <span className="anchor pointer" onClick={e => handleNameChange(index, appName.suggestedName)}>{appName.suggestedName}</span></span>}
151-
</span>}
145+
{handleNameChange && <div className="mb-16">
146+
<CustomInput
147+
name="appName"
148+
label="App name"
149+
rootClassName={`${appName?.error ? 'form__input--error' : ''}`}
150+
value={appName.value}
151+
onChange={(e) => handleNameChange(index, e.target.value)}
152+
data-testid="advanced-option-app-name-box"
153+
isRequiredField={true}
154+
error={appName?.error}
155+
additionalErrorInfo={appName?.error && appName?.suggestedName && renderAdditionalErrorInfo(handleNameChange, appName.suggestedName, index)}
156+
/>
152157
</div>}
153158
{handleEnvironmentChange && <div className="flex top mb-16">
154159
<div className="flex column half left top">

src/components/charts/charts.util.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,18 @@ export const QueryParams = {
9999
export const PaginationParams = {
100100
pageOffset: 0,
101101
pageSize: 20
102-
}
102+
}
103+
104+
export const renderAdditionalErrorInfo = (handleNameChange, suggestedName, index) => {
105+
return (
106+
suggestedName && (
107+
<>
108+
. Suggested Name:
109+
<span className="anchor pointer" onClick={(e) => handleNameChange(index, suggestedName)}>
110+
{suggestedName}
111+
{console.log(suggestedName)}
112+
</span>
113+
</>
114+
)
115+
)
116+
}

src/components/charts/modal/ChartGroupBasicDeploy.tsx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ import { CustomInput, DialogForm, DialogFormSubmit, showError } from '@devtron-l
33
import { ProjectType, ChartGroupEntry, EnvironmentType } from '../charts.types';
44
import { ReactComponent as Edit } from '../../../assets/icons/ic-edit.svg';
55
import { ReactComponent as Error } from '../../../assets/icons/ic-warning.svg';
6-
import { styles, smallMenuList, menuList, DropdownIndicator } from '../charts.util';
6+
import { styles, smallMenuList, menuList, DropdownIndicator, renderAdditionalErrorInfo } from '../charts.util';
77
import { Option } from '../../v2/common/ReactSelect.utils';
88
import placeHolder from '../../../assets/icons/ic-plc-chart.svg';
99
import ReactSelect from 'react-select';
1010
import { getEnvironmentListMin } from '../../../services/service';
11-
import { render } from 'react-dom';
1211

1312
interface ChartGroupBasicDeployProps {
1413
projects: ProjectType[];
@@ -197,19 +196,6 @@ function ApplicationNameList({ charts, handleNameChange, showAppNames }) {
197196
listClassNames = `${listClassNames} show`
198197
}
199198

200-
const renderAdditionalErrorInfo = (suggestedName: string, index: number) => {
201-
if (suggestedName) {
202-
return (
203-
<>
204-
. Suggested Name:
205-
<span className="anchor pointer" onClick={(e) => handleNameChange(index, suggestedName)}>
206-
{suggestedName}
207-
</span>
208-
</>
209-
)
210-
}
211-
}
212-
213199
return (
214200
<div
215201
className={listClassNames}>
@@ -235,7 +221,8 @@ function ApplicationNameList({ charts, handleNameChange, showAppNames }) {
235221
handleNameChange(index, event.target.value)
236222
}}
237223
error={chart.name.error}
238-
additionalErrorInfo={renderAdditionalErrorInfo(chart.name.suggestedName, index)}
224+
isRequiredField={true}
225+
additionalErrorInfo={renderAdditionalErrorInfo(handleNameChange, chart.name.suggestedNam, index)}
239226
/>
240227
</div>
241228
</div>

0 commit comments

Comments
 (0)