Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Loading Indicator in Folder Creation and Restrict Empty Folder Names #1318

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions components/folders/add-folder-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,13 @@ export function AddFolderModal({
}
}

const clearModelState = () => {
setOpen(!open);
folderName !== null && setFolderName("");
};

return (
<Dialog open={open} onOpenChange={setOpen}>
<Dialog open={open} onOpenChange={clearModelState}>
<DialogTrigger asChild>{children}</DialogTrigger>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader className="text-start">
Expand All @@ -134,10 +139,16 @@ export function AddFolderModal({
placeholder="folder-123"
className="mb-4 mt-1 w-full"
onChange={(e) => setFolderName(e.target.value)}
value={folderName || ""}
/>
<DialogFooter>
<Button type="submit" className="h-9 w-full">
Add new folder
<Button
type="submit"
className="h-9 w-full"
disabled={folderName?.trim() == "" || loading}
loading={loading}
>
{loading ? "Adding..." : "Add new folder"}
</Button>
</DialogFooter>
</form>
Expand Down
18 changes: 14 additions & 4 deletions components/folders/edit-folder-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,13 @@ export function EditFolderModal({
}
};

const clearModelState = () => {
setOpen(!open);
folderName !== null && setFolderName("");
};

return (
<Dialog open={open} onOpenChange={setOpen}>
<Dialog open={open} onOpenChange={clearModelState}>
<DialogTrigger asChild>{children}</DialogTrigger>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader className="text-start">
Expand All @@ -108,14 +113,19 @@ export function EditFolderModal({
</Label>
<Input
id="folder-name-update"
value={folderName}
value={folderName || ""}
placeholder="folder-123"
className="mb-4 mt-1 w-full"
onChange={(e) => setFolderName(e.target.value)}
/>
<DialogFooter>
<Button type="submit" className="h-9 w-full" loading={loading}>
Update folder
<Button
type="submit"
className="h-9 w-full"
loading={loading}
disabled={folderName?.trim() == "" || loading}
>
{loading? "Updating":"Update folder"}
</Button>
</DialogFooter>
</form>
Expand Down
Loading