Skip to content

Commit

Permalink
web: use reset hook
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Feb 11, 2025
1 parent 2ba3f16 commit 7346087
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions web/src/components/storage/ProposalPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import AddExistingDeviceMenu from "./AddExistingDeviceMenu";
import { IssueSeverity } from "~/types/issues";
import {
useAvailableDevices,
useConfigMutation,
useResetConfigMutation,
useDeprecated,
useDeprecatedChanges,
useReprobeMutation,
Expand All @@ -56,22 +56,8 @@ import { useIssues } from "~/queries/issues";
import { STORAGE as PATHS } from "~/routes/paths";
import { _ } from "~/i18n";

/** @todo Call to an API method to reset the default config instead of setting a config. */
function useResetConfig() {
const { mutate } = useConfigMutation();

return () =>
mutate({
drives: [
{
partitions: [{ search: "*", delete: true }, { generate: "default" }],
},
],
});
}

function ResetEmptyState() {
const reset = useResetConfig();
const { mutate: reset } = useResetConfigMutation();

const description = _(
"The current storage config cannot be edited. Do you want to reset to the default config?",
Expand All @@ -84,7 +70,7 @@ function ResetEmptyState() {
>
<EmptyStateBody>{description}</EmptyStateBody>
<EmptyStateFooter>
<Button variant="secondary" onClick={reset}>
<Button variant="secondary" onClick={() => reset()}>
{_("Reset")}
</Button>
</EmptyStateFooter>
Expand Down Expand Up @@ -140,7 +126,7 @@ type ProposalSectionsProps = {
};

function ProposalSections({ isEditable, isValid }: ProposalSectionsProps): React.ReactNode {
const reset = useResetConfig();
const { mutate: reset } = useResetConfigMutation();

return (
<Grid hasGutter>
Expand All @@ -152,7 +138,7 @@ function ProposalSections({ isEditable, isValid }: ProposalSectionsProps): React
{_(
"The current storage config cannot be edited. Do you want to reset to the default config?",
)}
<Button variant="plain" isInline onClick={reset}>
<Button variant="plain" isInline onClick={() => reset()}>
{_("Reset")}
</Button>
</>
Expand Down

0 comments on commit 7346087

Please sign in to comment.