-
Notifications
You must be signed in to change notification settings - Fork 313
Show confirmation modal when deleting file/directory #366
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
Conversation
web/client/src/api/instance.ts
Outdated
| return { ok: false, detail: 'Empty response' } | ||
| if (response.status === 204) | ||
| return { ok: true, ...(await response.json()) } | ||
| if (response.status > 400) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be >= 400?
| headline, | ||
| tagline, | ||
| description, | ||
| children, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does children need to be in PropsModalConfirmation? Is it already in React.HTMLAttributes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to define children as prop
| } | ||
|
|
||
| export interface WithConfirmation { | ||
| setConfirmation: (confirmation: Confirmation | undefined) => void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the below equivalent?
| setConfirmation: (confirmation: Confirmation | undefined) => void | |
| setConfirmation: (confirmation?: Confirmation) => void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
| project?: DirectoryApi | ||
| }): JSX.Element { | ||
| const directory = useMemo(() => new ModelDirectory(project), [project]) | ||
| const [confirmation, setConfirmation] = useState<Confirmation | undefined>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Confirmation a type and/or an interface? Can you create an instance of it? Does this mean confirmation can also be undefined? Can it also be null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmation is an interface it only has meaning to typescript and we cant create an instance from typescript interfaces.
so confirmation is just optional and should be either object -> Confirmation or undefined from typescript point of view it should not be a null but at runtime it can be null it wont break or show an error
| }): JSX.Element { | ||
| const directory = useMemo(() => new ModelDirectory(project), [project]) | ||
| const [confirmation, setConfirmation] = useState<Confirmation | undefined>() | ||
| const [showCofirmation, setShowConfirmation] = useState(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const [showCofirmation, setShowConfirmation] = useState(false) | |
| const [showConfirmation, setShowConfirmation] = useState(false) |
| .then(created => { | ||
| if (isFalse((created as any).ok)) { | ||
| console.warn([ | ||
| `Diroctory: ${directory.path}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `Diroctory: ${directory.path}`, | |
| `Directory: ${directory.path}`, |
| .then(response => { | ||
| if (isFalse((response as any).ok)) { | ||
| console.warn([ | ||
| `Diroctory: ${directory.path}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `Diroctory: ${directory.path}`, | |
| `Directory: ${directory.path}`, |
| setConfirmation({ | ||
| headline: 'Removing Directory', | ||
| description: `Are you sure you want to remove the directory "${directory.name}"?`, | ||
| yesText: 'Yes, Remove', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this looks better?
| yesText: 'Yes, Remove', | |
| yesText: 'Yes, remove.', |
No description provided.