Adding update/delete commands to tree
This commit is contained in:
Родитель
72ba7cc08e
Коммит
7184bda25e
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"title": "bar",
|
||||
"description": "",
|
||||
"steps": [
|
||||
{
|
||||
"file": "src/extension.ts",
|
||||
"line": 35,
|
||||
"description": "blah"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"title": "foo",
|
||||
"description": "",
|
||||
"steps": [
|
||||
{
|
||||
"file": "schema.json",
|
||||
"line": 21,
|
||||
"description": "Test"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -23,4 +23,4 @@
|
|||
"description": "When a tour is activate and/or navigated, we update the status bar item to indicate the current step and title."
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"title": "this is a test - please work",
|
||||
"description": "",
|
||||
"steps": [
|
||||
{
|
||||
"file": "schema.json",
|
||||
"line": 19,
|
||||
"description": "cool"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,3 +1,7 @@
|
|||
## v0.0.6 (03/13/2020)
|
||||
|
||||
- Added the `Change Title`, `Change Description` and `Delete Tour` commands to the `Code Tours` tree view to enable easily managing existing tours
|
||||
|
||||
## v0.0.5 (03/09/2020)
|
||||
|
||||
- Added an icon to the `Code Tours` tree view which indicates the currently active tour
|
||||
|
|
43
package.json
43
package.json
|
@ -40,13 +40,25 @@
|
|||
"enablement": "!commentIsEmpty"
|
||||
},
|
||||
{
|
||||
"command": "codetour.editTourStep",
|
||||
"title": "Edit Step"
|
||||
"command": "codetour.changeTourDescription",
|
||||
"title": "Change Description"
|
||||
},
|
||||
{
|
||||
"command": "codetour.changeTourTitle",
|
||||
"title": "Change Title"
|
||||
},
|
||||
{
|
||||
"command": "codetour.deleteTour",
|
||||
"title": "Delete Tour"
|
||||
},
|
||||
{
|
||||
"command": "codetour.deleteTourStep",
|
||||
"title": "Delete Step"
|
||||
},
|
||||
{
|
||||
"command": "codetour.editTourStep",
|
||||
"title": "Edit Step"
|
||||
},
|
||||
{
|
||||
"command": "codetour.endTour",
|
||||
"title": "End Tour",
|
||||
|
@ -114,6 +126,18 @@
|
|||
"command": "codetour.addTourStep",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codetour.changeTourTitle",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codetour.changeTourDescription",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codetour.deleteTour",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "codetour.deleteTourStep",
|
||||
"when": "false"
|
||||
|
@ -209,6 +233,21 @@
|
|||
"command": "codetour.startTour",
|
||||
"when": "viewItem == codetour.tour",
|
||||
"group": "inline@3"
|
||||
},
|
||||
{
|
||||
"command": "codetour.changeTourTitle",
|
||||
"when": "viewItem == codetour.tour",
|
||||
"group": "basic@1"
|
||||
},
|
||||
{
|
||||
"command": "codetour.changeTourDescription",
|
||||
"when": "viewItem == codetour.tour",
|
||||
"group": "basic@2"
|
||||
},
|
||||
{
|
||||
"command": "codetour.deleteTour",
|
||||
"when": "viewItem == codetour.tour",
|
||||
"group": "manage@1"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -109,6 +109,7 @@ export function registerCommands() {
|
|||
);
|
||||
|
||||
startCodeTour({
|
||||
id: "",
|
||||
title,
|
||||
description,
|
||||
steps: []
|
||||
|
@ -190,6 +191,44 @@ export function registerCommands() {
|
|||
}
|
||||
);
|
||||
|
||||
async function updateTourProperty(tour: CodeTour, property: string) {
|
||||
const propertyValue = await vscode.window.showInputBox({
|
||||
prompt: `Enter the ${property} for this tour`,
|
||||
// @ts-ignore
|
||||
value: tour[property]
|
||||
});
|
||||
|
||||
if (!propertyValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
tour[property] = propertyValue;
|
||||
|
||||
const uri = vscode.Uri.parse(tour.id);
|
||||
delete tour.id;
|
||||
const tourContent = JSON.stringify(tour, null, 2);
|
||||
vscode.workspace.fs.writeFile(uri, new Buffer(tourContent));
|
||||
}
|
||||
|
||||
vscode.commands.registerCommand(
|
||||
`${EXTENSION_NAME}.changeTourDescription`,
|
||||
(node: CodeTourNode) => updateTourProperty(node.tour, "description")
|
||||
);
|
||||
|
||||
vscode.commands.registerCommand(
|
||||
`${EXTENSION_NAME}.changeTourTitle`,
|
||||
(node: CodeTourNode) => updateTourProperty(node.tour, "title")
|
||||
);
|
||||
|
||||
vscode.commands.registerCommand(
|
||||
`${EXTENSION_NAME}.deleteTour`,
|
||||
async (node: CodeTourNode) => {
|
||||
const uri = vscode.Uri.parse(node.tour.id);
|
||||
vscode.workspace.fs.delete(uri);
|
||||
}
|
||||
);
|
||||
|
||||
vscode.commands.registerCommand(
|
||||
`${EXTENSION_NAME}.deleteTourStep`,
|
||||
async (comment: CodeTourComment) => {
|
||||
|
@ -218,6 +257,7 @@ export function registerCommands() {
|
|||
.replace(/\s/g, "-")
|
||||
.replace(/[^\w\d-_]/g, "");
|
||||
|
||||
delete store.currentTour?.id;
|
||||
const tour = JSON.stringify(store.currentTour, null, 2);
|
||||
const workspaceRoot = vscode.workspace.workspaceFolders![0].uri.toString();
|
||||
const uri = vscode.Uri.parse(`${workspaceRoot}/.vscode/tours/${file}.json`);
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
import { observable } from "mobx";
|
||||
|
||||
export interface CodeTourStep {
|
||||
title?: string;
|
||||
description: string;
|
||||
file?: string;
|
||||
uri?: string;
|
||||
line: number;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface CodeTour {
|
||||
id: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
steps: CodeTourStep[];
|
||||
ref?: string;
|
||||
}
|
||||
|
||||
export interface Store {
|
||||
|
|
|
@ -50,7 +50,9 @@ async function discoverSubTours(workspaceRoot: string): Promise<CodeTour[]> {
|
|||
const tourContent = (
|
||||
await vscode.workspace.fs.readFile(tourUri)
|
||||
).toString();
|
||||
return JSON.parse(tourContent);
|
||||
const tour = JSON.parse(tourContent);
|
||||
tour.id = tourUri.toString();
|
||||
return tour;
|
||||
})
|
||||
);
|
||||
} catch {
|
||||
|
|
|
@ -31,8 +31,7 @@ export class CodeTourNode extends TreeItem {
|
|||
contextValues.push("recording");
|
||||
}
|
||||
|
||||
const isActive =
|
||||
store.currentTour && tour.title === store.currentTour?.title;
|
||||
const isActive = store.currentTour && tour.id === store.currentTour?.id;
|
||||
if (isActive) {
|
||||
contextValues.push("active");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче