Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add transition state to staff views modals

dominik-zeglen8359dc1c7142
diff --git a/saleor/static/dashboard-next/components/ActionDialog/ActionDialog.tsx b/saleor/static/dashboard-next/components/ActionDialog/ActionDialog.tsx
index 90005f09d7..e438f77037 100644
--- a/saleor/static/dashboard-next/components/ActionDialog/ActionDialog.tsx
+++ b/saleor/static/dashboard-next/components/ActionDialog/ActionDialog.tsx
@@ -13,7 +13,7 @@ import ConfirmButton, {
} from "../ConfirmButton/ConfirmButton";
interface ActionDialogProps {
- confirmButtonState?: ConfirmButtonTransitionState;
+ confirmButtonState: ConfirmButtonTransitionState;
open: boolean;
title: string;
variant?: string;
diff --git a/saleor/static/dashboard-next/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx b/saleor/static/dashboard-next/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx
index 2de9a88d6d..7a65a27613 100644
--- a/saleor/static/dashboard-next/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx
+++ b/saleor/static/dashboard-next/staff/components/StaffAddMemberDialog/StaffAddMemberDialog.tsx
@@ -8,6 +8,9 @@ import TextField from "@material-ui/core/TextField";
import Typography from "@material-ui/core/Typography";
import * as React from "react";
+import ConfirmButton, {
+ ConfirmButtonTransitionState
+} from "../../../components/ConfirmButton/ConfirmButton";
import { ControlledCheckbox } from "../../../components/ControlledCheckbox";
import Form from "../../../components/Form";
import i18n from "../../../i18n";
@@ -18,6 +21,7 @@ export interface FormData {
fullAccess: boolean;
}
interface StaffAddMemberDialogProps {
+ confirmButtonState: ConfirmButtonTransitionState;
errors: UserError[];
open: boolean;
onClose: () => void;
@@ -43,7 +47,7 @@ const decorate = withStyles(theme => ({
}
}));
const StaffAddMemberDialog = decorate<StaffAddMemberDialogProps>(
- ({ classes, errors, open, onClose, onConfirm }) => (
+ ({ classes, confirmButtonState, errors, open, onClose, onConfirm }) => (
<Dialog open={open}>
<Form errors={errors} initial={initialForm} onSubmit={onConfirm}>
{({ change, data, errors: formErrors, hasChanged }) => (
@@ -82,14 +86,15 @@ const StaffAddMemberDialog = decorate<StaffAddMemberDialogProps>(
<Button onClick={onClose}>
{i18n.t("Cancel", { context: "button" })}
</Button>
- <Button
+ <ConfirmButton
color="primary"
disabled={!hasChanged}
variant="raised"
type="submit"
+ transitionState={confirmButtonState}
>
{i18n.t("Send invite", { context: "button" })}
- </Button>
+ </ConfirmButton>
</DialogActions>
</>
)}
diff --git a/saleor/static/dashboard-next/staff/views/StaffDetails.tsx b/saleor/static/dashboard-next/staff/views/StaffDetails.tsx
index cef2f22219..402a5dac88 100644
--- a/saleor/static/dashboard-next/staff/views/StaffDetails.tsx
+++ b/saleor/static/dashboard-next/staff/views/StaffDetails.tsx
@@ -60,12 +60,17 @@ export const StaffDetails: React.StatelessComponent<OrderListProps> = ({
variables={{ id }}
onCompleted={handleStaffMemberDelete}
>
- {deleteStaffMember => {
+ {(deleteStaffMember, deleteResult) => {
const formTransitionState = getMutationState(
updateResult.called,
updateResult.loading,
maybe(() => updateResult.data.staffUpdate.errors)
);
+ const deleteTransitionState = getMutationState(
+ deleteResult.called,
+ deleteResult.loading,
+ maybe(() => deleteResult.data.staffDelete.errors)
+ );
return (
<>
<WindowTitle title={maybe(() => data.user.email)} />
@@ -96,6 +101,7 @@ export const StaffDetails: React.StatelessComponent<OrderListProps> = ({
<ActionDialog
open={!!match}
title={i18n.t("Remove staff user")}
+ confirmButtonState={deleteTransitionState}
variant="delete"
onClose={() =>
navigate(staffMemberDetailsUrl(id))
diff --git a/saleor/static/dashboard-next/staff/views/StaffList.tsx b/saleor/static/dashboard-next/staff/views/StaffList.tsx
index ff7ab1e770..758a78c234 100644
--- a/saleor/static/dashboard-next/staff/views/StaffList.tsx
+++ b/saleor/static/dashboard-next/staff/views/StaffList.tsx
@@ -5,7 +5,7 @@ import Messages from "../../components/messages";
import Navigator from "../../components/Navigator";
import { createPaginationState, Paginator } from "../../components/Paginator";
import i18n from "../../i18n";
-import { maybe } from "../../misc";
+import { maybe, getMutationState } from "../../misc";
import StaffAddMemberDialog, {
FormData as AddStaffMemberForm
} from "../components/StaffAddMemberDialog";
@@ -69,6 +69,11 @@ export const StaffList: React.StatelessComponent<StaffListProps> = ({
}
}
});
+ const addTransitionState = getMutationState(
+ addStaffMemberData.called,
+ addStaffMemberData.loading,
+ maybe(() => addStaffMemberData.data.staffCreate.errors)
+ );
return (
<Paginator
pageInfo={maybe(() => data.staffUsers.pageInfo)}
@@ -93,6 +98,7 @@ export const StaffList: React.StatelessComponent<StaffListProps> = ({
path={staffMemberAddPath}
render={({ match }) => (
<StaffAddMemberDialog
+ confirmButtonState={addTransitionState}
errors={maybe(
() =>
addStaffMemberData.data.staffCreate
diff --git a/saleor/static/dashboard-next/storybook/stories/components/ActionDialog.tsx b/saleor/static/dashboard-next/storybook/stories/components/ActionDialog.tsx
index 4b06b420fd..6cb2632dca 100644
--- a/saleor/static/dashboard-next/storybook/stories/components/ActionDialog.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/components/ActionDialog.tsx
@@ -12,6 +12,7 @@ storiesOf("Generics / ActionDialog", module)
open={true}
onClose={undefined}
onConfirm={undefined}
+ confirmButtonState="default"
>
Example content
</ActionDialog>