-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix: issue and module link validation #5994
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,6 @@ import { Controller, useForm } from "react-hook-form"; | |
| import type { TIssueLinkEditableFields } from "@plane/types"; | ||
| // plane ui | ||
| import { Button, Input, ModalCore } from "@plane/ui"; | ||
| // helpers | ||
| import { checkURLValidity } from "@/helpers/string.helper"; | ||
| // hooks | ||
| import { useIssueDetail } from "@/hooks/store"; | ||
| // types | ||
|
|
@@ -48,14 +46,18 @@ export const IssueLinkCreateUpdateModal: FC<TIssueLinkCreateEditModal> = observe | |
|
|
||
| const onClose = () => { | ||
| setIssueLinkData(null); | ||
| reset(); | ||
| if (handleOnClose) handleOnClose(); | ||
| }; | ||
|
|
||
| const handleFormSubmit = async (formData: TIssueLinkCreateFormFieldOptions) => { | ||
| if (!formData || !formData.id) await linkOperations.create({ title: formData.title, url: formData.url }); | ||
| else await linkOperations.update(formData.id as string, { title: formData.title, url: formData.url }); | ||
| onClose(); | ||
| const parsedUrl = formData.url.startsWith("http") ? formData.url : `http://${formData.url}`; | ||
| try { | ||
| if (!formData || !formData.id) await linkOperations.create({ title: formData.title, url: parsedUrl }); | ||
| else await linkOperations.update(formData.id, { title: formData.title, url: parsedUrl }); | ||
| onClose(); | ||
| } catch (error) { | ||
| console.error("error", error); | ||
| } | ||
|
Comment on lines
+54
to
+60
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve error handling and user feedback The current implementation silently fails by only logging to console. Users should be notified when operations fail. try {
if (!formData || !formData.id) await linkOperations.create({ title: formData.title, url: parsedUrl });
else await linkOperations.update(formData.id, { title: formData.title, url: parsedUrl });
onClose();
} catch (error) {
- console.error("error", error);
+ console.error("Failed to save link:", error);
+ // Assuming you have a toast notification system
+ toast.error(
+ error instanceof Error
+ ? error.message
+ : "Failed to save link. Please try again."
+ );
}
|
||
| }; | ||
|
|
||
| useEffect(() => { | ||
|
|
@@ -77,7 +79,6 @@ export const IssueLinkCreateUpdateModal: FC<TIssueLinkCreateEditModal> = observe | |
| name="url" | ||
| rules={{ | ||
| required: "URL is required", | ||
| validate: (value) => checkURLValidity(value) || "URL is invalid", | ||
| }} | ||
| render={({ field: { value, onChange, ref } }) => ( | ||
| <Input | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion
Enhance URL protocol validation logic
The current URL processing might miss some edge cases. Consider using the URL constructor for robust URL validation and protocol handling.
📝 Committable suggestion