Skip to content

Commit

Permalink
fix: update write api token flow
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Jan 24, 2024
1 parent 1424963 commit 8f8bdc4
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { useWriteAPITokenActions } from "../useWriteAPITokenActions";

import * as styles from "./ConnectGitRepository.module.css";

const GITHUB_APP_SLUG = "prismic-prod-internal-test";

// TODO: Export types from `@slicemachine/manager`
type GitOwner = Awaited<
ReturnType<(typeof managerClient)["git"]["fetchOwners"]>
Expand All @@ -54,7 +56,7 @@ function ConnectButton(props: ConnectButtonBaseProps) {
const state = await managerClient.git.createGitHubAuthState();

const url = new URL(
"https://github.com/apps/prismic-push-models-poc/installations/new",
`https://github.com/apps/${GITHUB_APP_SLUG}/installations/new`,
);
url.searchParams.set("state", state.key);

Expand Down Expand Up @@ -240,6 +242,7 @@ function UpdateOrDeleteWriteAPIForm(props: UpdateOrDeleteWriteAPIFormProps) {
repo={repo}
withCancel={true}
onCancel={() => setIsUpdating(false)}
onSuccess={() => setIsUpdating(false)}
/>
) : (
<div>
Expand All @@ -260,10 +263,11 @@ type UpdateWriteAPIFormProps = {
};
withCancel?: boolean;
onCancel?: () => void | Promise<void>;
onSuccess?: () => void | Promise<void>;
};

function UpdateWriteAPIForm(props: UpdateWriteAPIFormProps) {
const { repo, withCancel, onCancel } = props;
const { repo, withCancel, onCancel, onSuccess } = props;

const { updateToken } = useWriteAPITokenActions({ git: repo });

Expand All @@ -274,6 +278,7 @@ function UpdateWriteAPIForm(props: UpdateWriteAPIFormProps) {
if (token) {
setIsSubmitting(true);
await updateToken(token);
await onSuccess?.();
}
};

Expand Down

0 comments on commit 8f8bdc4

Please sign in to comment.