Skip to content

Commit 9e4570f

Browse files
authored
Removed the extra pull request button (#338)
1 parent 9ebc5e9 commit 9e4570f

File tree

2 files changed

+2
-80
lines changed

2 files changed

+2
-80
lines changed

frontend/src/lib/components/editors/DocumentEditor.svelte

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,9 @@
6363
interface Props {
6464
previewWindow: HTMLElement;
6565
saveChangesHandler: (commitMessage: string) => Promise<void>;
66-
createPullRequestHandler: () => Promise<void>;
6766
}
6867
69-
let {
70-
previewWindow = $bindable(),
71-
saveChangesHandler = $bindable(),
72-
createPullRequestHandler = $bindable()
73-
}: Props = $props();
68+
let { previewWindow = $bindable(), saveChangesHandler = $bindable() }: Props = $props();
7469
7570
async function cancelChangesHandler() {
7671
if ($editorText !== get(currentFile)) {
@@ -145,24 +140,6 @@
145140
<path d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z" />
146141
</svg>
147142
</button>
148-
<!-- Pull Request -->
149-
<button onclick={createPullRequestHandler} class="pull-request" title="Create Pull Request">
150-
<svg
151-
xmlns="http://www.w3.org/2000/svg"
152-
width="25px"
153-
height="25px"
154-
viewBox="0 0 24 24"
155-
fill="none"
156-
>
157-
<path
158-
fill-rule="evenodd"
159-
clip-rule="evenodd"
160-
d="M14.7071 2.70711L13.4142 4H14C17.3137 4 20 6.68629 20 10V16.1707C21.1652 16.5825 22 17.6938 22 19C22 20.6569 20.6569 22 19 22C17.3431 22 16 20.6569 16 19C16 17.6938 16.8348 16.5825 18 16.1707V10C18 7.79086 16.2091 6 14 6H13.4142L14.7071 7.29289C15.0976 7.68342 15.0976 8.31658 14.7071 8.70711C14.3166 9.09763 13.6834 9.09763 13.2929 8.70711L10.2929 5.70711C9.90237 5.31658 9.90237 4.68342 10.2929 4.29289L13.2929 1.29289C13.6834 0.902369 14.3166 0.902369 14.7071 1.29289C15.0976 1.68342 15.0976 2.31658 14.7071 2.70711ZM18 19C18 18.4477 18.4477 18 19 18C19.5523 18 20 18.4477 20 19C20 19.5523 19.5523 20 19 20C18.4477 20 18 19.5523 18 19ZM6 4C5.44772 4 5 4.44772 5 5C5 5.55228 5.44772 6 6 6C6.55228 6 7 5.55228 7 5C7 4.44772 6.55228 4 6 4ZM7 7.82929C8.16519 7.41746 9 6.30622 9 5C9 3.34315 7.65685 2 6 2C4.34315 2 3 3.34315 3 5C3 6.30622 3.83481 7.41746 5 7.82929V16.1707C3.83481 16.5825 3 17.6938 3 19C3 20.6569 4.34315 22 6 22C7.65685 22 9 20.6569 9 19C9 17.6938 8.16519 16.5825 7 16.1707V7.82929ZM6 18C5.44772 18 5 18.4477 5 19C5 19.5523 5.44772 20 6 20C6.55228 20 7 19.5523 7 19C7 18.4477 6.55228 18 6 18Z"
161-
fill="#000000"
162-
/>
163-
</svg>
164-
<span>Create Pull Request</span>
165-
</button>
166143
</div>
167144
<div class="editor-panes">
168145
<textarea bind:value={$editorText} class="editor-pane"></textarea>

frontend/src/routes/+page.svelte

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -178,57 +178,6 @@
178178
}
179179
});
180180
});
181-
182-
let createPullRequestHandler = $state(async (): Promise<void> => {
183-
const title = `Pull request for ${$currentFile}`;
184-
const description = `This pull request contains changes made by ${$me.username}.`;
185-
const headBranch = $branchName;
186-
187-
const response = await fetch(`${apiAddress}/api/pulls`, {
188-
method: 'POST',
189-
credentials: 'include',
190-
headers: {
191-
'Content-Type': 'application/json'
192-
},
193-
body: JSON.stringify({
194-
head_branch: headBranch,
195-
base_branch: 'master',
196-
title: title,
197-
description: description
198-
})
199-
});
200-
201-
// Handle the response
202-
if (!response.ok) {
203-
const errorMessage = `Failed to create pull request (Code ${response.status}: "${response.statusText}")`;
204-
addToast({
205-
message: `Error: ${errorMessage}`,
206-
type: ToastType.Error,
207-
dismissible: true
208-
});
209-
return; // Exit the function early on error
210-
}
211-
212-
// Parse the JSON response to get the pull request URL
213-
const jsonResponse = await response.json();
214-
const pullRequestUrl = jsonResponse.data?.pull_request_url; // Adjusted based on API response
215-
216-
if (pullRequestUrl) {
217-
// If successful, show success toast with the URL
218-
addToast({
219-
message: `Pull request created successfully. View it [here](${pullRequestUrl}).`,
220-
type: ToastType.Success,
221-
dismissible: true
222-
});
223-
} else {
224-
// Handle the case where the URL is not present (if needed)
225-
addToast({
226-
message: 'Pull request created successfully, but the URL is not available.',
227-
type: ToastType.Warning,
228-
dismissible: true
229-
});
230-
}
231-
});
232181
</script>
233182

234183
<div style="--sidebar-width: {sidebarWidth}" class="container">
@@ -273,11 +222,7 @@
273222
/>
274223
{#if mode === SelectedMode.Documents}
275224
{#if showEditor && $currentFile !== ''}
276-
<DocumentEditor
277-
bind:saveChangesHandler
278-
bind:previewWindow={previewWindow!}
279-
bind:createPullRequestHandler
280-
/>
225+
<DocumentEditor bind:saveChangesHandler bind:previewWindow={previewWindow!} />
281226
{:else}
282227
<span class="nofile-placeholder">
283228
<p>

0 commit comments

Comments
 (0)