Skip to content

Commit cb8f265

Browse files
committed
fix: remove empty url preview for edit image form field
1 parent 7f46354 commit cb8f265

File tree

4 files changed

+41
-9
lines changed

4 files changed

+41
-9
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "0.1.8-beta-14",
3+
"version": "0.1.8-beta-24",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Shared/Components/EditImageFormField/EditImageFormField.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { SyntheticEvent, useState } from 'react'
2+
import { toast } from 'react-toastify'
23
import { showError } from '@Common/Helper'
34
import { CustomInput } from '@Common/CustomInput'
45
import { ButtonWithLoader, ImageWithFallback } from '@Shared/Components'
@@ -62,17 +63,20 @@ const EditImageFormField = ({
6263
const handleChange = (event: SyntheticEvent) => {
6364
const { value } = event.target as HTMLInputElement
6465
handleURLChange(value)
65-
handleError(validateURL(value, false).message)
66+
if (value.trim()) {
67+
handleError(validateURL(value, false).message)
68+
}
6669
}
6770

6871
const handlePreviewImage = async () => {
6972
if (!url) {
70-
handleSuccess()
73+
// Not setting the error since can save without image
74+
toast.error('Please enter a valid image URL')
7175
return
7276
}
7377

7478
if (errorMessage) {
75-
showError(errorMessage)
79+
toast.error(errorMessage)
7680
return
7781
}
7882

@@ -151,7 +155,7 @@ const EditImageFormField = ({
151155
<CustomInput
152156
name={`${ariaLabelPrefix} url input`}
153157
label="Image URL"
154-
labelClassName="m-0 dc__required-field fs-13 fw-4 lh-20 cn-7"
158+
labelClassName="m-0 fs-13 fw-4 lh-20 cn-7"
155159
placeholder="Enter image url"
156160
value={url}
157161
onChange={handleChange}

src/Shared/Components/Plugin/service.tsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,33 @@ export const getAvailablePluginTags = async (appId: number): Promise<string[]> =
9696
}
9797
}
9898

99-
export const getParentPluginList = async (appId?: number): Promise<ResponseType<MinParentPluginDTO[]>> =>
100-
get<MinParentPluginDTO[]>(getUrlWithSearchParams(ROUTES.PLUGIN_LIST_MIN, { appId }))
99+
// TODO: Remove this mock data and implement the actual API call
100+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
101+
export const getParentPluginList = async (appId?: number): Promise<ResponseType<MinParentPluginDTO[]>> => {
102+
// get<MinParentPluginDTO[]>(getUrlWithSearchParams(ROUTES.PLUGIN_LIST_MIN, { appId }))
103+
// eslint-disable-next-line no-promise-executor-return
104+
await new Promise((resolve) => setTimeout(resolve, 1000))
105+
const mockData: MinParentPluginDTO[] = [
106+
{
107+
id: 1,
108+
pluginName: 'Mock Plugin 1',
109+
icon: 'https://via.placeholder.com/150',
110+
},
111+
{
112+
id: 2,
113+
pluginName: 'Mock Plugin 2',
114+
icon: 'https://via.placeholder.com/150',
115+
},
116+
{
117+
id: 3,
118+
pluginName: 'Mock Plugin 3',
119+
icon: 'https://via.placeholder.com/150',
120+
},
121+
{
122+
id: 4,
123+
pluginName: 'Mock Plugin 4',
124+
icon: 'https://via.placeholder.com/150',
125+
},
126+
]
127+
return Promise.resolve({ result: mockData, status: 'OK', code: 200 })
128+
}

0 commit comments

Comments
 (0)