diff --git a/packages/amplication-client/src/Project/ArchitectureConsole/ApplyChangesNextSteps.tsx b/packages/amplication-client/src/Project/ArchitectureConsole/ApplyChangesNextSteps.tsx index f32f2db7a5..85ac62cb35 100644 --- a/packages/amplication-client/src/Project/ArchitectureConsole/ApplyChangesNextSteps.tsx +++ b/packages/amplication-client/src/Project/ArchitectureConsole/ApplyChangesNextSteps.tsx @@ -22,10 +22,12 @@ const className = "apply-changes-next-steps"; type Props = { onDisplayArchitectureClicked: () => void; + onCommitChangesError: () => void; }; export const ApplyChangesNextSteps = ({ onDisplayArchitectureClicked, + onCommitChangesError, }: Props) => { const history = useHistory(); const { currentWorkspace, currentProject, isPreviewPlan } = @@ -65,9 +67,9 @@ export const ApplyChangesNextSteps = ({ showCommitMessage={false} commitMessage="Architecture redesign" commitBtnType={CommitBtnType.JumboButton} + onCommitChangesError={onCommitChangesError} > )} - (false); + const [keepLoadingChanges, setKeepLoadingChanges] = useState(false); + const [commitChangesError, setCommitChangesError] = useState(false); + const history = useHistory(); + + const handleCommitChangesError = useCallback(() => { + setCommitChangesError(true); + }, [setCommitChangesError]); + + const bypassLimitations = useMemo(() => { + return ( + currentWorkspace?.subscription?.subscriptionPlan !== + models.EnumSubscriptionPlan.Pro + ); + }, [currentWorkspace]); + + const redirectToPurchase = () => { + const path = `/${currentWorkspace?.id}/purchase`; + history.push(path, { from: { pathname: history.location.pathname } }); + }; + const movedEntities = useMemo(() => { const movedEntities: movedEntitiesData[] = []; nodes @@ -78,6 +114,32 @@ export default function ModelOrganizerConfirmation({ setApplyChangesSteps(true); }, [setKeepLoadingChanges, setApplyChangesSteps]); + const [commit] = useMutation(COMMIT_CHANGES, { + onCompleted: (response) => { + setCommitRunning(false); + setCommitChangesError(false); + resetPendingChanges(); + commitUtils.refetchCommitsData(true); + const path = commitPath( + currentWorkspace?.id, + currentProject?.id, + response.commit.id + ); + return history.push(path); + }, + }); + + const handleOnBypassClicked = useCallback(() => { + setCommitRunning(true); + commit({ + variables: { + message: "Architecture redesign", + projectId: currentProject?.id, + bypassLimitations: true, + }, + }).catch(console.error); + }, [setCommitRunning, commit, currentProject?.id]); + const ActionStep = applyChangesData?.action?.steps?.length ? applyChangesData?.action?.steps[0] : null; @@ -142,8 +204,48 @@ export default function ModelOrganizerConfirmation({ - ) : applyChangesSteps ? ( - + ) : applyChangesSteps && !commitChangesError ? ( + + ) : commitChangesError ? ( + <> + + + Your workspace exceeds its resource limitation. Please contact us + to upgrade + + + Please contact us to upgrade + + + + + {bypassLimitations && ( + + )} + + ) : !applyChangesSteps ? ( <> {changes?.newServices?.length > 0 && ( diff --git a/packages/amplication-client/src/VersionControl/Commit.tsx b/packages/amplication-client/src/VersionControl/Commit.tsx index 52e036abb3..00bdcbb189 100644 --- a/packages/amplication-client/src/VersionControl/Commit.tsx +++ b/packages/amplication-client/src/VersionControl/Commit.tsx @@ -42,6 +42,7 @@ type Props = { showCommitMessage?: boolean; commitMessage?: string; commitBtnType: CommitBtnType; + onCommitChangesError?: () => void; }; const CLASS_NAME = "commit"; @@ -75,6 +76,7 @@ const Commit = ({ commitBtnType, showCommitMessage = true, commitMessage, + onCommitChangesError, }: Props) => { const history = useHistory(); const { trackEvent } = useTracking(); @@ -100,6 +102,10 @@ const Commit = ({ onError: (error: ApolloError) => { setCommitRunning(false); setPendingChangesError(true); + if (onCommitChangesError) { + onCommitChangesError(); + return; + } setOpenLimitationDialog( error?.graphQLErrors?.some(