Skip to content

Commit

Permalink
Merge pull request #146 from cytechmobile/feat/119_contect-menu-commands
Browse files Browse the repository at this point in the history
  • Loading branch information
maninak authored Jul 16, 2024
2 parents 29d07d7 + 6386bf8 commit 6372f5f
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
- lays much of the groundwork for the upcoming independence of the extension from the Radicle HTTP daemon for local operations
- **settings:** disallow usage of now unsupported relative paths for config `radicle.advanced.pathToRadBinary`
- **settings:** support trailing slashes for config `radicle.advanced.pathToNodeHome`
- **patch-list:** show all possible actions for a patch on its context menu (right click)
- **patch-list:** add new context-menu action "Refresh Patch Data" for a patch item

### 🔥 Performance

Expand All @@ -64,6 +66,7 @@
- **webview:** keep panel's title in sync with the title of the patch shown within it as it gets updated either from the extension user or from network users
- **patch-detail:** the buttons on patch detail webviews left open from a previous VS Code session that got restored will now work, same as those of just opened webviews
- **patch-list:** more accurately reflect git check-out state per patch in the list. Previously a checked out patch would not have the associated checkmark denoting its state shown in the patch list unless a check out AND a list refresh was done. Some edge cases may remain unpatched still.
- **patch-list:** sort changed file entries placing correctly always to the top those located at the root directory of the repo
- **patch-list:** let the "Updated X time ago" text in the title bar of the Patches view be updated when there's only one patch in the currently open repo and the user refetched its data exclusively, e.g. using the "Refresh" button in the Patch Detail view
- **commands:** don't fail checking out patch branch if the branch already existed but was referring to a different revision than the one we're attempting to check out
- **settings:** watch _user-defined_ path to Radicle CLI binary for changes too. Previously only the default paths per OS were being watched.
Expand Down
44 changes: 36 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,24 @@
"enablement": "radicle.isRadInitialized"
},
{
"command": "radicle.refreshPatches",
"title": "Refresh Patches View",
"command": "radicle.refreshAllPatches",
"title": "Refresh All Patch Data",
"shortTitle": "Refresh Patches",
"category": "Radicle",
"icon": "$(refresh)",
"enablement": "radicle.isRadInitialized"
},
{
"command": "radicle.refreshOnePatch",
"title": "Refresh Patch Data",
"shortTitle": "Refresh Patch",
"category": "Radicle",
"icon": "$(refresh)",
"enablement": "radicle.isRadInitialized"
},
{
"command": "radicle.viewPatchDetails",
"title": "View Patch Details",
"title": "Open Patch Details",
"shortTitle": "Patch Details",
"category": "Radicle",
"icon": "$(preview)",
Expand Down Expand Up @@ -176,6 +184,10 @@
"command": "radicle.viewPatchDetails",
"when": "false"
},
{
"command": "radicle.refreshOnePatch",
"when": "false"
},
{
"command": "radicle.checkoutPatch",
"when": "false"
Expand Down Expand Up @@ -205,7 +217,7 @@
],
"view/title": [
{
"command": "radicle.refreshPatches",
"command": "radicle.refreshAllPatches",
"when": "view == patches-view",
"group": "navigation@1"
}
Expand All @@ -216,20 +228,36 @@
"when": "view == patches-view && viewItem =~ /patch/",
"group": "inline@1"
},
{
"command": "radicle.viewPatchDetails",
"when": "view == patches-view && viewItem =~ /patch/",
"group": "contextMenu.A@1"
},
{
"command": "radicle.refreshOnePatch",
"when": "view == patches-view && viewItem =~ /patch/",
"group": "contextMenu.A@2"
},
{
"command": "radicle.copyPatchId",
"when": "view == patches-view && viewItem =~ /patch/",
"group": "contextMenu.C@1"
},
{
"command": "radicle.checkoutPatch",
"when": "view == patches-view && viewItem =~ /patch:checked-out-false/",
"group": "inline@2"
},
{
"command": "radicle.checkoutPatch",
"when": "view == patches-view && viewItem =~ /patch:checked-out-false/",
"group": "contextMenu.B@1"
},
{
"command": "radicle.checkoutDefaultBranch",
"when": "view == patches-view && viewItem =~ /patch:checked-out-true/",
"group": "inline@2"
},
{
"command": "radicle.copyPatchId",
"when": "view == patches-view && viewItem =~ /patch/"
},
{
"command": "radicle.openOriginalVersionOfPatchedFile",
"when": "view == patches-view && viewItem =~ /filechange:(deleted|modified|copied|moved)/",
Expand Down
5 changes: 4 additions & 1 deletion src/helpers/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,12 @@ export function registerAllCommands(): void {
registerVsCodeCmd('radicle.collapsePatches', () => {
commands.executeCommand('workbench.actions.treeView.patches-view.collapseAll')
})
registerVsCodeCmd('radicle.refreshPatches', () => {
registerVsCodeCmd('radicle.refreshAllPatches', () => {
usePatchStore().resetAllPatches()
})
registerVsCodeCmd('radicle.refreshOnePatch', (patchId: Patch['id']) => {
usePatchStore().refetchPatch(patchId)
})
registerVsCodeCmd('radicle.checkoutPatch', checkOutPatch)
registerVsCodeCmd('radicle.checkoutDefaultBranch', checkOutDefaultBranch)
registerVsCodeCmd('radicle.copyPatchId', async (patch: Partial<Patch> | undefined) => {
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/webview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Uri, ViewColumn, type Webview, type WebviewPanel, window } from 'vscode'
import { Uri, ViewColumn, type Webview, type WebviewPanel, commands, window } from 'vscode'
import {
type WebviewId,
allWebviewIds,
Expand Down Expand Up @@ -261,7 +261,7 @@ async function handleMessageFromWebviewPatchDetail(
copyToClipboardAndNotify(message.payload.textToCopy)
break
case 'refreshPatchData':
usePatchStore().refetchPatch(message.payload.patchId)
commands.executeCommand('radicle.refreshOnePatch', message.payload.patchId)
break
case 'checkOutPatchBranch':
checkOutPatch(message.payload.patch)
Expand Down
2 changes: 1 addition & 1 deletion src/ux/patchesView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export const patchesTreeDataProvider: TreeDataProvider<
)}${sep}${fileDir}${sep}${filename}`

const node: FilechangeNode = {
relativeInRepoUrl: filePath,
relativeInRepoUrl: filePath.includes(sep) ? filePath : `${sep}${filePath}`,
oldVersionUrl,
newVersionUrl,
patch,
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/src/components/PatchDetailButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function revealPatch() {
<vscode-button
class="self-center"
appearance="secondary"
title="Refresh All Data on This Page"
title="Refresh Patch Data"
@click="refetchPatchData"
>
<!-- eslint-disable-next-line vue/no-deprecated-slot-attribute -->
Expand Down

0 comments on commit 6372f5f

Please sign in to comment.