Merge pull request #3173 from ceruleandeep/redesign-extension-manager Redesign extension manager
Signed| @@ -50,3 +50,5 @@ public/css/user.css | ||
| 50 | 50 | /default/scaffold |
| 51 | 51 | public/scripts/extensions/third-party |
| 52 | 52 | /certs |
| 53 | +.aider* | |
| 54 | +.env | |
| @@ -770,7 +770,7 @@ async function showExtensionsDetails() { | ||
| 770 | 770 | |
| 771 | 771 | /** |
| 772 | 772 | * Handles the click event for the update button of an extension. |
| 773 | 773 | * This function makes a POST request to '/update_extensionapi/extensions/update' with the extension's name. |
| 774 | 774 | * If the extension is already up to date, it displays a success message. |
| 775 | 775 | * If the extension is not up to date, it updates the extension and displays a success message with the new commit hash. |
| 776 | 776 | */ |
| @@ -783,8 +783,11 @@ async function onUpdateClick() { | ||
| 783 | 783 | return; |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | const icon = $(this).find('i').addClass('fa-spin'); |
| 787 | + icon.addClass('fa-spin'); | |
| 787 | 788 | await updateExtension(extensionName, false); |
| 789 | + // updateExtension eats the error, but we can at least stop the spinner | |
| 790 | + icon.removeClass('fa-spin'); | |
| 788 | 791 | } |
| 789 | 792 | |
| 790 | 793 | /** |
| @@ -803,10 +806,17 @@ async function updateExtension(extensionName, quiet) { | ||
| 803 | 806 | }), |
| 804 | 807 | }); |
| 805 | 808 | |
| 809 | + if (!response.ok) { | |
| 810 | + const text = await response.text(); | |
| 811 | + toastr.error(text || response.statusText, t`Extension update failed`, { timeOut: 5000 }); | |
| 812 | + console.error('Extension update failed', response.status, response.statusText, text); | |
| 813 | + return; | |
| 814 | + } | |
| 815 | + | |
| 806 | 816 | const data = await response.json(); |
| 807 | 817 | |
| 808 | 818 | if (!quiet) { |
| 809 | 819 | await showExtensionsDetails(); |
| 810 | 820 | } |
| 811 | 821 | |
| 812 | 822 | if (data.isUpToDate) { |
| @@ -224,12 +224,20 @@ router.post('/version', jsonParser, async (request, response) => { | ||
| 224 | 224 | return response.status(404).send(`Directory does not exist at ${extensionPath}`); |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | + let currentCommitHash; | |
| 228 | + try { | |
| 229 | + currentCommitHash = await git.cwd(extensionPath).revparse(['HEAD']); | |
| 230 | + } catch (error) { | |
| 231 | + // it is not a git repo, or has no commits yet, or is a bare repo | |
| 232 | + // not possible to update it, most likely can't get the branch name either | |
| 233 | + return response.send({ currentBranchName: null, currentCommitHash, isUpToDate: true, remoteUrl: null }); | |
| 234 | + } | |
| 235 | + | |
| 227 | 236 | const currentBranch = await git.cwd(extensionPath).branch(); |
| 228 | 237 | // get only the working branch |
| 229 | 238 | const currentBranchName = currentBranch.current; |
| 230 | 239 | await git.cwd(extensionPath).fetch('origin'); |
| 231 | - const currentCommitHash = await git.cwd(extensionPath).revparse(['HEAD']); | |
| 240 | + console.log(extensionName, currentBranchName, currentCommitHash); | |
| 232 | - console.log(currentBranch, currentCommitHash); | |
| 233 | 241 | const { isUpToDate, remoteUrl } = await checkIfRepoIsUpToDate(extensionPath); |
| 234 | 242 | |
| 235 | 243 | return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl }); |