Skip to content

chore(site): replace deployment stats service by react-query #9698

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 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions site/src/api/queries/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ export const deploymentDAUs = () => {
queryFn: () => API.getDeploymentDAUs(),
};
};

export const deploymentStats = () => {
return {
queryKey: ["deployment", "stats"],
queryFn: () => API.getDeploymentStats(),
};
};
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { useMachine } from "@xstate/react";
import { usePermissions } from "hooks/usePermissions";
import { DeploymentBannerView } from "./DeploymentBannerView";
import { deploymentStatsMachine } from "xServices/deploymentStats/deploymentStatsMachine";
import { useQuery } from "@tanstack/react-query";
import { deploymentStats } from "api/queries/deployment";

export const DeploymentBanner: React.FC = () => {
const permissions = usePermissions();
const [state, sendEvent] = useMachine(deploymentStatsMachine);
const deploymentStatsQuery = useQuery(deploymentStats());

if (!permissions.viewDeploymentValues || !state.context.deploymentStats) {
if (!permissions.viewDeploymentValues || !deploymentStatsQuery.data) {
return null;
}

return (
<DeploymentBannerView
stats={state.context.deploymentStats}
fetchStats={() => sendEvent("RELOAD")}
stats={deploymentStatsQuery.data}
fetchStats={() => deploymentStatsQuery.refetch()}
/>
);
};
60 changes: 0 additions & 60 deletions site/src/xServices/deploymentStats/deploymentStatsMachine.ts

This file was deleted.