Skip to content

Commit aea9bf1

Browse files
committed
Refactor context menu conditions
1 parent e20e38e commit aea9bf1

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@
690690
},
691691
{
692692
"command": "vscode-cmsis-debugger.componentViewer.copyRow",
693-
"when": "webviewId == 'cmsis-debugger.componentViewer' && componentViewerRow != 'root' && componentViewerRowHasValue",
693+
"when": "webviewId == 'cmsis-debugger.componentViewer' && !componentViewerRowIsRoot && componentViewerRowHasValue",
694694
"group": "contextMenuG1@2"
695695
},
696696
{
@@ -705,12 +705,12 @@
705705
},
706706
{
707707
"command": "vscode-cmsis-debugger.componentViewer.lockComponent",
708-
"when": "webviewId == 'cmsis-debugger.componentViewer' && componentViewerRow == 'root' && componentViewerLockState == 'unlocked'",
708+
"when": "webviewId == 'cmsis-debugger.componentViewer' && componentViewerRowIsRoot && !componentViewerComponentLocked",
709709
"group": "contextMenuG2@2"
710710
},
711711
{
712712
"command": "vscode-cmsis-debugger.componentViewer.unlockComponent",
713-
"when": "webviewId == 'cmsis-debugger.componentViewer' && componentViewerRow == 'root' && componentViewerLockState == 'locked'",
713+
"when": "webviewId == 'cmsis-debugger.componentViewer' && componentViewerRowIsRoot && componentViewerComponentLocked",
714714
"group": "contextMenuG2@2"
715715
},
716716
{
@@ -725,7 +725,7 @@
725725
},
726726
{
727727
"command": "vscode-cmsis-debugger.corePeripherals.copyRow",
728-
"when": "webviewId == 'cmsis-debugger.corePeripherals' && componentViewerRow != 'root' && componentViewerRowHasValue",
728+
"when": "webviewId == 'cmsis-debugger.corePeripherals' && !componentViewerRowIsRoot && componentViewerRowHasValue",
729729
"group": "contextMenuG1@2"
730730
},
731731
{
@@ -740,12 +740,12 @@
740740
},
741741
{
742742
"command": "vscode-cmsis-debugger.corePeripherals.lockComponent",
743-
"when": "webviewId == 'cmsis-debugger.corePeripherals' && componentViewerRow == 'root' && componentViewerLockState == 'unlocked'",
743+
"when": "webviewId == 'cmsis-debugger.corePeripherals' && componentViewerRowIsRoot && !componentViewerComponentLocked",
744744
"group": "contextMenuG2@2"
745745
},
746746
{
747747
"command": "vscode-cmsis-debugger.corePeripherals.unlockComponent",
748-
"when": "webviewId == 'cmsis-debugger.corePeripherals' && componentViewerRow == 'root' && componentViewerLockState == 'locked'",
748+
"when": "webviewId == 'cmsis-debugger.corePeripherals' && componentViewerRowIsRoot && componentViewerComponentLocked",
749749
"group": "contextMenuG2@2"
750750
},
751751
{

src/webviews/tree-table/src/TreeTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ function buildVscodeContext(row: FlatRow, copyText: string): string {
3939
const rowCopyText = row.value ? `${row.name}\t${row.value}` : row.name;
4040
return JSON.stringify({
4141
componentViewerRowId: row.id,
42-
componentViewerRow: row.lockEnabled ? 'root' : 'item',
42+
componentViewerRowIsRoot: Boolean(row.lockEnabled),
4343
componentViewerRowHasValue: Boolean(row.value),
44-
componentViewerLockState: row.locked ? 'locked' : 'unlocked',
44+
componentViewerComponentLocked: Boolean(row.locked),
4545
componentViewerCopyText: copyText,
4646
componentViewerCopyRowText: rowCopyText,
4747
preventDefaultContextMenuItems: true,

0 commit comments

Comments
 (0)