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

Drag'n'drop added/existing file entries, add empty folder #3999

Merged
merged 4 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions catalog/app/components/Dialog/Confirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ interface PromptProps {
title: string
}

// TODO: Re-use utils/Dialog
export function useConfirm({ cancelTitle, title, onSubmit, submitTitle }: PromptProps) {
const [key, setKey] = React.useState(0)
const [opened, setOpened] = React.useState(false)
Expand Down
25 changes: 21 additions & 4 deletions catalog/app/components/Dialog/Prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@
import * as Lab from '@material-ui/lab'

interface DialogProps {
children: React.ReactNode
initialValue?: string
onCancel: () => void
onSubmit: (value: string) => void
open: boolean
placeholder?: string
title: string
validate: (value: string) => Error | undefined
}

function Dialog({
children,

Check warning on line 18 in catalog/app/components/Dialog/Prompt.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Dialog/Prompt.tsx#L18

Added line #L18 was not covered by tests
initialValue,
open,
onCancel,
onSubmit,
open,
placeholder,

Check warning on line 23 in catalog/app/components/Dialog/Prompt.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Dialog/Prompt.tsx#L22-L23

Added lines #L22 - L23 were not covered by tests
title,
validate,
}: DialogProps) {
Expand All @@ -26,6 +30,7 @@
const handleChange = React.useCallback((event) => setValue(event.target.value), [])
const handleSubmit = React.useCallback(
(event) => {
event.stopPropagation()

Check warning on line 33 in catalog/app/components/Dialog/Prompt.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Dialog/Prompt.tsx#L33

Added line #L33 was not covered by tests
event.preventDefault()
setSubmitted(true)
if (!error) onSubmit(value)
Expand All @@ -37,11 +42,13 @@
<form onSubmit={handleSubmit}>
<M.DialogTitle>{title}</M.DialogTitle>
<M.DialogContent>
{children}
<M.TextField
autoFocus
fullWidth
margin="dense"
onChange={handleChange}
placeholder={placeholder}
value={value}
/>
{!!error && !!submitted && (
Expand Down Expand Up @@ -69,11 +76,19 @@
interface PromptProps {
initialValue?: string
onSubmit: (value: string) => void
placeholder?: string
title: string
validate: (value: string) => Error | undefined
}

export function usePrompt({ initialValue, title, onSubmit, validate }: PromptProps) {
// TODO: Re-use utils/Dialog
export function usePrompt({
onSubmit,
initialValue,
placeholder,
validate,
title,
}: PromptProps) {

Check warning on line 91 in catalog/app/components/Dialog/Prompt.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Dialog/Prompt.tsx#L85-L91

Added lines #L85 - L91 were not covered by tests
const [key, setKey] = React.useState(0)
const [opened, setOpened] = React.useState(false)
const open = React.useCallback(() => {
Expand All @@ -89,20 +104,22 @@
[close, onSubmit],
)
const render = React.useCallback(
() => (
(children?: React.ReactNode) => (

Check warning on line 107 in catalog/app/components/Dialog/Prompt.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Dialog/Prompt.tsx#L107

Added line #L107 was not covered by tests
<Dialog
{...{
children,
initialValue,
key,
onCancel: close,
onSubmit: handleSubmit,
open: opened,
placeholder,
title,
validate,
}}
/>
),
[initialValue, key, close, handleSubmit, opened, title, validate],
[close, handleSubmit, initialValue, key, opened, placeholder, title, validate],
)
return React.useMemo(
() => ({
Expand Down
Loading
Loading