Skip to content

Commit 168ddce

Browse files
committed
Remove unnecessary review creation eligibility check
This commit removes an unnecessary check that previously determined whether a review could be created or not. Simplifies logic in BranchReview.svelte, CreateReviewBox.svelte, ReviewCreation.svelte, and ReviewCreationControls.svelte by eliminating isCreateButtonEnabled, submitDisabled logic, and related properties. This streamlines the review creation process and cleans up unused derived values and props.
1 parent 3ac98bb commit 168ddce

File tree

4 files changed

+2
-25
lines changed

4 files changed

+2
-25
lines changed

apps/desktop/src/components/BranchReview.svelte

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
let modal = $state<Modal>();
3636
let confirmCreatePrModal = $state<ReturnType<typeof Modal>>();
3737
let reviewCreation = $state<ReturnType<typeof ReviewCreation>>();
38-
39-
const submitDisabled = $derived(reviewCreation ? !reviewCreation.imports.creationEnabled : false);
4038
</script>
4139

4240
<CanPublishReviewPlugin
@@ -82,7 +80,6 @@
8280
{#snippet controls(close)}
8381
<ReviewCreationControls
8482
isSubmitting={!!reviewCreation?.imports.isLoading}
85-
{submitDisabled}
8683
{canPublishPR}
8784
{reviewUnit}
8885
onCancel={close}

apps/desktop/src/components/CreateReviewBox.svelte

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
const pr = $derived(prResult?.current.data);
4141
4242
const canPublishPR = $derived(!!(forge.current.authenticated && !pr));
43-
44-
const submitDisabled = $derived(reviewCreation ? !reviewCreation.imports.creationEnabled : false);
4543
</script>
4644

4745
{#snippet editor()}
@@ -56,7 +54,6 @@
5654
/>
5755
<ReviewCreationControls
5856
isSubmitting={!!reviewCreation?.imports.isLoading}
59-
{submitDisabled}
6057
{canPublishPR}
6158
{reviewUnit}
6259
onCancel={() => {

apps/desktop/src/components/ReviewCreation.svelte

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@
4545
projectId: string;
4646
stackId: string;
4747
branchName: string;
48-
prNumber?: number;
4948
reviewId?: string;
5049
onClose: () => void;
5150
};
5251
53-
const { projectId, stackId, branchName, prNumber, onClose }: Props = $props();
52+
const { projectId, stackId, branchName, onClose }: Props = $props();
5453
5554
const baseBranch = inject(BASE_BRANCH);
5655
const forge = inject(DEFAULT_FORGE_FACTORY);
@@ -80,14 +79,10 @@
8079
const commitsResult = $derived(stackService.commits(projectId, stackId, branchName));
8180
const commits = $derived(commitsResult.current.data || []);
8281
83-
const prResult = $derived(prNumber ? prService?.get(prNumber) : undefined);
84-
const pr = $derived(prResult?.current.data);
85-
8682
const forgeBranch = $derived(branchName ? forge.current.branch(branchName) : undefined);
8783
const baseBranchName = $derived(baseBranch.shortName);
8884
8985
const createDraft = persisted<boolean>(false, 'createDraftPr');
90-
const createPullRequest = persisted<boolean>(true, 'createPullRequest');
9186
9287
const pushBeforeCreate = $derived(
9388
!forgeBranch || (branchDetails ? requiresPush(branchDetails.pushStatus) : true)
@@ -111,8 +106,6 @@
111106
let isCreatingReview = $state<boolean>(false);
112107
const isExecuting = $derived(stackPush.current.isLoading || aiIsLoading || isCreatingReview);
113108
114-
const canPublishPR = $derived(!!(forge.current.authenticated && !pr));
115-
116109
async function getDefaultTitle(commits: Commit[]): Promise<string> {
117110
if (commits.length === 1) {
118111
const commitMessage = commits[0]!.message;
@@ -305,13 +298,6 @@
305298
}
306299
}
307300
308-
const isCreateButtonEnabled = $derived.by(() => {
309-
if (canPublishPR && $createPullRequest) {
310-
return true;
311-
}
312-
return false;
313-
});
314-
315301
async function onAiButtonClick() {
316302
if (!aiGenEnabled || aiIsLoading) return;
317303
@@ -347,9 +333,6 @@
347333
}
348334
349335
export const imports = {
350-
get creationEnabled() {
351-
return isCreateButtonEnabled;
352-
},
353336
get isLoading() {
354337
return isExecuting;
355338
}

apps/desktop/src/components/ReviewCreationControls.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
interface Props {
1111
isSubmitting: boolean;
1212
canPublishPR: boolean;
13-
submitDisabled: boolean;
13+
submitDisabled?: boolean;
1414
reviewUnit: string | undefined;
1515
onCancel: () => void;
1616
onSubmit: () => void;

0 commit comments

Comments
 (0)