-
Notifications
You must be signed in to change notification settings - Fork 39
feat: migrate remaining admin UI components to ConnectRPC #1285
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Pull Request Test Coverage Report for Build 19365674208Details
💛 - Coveralls |
12714e2 to
99894f4
Compare
| import { RQLExportRequest } from "@raystack/proton/frontier"; | ||
|
|
||
| const adminClient = clients.admin({ useBinary: false }); | ||
| const adminClient = clients.admin({ useBinary: true }); |
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.
Why have we changed this?
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.
for smaller network transfers. binary format uses less data.
| onRemove, | ||
| onClose, | ||
| }: RemoveMemberProps) => { | ||
| const [isSubmitting, setIsSubmitting] = 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.
I think we can remove the submitting useState and use the isPending var from useMutation.
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.
good point, let me do that.
| : "Unknown error"; | ||
| toast.error(`Failed to remove member: ${message}`); | ||
| console.error(error); | ||
| } finally { |
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.
Finallly block will also be removed if using isPending.
| FrontierServiceQueries, | ||
| GetProjectRequestSchema, | ||
| ListRolesRequestSchema, | ||
| } from "@raystack/proton/frontier"; |
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.
@raystack/proton/frontier these two imports can be merged.
| console.error(error); | ||
| } finally { | ||
| setIsProjectRolesLoading(false); | ||
| const { data: projectRoles = [], isLoading: isProjectRolesLoading } = useQuery( |
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.
Error handling required.
| SearchOrganizationProjectsResponse_OrganizationProject, | ||
| } from "@raystack/proton/frontier"; | ||
|
|
||
| import { FrontierServiceQueries, UpdateProjectRequestSchema } from "@raystack/proton/frontier"; |
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.
raystack/proton/frontier imports can be merged
| @@ -1,21 +1,23 @@ | |||
| import { DataTable, EmptyState, Flex } from "@raystack/apsara"; | |||
| import type { DataTableQuery, DataTableSort } from "@raystack/apsara"; | |||
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.
raystack/apsara Imports can be merged here
| }, | ||
| ); | ||
|
|
||
| const { data: plans = [], isLoading: isPlansLoading } = useQuery( |
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.
error handling
| console.error(error); | ||
| } finally { | ||
| setIsLoading(false); | ||
| const { data: defaultRoles = [], isLoading: isDefaultRolesLoading } = useQuery( |
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.
same
| }, []); | ||
| ); | ||
|
|
||
| const { data: organizationRoles = [], isLoading: isOrgRolesLoading } = useQuery( |
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.
same
…rontier - useRQL: V1Beta1RQLQuery* → RQLQuery* types - getUserName: V1Beta1User → User type - converBillingAddressToString: BillingAccountAddress → BillingAccount_Address, postal_code → postalCode
dc923ad to
d2bf4b5
Compare
Summary
Migrated admin UI components from REST API (Axios) to ConnectRPC queries and mutations for improved type safety and consistency.
Changes
useQuery,useMutation, anduseInfiniteQueryhooksclients.frontier()andclients.admin()calls with declarative ConnectRPC hooksV1Beta1*to modern types from@raystack/proton/frontierrole_ids→roleIds,postal_code→postalCode)~/api/frontier.ts,~/api/index.ts)Technical Details
create()with RequestSchema types for type-safe request constructionuseInfiniteQueryfor paginated data with RQL supportcreateClient()pattern for imperative calls when hooks aren't suitable (e.g., policy management)Test Plan