-
Notifications
You must be signed in to change notification settings - Fork 2k
Hosting Dashboard: Add domain glue records add/edit screen #105213
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
19 commits
Select commit
Hold shift + click to select a range
b71e67a
Add glue records creation form
m1r0 241d94f
Fix text case
m1r0 1768cff
Add glue records edit form
m1r0 8d32de8
Switch to `ValidatedInputControl` for the name server input
m1r0 2278bed
Add a variable for the suffix value
m1r0 74a78ce
Fix the placeholder value to make it consistent
m1r0 378a238
Update the client before invalidating the queries
m1r0 25514be
Replace `useRoute` with `useNavigate`
m1r0 12ccb26
Switch to the `useSuspenseQuery` hook
m1r0 1755dbb
Move the 404 redirect to the router
m1r0 2c77a36
Move the util helpers
m1r0 eafbe78
Fix missing `useMemo` dependency
m1r0 2b0417e
Cleanup glue record transform duplication
m1r0 e3b69bd
Rename `overview-glue-records` to `domain-glue-records`
m1r0 973aaee
Disable the submit button when form is invalid
m1r0 75d9dee
Replace `ValidatedInputControl` with `InputControl`
m1r0 047484e
Fix domain router imports
m1r0 1a57c05
Improve mutation types
m1r0 b57c72e
Fix missing useMemo dependencies
m1r0 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
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 |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { useMutation } from '@tanstack/react-query'; | ||
| import { useNavigate } from '@tanstack/react-router'; | ||
| import { useDispatch } from '@wordpress/data'; | ||
| import { __ } from '@wordpress/i18n'; | ||
| import { store as noticesStore } from '@wordpress/notices'; | ||
| import { domainGlueRecordCreateMutation } from '../../app/queries/domain-glue-records'; | ||
| import { domainRoute, domainGlueRecordsRoute } from '../../app/router/domains'; | ||
| import { PageHeader } from '../../components/page-header'; | ||
| import PageLayout from '../../components/page-layout'; | ||
| import { DomainGlueRecord } from '../../data/domain-glue-records'; | ||
| import DomainGlueRecordsForm from './form'; | ||
|
|
||
| export default function AddDomainGlueRecords() { | ||
| const navigate = useNavigate(); | ||
| const { domainName } = domainRoute.useParams(); | ||
| const createMutation = useMutation( domainGlueRecordCreateMutation( domainName ) ); | ||
| const { createSuccessNotice, createErrorNotice } = useDispatch( noticesStore ); | ||
|
|
||
| const handleSubmit = ( glueRecord: DomainGlueRecord ) => { | ||
| createMutation.mutate( glueRecord, { | ||
| onSuccess: () => { | ||
| createSuccessNotice( __( 'Glue record created successfully.' ), { | ||
| type: 'snackbar', | ||
| } ); | ||
| navigate( { | ||
| to: domainGlueRecordsRoute.fullPath, | ||
| params: { domainName }, | ||
| } ); | ||
| }, | ||
| onError: () => { | ||
| createErrorNotice( __( 'Failed to create glue record.' ), { type: 'snackbar' } ); | ||
| }, | ||
| } ); | ||
| }; | ||
|
|
||
| return ( | ||
| <PageLayout size="small" header={ <PageHeader title={ __( 'Add glue record' ) } /> }> | ||
| <DomainGlueRecordsForm | ||
| domainName={ domainName } | ||
| onSubmit={ handleSubmit } | ||
| isSubmitting={ createMutation.isPending } | ||
| submitButtonText={ __( 'Add record' ) } | ||
| /> | ||
| </PageLayout> | ||
| ); | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { useSuspenseQuery, useMutation } from '@tanstack/react-query'; | ||
| import { useNavigate } from '@tanstack/react-router'; | ||
| import { useDispatch } from '@wordpress/data'; | ||
| import { __ } from '@wordpress/i18n'; | ||
| import { store as noticesStore } from '@wordpress/notices'; | ||
| import { | ||
| domainGlueRecordsQuery, | ||
| domainGlueRecordUpdateMutation, | ||
| } from '../../app/queries/domain-glue-records'; | ||
| import { domainRoute, domainGlueRecordsRoute } from '../../app/router/domains'; | ||
| import { PageHeader } from '../../components/page-header'; | ||
| import PageLayout from '../../components/page-layout'; | ||
| import { DomainGlueRecord } from '../../data/domain-glue-records'; | ||
| import DomainGlueRecordsForm from './form'; | ||
|
|
||
| export default function EditDomainGlueRecords() { | ||
| const navigate = useNavigate(); | ||
| const { domainName, nameServer } = domainRoute.useParams(); | ||
| const { data: glueRecordsData } = useSuspenseQuery( domainGlueRecordsQuery( domainName ) ); | ||
| const updateMutation = useMutation( domainGlueRecordUpdateMutation( domainName ) ); | ||
| const { createSuccessNotice, createErrorNotice } = useDispatch( noticesStore ); | ||
| const glueRecord = glueRecordsData.find( | ||
| ( glueRecord: DomainGlueRecord ) => glueRecord.nameserver === nameServer | ||
| ); | ||
|
|
||
| const handleSubmit = ( updatedGlueRecord: DomainGlueRecord ) => { | ||
| updateMutation.mutate( updatedGlueRecord, { | ||
| onSuccess: () => { | ||
| createSuccessNotice( __( 'Glue record updated successfully.' ), { | ||
| type: 'snackbar', | ||
| } ); | ||
| navigate( { | ||
| to: domainGlueRecordsRoute.fullPath, | ||
| params: { domainName }, | ||
| } ); | ||
| }, | ||
| onError: () => { | ||
| createErrorNotice( __( 'Failed to update glue record.' ), { type: 'snackbar' } ); | ||
| }, | ||
| } ); | ||
| }; | ||
|
|
||
| return ( | ||
| <PageLayout size="small" header={ <PageHeader title={ __( 'Edit glue record' ) } /> }> | ||
| <DomainGlueRecordsForm | ||
| domainName={ domainName } | ||
| initialData={ glueRecord } | ||
| onSubmit={ handleSubmit } | ||
| isSubmitting={ updateMutation.isPending } | ||
| isEdit | ||
| submitButtonText={ __( 'Update glue record' ) } | ||
| /> | ||
| </PageLayout> | ||
| ); | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.