Undo formatting changes

This commit is contained in:
Phil
2024-06-02 11:03:34 -06:00
parent fc67def501
commit d393cdfd21
2 changed files with 81 additions and 82 deletions
+43 -45
View File
@@ -127,7 +127,8 @@ const BookmarkForm = () => {
useEffect(() => {
const syncBookmarks = async () => {
try {
const { syncBookmarks, baseUrl, defaultCollection } = await getConfig();
const { syncBookmarks, baseUrl, defaultCollection } =
await getConfig();
form.setValue('collection', {
name: defaultCollection,
});
@@ -137,6 +138,7 @@ const BookmarkForm = () => {
if (await isConfigured()) {
await saveLinksInCache(baseUrl);
//await syncLocalBookmarks(baseUrl);
}
} catch (error) {
console.error(error);
@@ -184,19 +186,19 @@ const BookmarkForm = () => {
return (
<div>
<Form {...form}>
<form onSubmit={handleSubmit((e) => onSubmit(e))} className="py-1">
<form onSubmit={handleSubmit((e) => onSubmit(e))} className='py-1'>
{collectionError ? (
<p className="text-red-600">
<p className='text-red-600'>
There was an error, please make sure the website is available.
</p>
) : null}
<FormField
control={control}
name="collection"
name='collection'
render={({ field }) => (
<FormItem className={`my-2`}>
<FormLabel>Collection</FormLabel>
<div className="min-w-full inset-x-0">
<div className='min-w-full inset-x-0'>
<Popover
open={openCollections}
onOpenChange={setOpenCollections}
@@ -204,23 +206,23 @@ const BookmarkForm = () => {
<PopoverTrigger asChild>
<FormControl>
<Button
variant="outline"
role="combobox"
variant='outline'
role='combobox'
aria-expanded={openCollections}
className={cn(
'w-full justify-between',
!field.value?.name && 'text-muted-foreground'
!field.value?.name && 'text-muted-foreground',
)}
>
{loadingCollections
? 'Loading'
: field.value?.name
? collections?.find(
(collection: { name: string }) =>
collection.name === field.value?.name
)?.name || form.getValues('collection')?.name
: 'Select a collection...'}
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
? collections?.find(
(collection: { name: string }) =>
collection.name === field.value?.name,
)?.name || form.getValues('collection')?.name
: 'Select a collection...'}
<CaretSortIcon className='ml-2 h-4 w-4 shrink-0 opacity-50' />
</Button>
</FormControl>
</PopoverTrigger>
@@ -234,23 +236,23 @@ const BookmarkForm = () => {
}`}
>
<Button
className="absolute top-1 right-1 bg-transparent hover:bg-transparent hover:opacity-50 transition-colors ease-in-out duration-200"
className='absolute top-1 right-1 bg-transparent hover:bg-transparent hover:opacity-50 transition-colors ease-in-out duration-200'
onClick={() => setOpenCollections(false)}
>
<X className={`h-4 w-4 text-black dark:text-white`} />
</Button>
<Command className="flex-grow min-w-full dropdown-content rounded-none">
<Command className='flex-grow min-w-full dropdown-content rounded-none'>
<CommandInput
className="min-w-[280px]"
placeholder="Search Collection..."
className='min-w-[280px]'
placeholder='Search Collection...'
/>
<CommandEmpty>No Collection found.</CommandEmpty>
{Array.isArray(collections) && (
<CommandGroup className="w-full overflow-y-auto">
<CommandGroup className='w-full overflow-y-auto'>
{isLoading ? (
<CommandItem
value="Getting collections..."
key="Getting collections..."
value='Getting collections...'
key='Getting collections...'
onSelect={() => {
form.setValue('collection', {
name: 'Unorganized',
@@ -270,7 +272,7 @@ const BookmarkForm = () => {
<CommandItem
value={collection.name}
key={collection.id}
className="cursor-pointer"
className='cursor-pointer'
onSelect={() => {
form.setValue('collection', {
ownerId: collection.ownerId,
@@ -282,7 +284,7 @@ const BookmarkForm = () => {
>
{collection.name}
</CommandItem>
)
),
)
)}
</CommandGroup>
@@ -293,18 +295,18 @@ const BookmarkForm = () => {
<PopoverContent
className={`min-w-full p-0 overflow-y-auto max-h-[200px]`}
>
<Command className="flex-grow min-w-full dropdown-content">
<Command className='flex-grow min-w-full dropdown-content'>
<CommandInput
className="min-w-[280px]"
placeholder="Search collection..."
className='min-w-[280px]'
placeholder='Search collection...'
/>
<CommandEmpty>No Collection found.</CommandEmpty>
{Array.isArray(collections) && (
<CommandGroup className="w-full">
<CommandGroup className='w-full'>
{isLoading ? (
<CommandItem
value="Getting collections..."
key="Getting collections..."
value='Getting collections...'
key='Getting collections...'
onSelect={() => {
form.setValue('collection', {
name: 'Unorganized',
@@ -335,7 +337,7 @@ const BookmarkForm = () => {
>
{collection.name}
</CommandItem>
)
),
)
)}
</CommandGroup>
@@ -405,11 +407,11 @@ const BookmarkForm = () => {
)}
/>
{openOptions ? (
<div className="details list-none space-y-5 pt-2">
<div className='details list-none space-y-5 pt-2'>
{tagsError ? <p>There was an error...</p> : null}
<FormField
control={control}
name="tags"
name='tags'
render={({ field }) => (
<FormItem>
<FormLabel>Tags</FormLabel>
@@ -438,12 +440,12 @@ const BookmarkForm = () => {
/>
<FormField
control={control}
name="name"
name='name'
render={({ field }) => (
<FormItem>
<FormLabel>Name</FormLabel>
<FormControl>
<Input placeholder="Google..." {...field} />
<Input placeholder='Google...' {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -451,12 +453,12 @@ const BookmarkForm = () => {
/>
<FormField
control={control}
name="description"
name='description'
render={({ field }) => (
<FormItem>
<FormLabel>Description</FormLabel>
<FormControl>
<Textarea placeholder="Description..." {...field} />
<Textarea placeholder='Description...' {...field} />
</FormControl>
<FormMessage />
</FormItem>
@@ -464,22 +466,18 @@ const BookmarkForm = () => {
/>
</div>
) : undefined}
{duplicated && (
<p className="text-muted text-zinc-600">
This bookmark is already on Linkwarden
</p>
)}
<div className="flex justify-between items-center mt-4">
{duplicated && <p className='text-muted text-zinc-600'>This bookmark is already on Linkwarden</p>}
<div className='flex justify-between items-center mt-4'>
<div
className="inline-flex select-none items-center justify-center rounded-md text-sm font-medium ring-offset-background
className='inline-flex select-none items-center justify-center rounded-md text-sm font-medium ring-offset-background
transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring
focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50
hover:bg-accent hover:text-accent-foreground hover:cursor-pointer p-2"
hover:bg-accent hover:text-accent-foreground hover:cursor-pointer p-2'
onClick={() => setOpenOptions((prevState) => !prevState)}
>
{openOptions ? 'Hide' : 'More'} Options
</div>
<Button disabled={isLoading} type="submit">
<Button disabled={isLoading} type='submit'>
Save
</Button>
</div>
+38 -37
View File
@@ -59,7 +59,7 @@ const OptionsForm = () => {
toast({
title: 'Error',
description:
"Either you didn't configure the extension or there was an error while trying to log out. Please try again.",
'Either you didn\'t configure the extension or there was an error while trying to log out. Please try again.',
variant: 'destructive',
});
return;
@@ -147,11 +147,11 @@ const OptionsForm = () => {
<Form {...form}>
<form
onSubmit={handleSubmit((e) => onSubmit(e))}
className="space-y-3 p-2"
className='space-y-3 p-2'
>
<FormField
control={control}
name="baseUrl"
name='baseUrl'
render={({ field }) => (
<FormItem>
<FormLabel>URL</FormLabel>
@@ -160,7 +160,7 @@ const OptionsForm = () => {
</FormDescription>
<FormControl>
<Input
placeholder="https://cloud.linkwarden.app"
placeholder='https://cloud.linkwarden.app'
{...field}
/>
</FormControl>
@@ -170,7 +170,7 @@ const OptionsForm = () => {
/>
<FormField
control={control}
name="defaultCollection"
name='defaultCollection'
render={({ field }) => (
<FormItem>
<FormLabel>Default collection</FormLabel>
@@ -178,7 +178,10 @@ const OptionsForm = () => {
Default collection to add bookmarks to.
</FormDescription>
<FormControl>
<Input placeholder="Unorganized" {...field} />
<Input
placeholder='Unorganized'
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
@@ -219,7 +222,29 @@ const OptionsForm = () => {
*/}
<FormField
control={control}
name="apiKey"
name="defaultExpanded"
render={({ field }) => (
<FormItem>
<div className="flex gap-1 items-center">
<FormControl>
<Checkbox
checked={field.value as boolean}
onCheckedChange={field.onChange}
/>
</FormControl>
<FormLabel>Show options in popup</FormLabel>
</div>
<FormDescription>
Show all options in the popup form by default.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={control}
name='apiKey'
render={({ field }) => (
<FormItem>
<FormLabel>API KEY</FormLabel>
@@ -228,10 +253,8 @@ const OptionsForm = () => {
</FormDescription>
<FormControl>
<Input
placeholder="eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..mkTNGkl3kXDjYb54.XA29mauKrHSqwGgBk1Zb2hanecG8_c9MVPI_qv7Ge1k-UYLG5Arag5eXfVYGacu3RqVCci4NZgsBH6r16QZ5rhRzGmwkSv_PGNNzfqbAWi4k9Em8KYkc.wAZ64-qx9DaGSr0gqShnrQ"
{...field}
type="text"
/>
placeholder='eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..mkTNGkl3kXDjYb54.XA29mauKrHSqwGgBk1Zb2hanecG8_c9MVPI_qv7Ge1k-UYLG5Arag5eXfVYGacu3RqVCci4NZgsBH6r16QZ5rhRzGmwkSv_PGNNzfqbAWi4k9Em8KYkc.wAZ64-qx9DaGSr0gqShnrQ' {...field}
type='text' />
</FormControl>
<FormMessage />
</FormItem>
@@ -279,42 +302,20 @@ const OptionsForm = () => {
</FormItem>
)}
/>*/}
<FormField
control={control}
name="defaultExpanded"
render={({ field }) => (
<FormItem>
<div className="flex gap-1 items-center">
<FormControl>
<Checkbox
checked={field.value as boolean}
onCheckedChange={field.onChange}
/>
</FormControl>
<FormLabel>Show options in popup</FormLabel>
</div>
<FormDescription>
Show all options in the popup form by default.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<div className="flex justify-between">
<div className='flex justify-between'>
<div>
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
{/*@ts-ignore*/}
<Button
type="button"
className="mb-2"
type='button'
className='mb-2'
onClick={onReset as never}
disabled={resetLoading}
>
Reset
</Button>
</div>
<Button disabled={isLoading} type="submit">
<Button disabled={isLoading} type='submit'>
Save
</Button>
</div>