From 57170847a13a8c80dbb95fdd0da9d790c58b34f3 Mon Sep 17 00:00:00 2001 From: ajnart Date: Tue, 21 Jun 2022 19:22:14 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Allow=20anything=20in=20the=20in?= =?UTF-8?q?put=20for=20the=20form.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If it works, it works. Fixes #256 --- src/components/AppShelf/AddAppShelfItem.tsx | 126 ++++++++++---------- 1 file changed, 61 insertions(+), 65 deletions(-) diff --git a/src/components/AppShelf/AddAppShelfItem.tsx b/src/components/AppShelf/AddAppShelfItem.tsx index c4db0df50..206cb5ee4 100644 --- a/src/components/AppShelf/AddAppShelfItem.tsx +++ b/src/components/AppShelf/AddAppShelfItem.tsx @@ -123,13 +123,9 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & validate: { apiKey: () => null, // Validate icon with a regex - icon: (value: string) => { - // Regex to match everything that ends with and icon extension - if (!value.match(/\.(png|jpg|jpeg|gif|svg)$/)) { - return 'Please enter a valid icon URL'; - } - return null; - }, + icon: (value: string) => + // Disable matching to allow any values + null, // Validate url with a regex http/https url: (value: string) => { try { @@ -298,64 +294,64 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & )} {form.values.type === 'qBittorrent' && ( - <> - { - form.setFieldValue('username', event.currentTarget.value); - }} - error={form.errors.username && 'Invalid username'} - /> - { - form.setFieldValue('password', event.currentTarget.value); - }} - error={form.errors.password && 'Invalid password'} - /> - - )} - {form.values.type === 'Deluge' && ( - <> - { - form.setFieldValue('password', event.currentTarget.value); - }} - error={form.errors.password && 'Invalid password'} - /> - - )} - {form.values.type === 'Transmission' && ( - <> - { - form.setFieldValue('username', event.currentTarget.value); - }} - error={form.errors.username && 'Invalid username'} - /> - { - form.setFieldValue('password', event.currentTarget.value); - }} - error={form.errors.password && 'Invalid password'} - /> - - )} + <> + { + form.setFieldValue('username', event.currentTarget.value); + }} + error={form.errors.username && 'Invalid username'} + /> + { + form.setFieldValue('password', event.currentTarget.value); + }} + error={form.errors.password && 'Invalid password'} + /> + + )} + {form.values.type === 'Deluge' && ( + <> + { + form.setFieldValue('password', event.currentTarget.value); + }} + error={form.errors.password && 'Invalid password'} + /> + + )} + {form.values.type === 'Transmission' && ( + <> + { + form.setFieldValue('username', event.currentTarget.value); + }} + error={form.errors.username && 'Invalid username'} + /> + { + form.setFieldValue('password', event.currentTarget.value); + }} + error={form.errors.password && 'Invalid password'} + /> + + )}