Skip to content

Commit

Permalink
Refetch setup on button press
Browse files Browse the repository at this point in the history
  • Loading branch information
roaga committed Nov 12, 2024
1 parent 523391a commit c6295fd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
9 changes: 7 additions & 2 deletions static/app/components/events/autofix/autofixDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ interface AutofixDrawerProps {
export function AutofixDrawer({group, project, event}: AutofixDrawerProps) {
const {autofixData, triggerAutofix, reset} = useAiAutofix(group, event);
const {data: summaryData, isError} = useGroupSummary(group.id, group.issueCategory);
const {data: setupData, isPending: isSetupLoading} = useAutofixSetup({
const {
data: setupData,
isPending: isSetupLoading,
refetch: refetchSetup,
} = useAutofixSetup({
groupId: group.id,
});

Expand Down Expand Up @@ -148,7 +152,8 @@ export function AutofixDrawer({group, project, event}: AutofixDrawerProps) {
<AutofixSetupContent
projectId={project.id}
groupId={group.id}
closeModal={() => {}} // Setup is inline, so no modal to close
closeModal={() => {}}
refetchSetup={refetchSetup}
/>
</SetupContainer>
) : !autofixData ? (
Expand Down
19 changes: 16 additions & 3 deletions static/app/components/events/autofix/autofixSetupModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,19 @@ function AutofixGithubIntegrationStep({
canStartAutofix,
closeModal,
isLastStep,
refetchSetup,
}: {
autofixSetup: AutofixSetupResponse;
canStartAutofix: boolean;
closeModal: () => void;
isLastStep?: boolean;
refetchSetup?: () => void;
}) {
const handleClose = () => {
refetchSetup?.();
closeModal();
};

const sortedRepos = useMemo(
() =>
autofixSetup.githubWriteIntegration.repos.toSorted((a, b) => {
Expand Down Expand Up @@ -186,7 +193,7 @@ function AutofixGithubIntegrationStep({
priority="primary"
size="sm"
disabled={!canStartAutofix}
onClick={closeModal}
onClick={handleClose}
>
{t("Let's Go!")}
</Button>
Expand Down Expand Up @@ -227,7 +234,7 @@ function AutofixGithubIntegrationStep({
priority="primary"
size="sm"
disabled={!canStartAutofix}
onClick={closeModal}
onClick={handleClose}
>
{t('Skip & Enable Autofix')}
</Button>
Expand Down Expand Up @@ -262,7 +269,7 @@ function AutofixGithubIntegrationStep({
priority="primary"
size="sm"
disabled={!canStartAutofix}
onClick={closeModal}
onClick={handleClose}
>
{t('Skip & Enable Autofix')}
</Button>
Expand All @@ -276,12 +283,14 @@ function AutofixSetupSteps({
autofixSetup,
closeModal,
canStartAutofix,
refetchSetup,
}: {
autofixSetup: AutofixSetupResponse;
canStartAutofix: boolean;
closeModal: () => void;
groupId: string;
projectId: string;
refetchSetup?: () => void;
}) {
return (
<GuidedSteps>
Expand All @@ -304,6 +313,7 @@ function AutofixSetupSteps({
canStartAutofix={canStartAutofix}
closeModal={closeModal}
isLastStep
refetchSetup={refetchSetup}
/>
</GuidedSteps.Step>
</GuidedSteps>
Expand All @@ -314,10 +324,12 @@ export function AutofixSetupContent({
projectId,
groupId,
closeModal,
refetchSetup,
}: {
closeModal: () => void;
groupId: string;
projectId: string;
refetchSetup?: () => void;
}) {
const organization = useOrganization();
const {data, canStartAutofix, isPending, isError} = useAutofixSetup(
Expand Down Expand Up @@ -363,6 +375,7 @@ export function AutofixSetupContent({
autofixSetup={data}
canStartAutofix={canStartAutofix}
closeModal={closeModal}
refetchSetup={refetchSetup}
/>
</Fragment>
);
Expand Down

0 comments on commit c6295fd

Please sign in to comment.