Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
feat(guideline): add API synchronization
Browse files Browse the repository at this point in the history
  • Loading branch information
frgfm committed Mar 5, 2024
1 parent e5835d3 commit 32ac7a7
Show file tree
Hide file tree
Showing 4 changed files with 244 additions and 208 deletions.
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@
"category": "Quack Companion",
"title": "List your guidelines"
},
{
"command": "quack.editGuideline",
"category": "Quack Companion",
"title": "Update your guideline content"
},
{
"command": "quack.editGuidelineItem",
"category": "Quack Companion",
Expand All @@ -229,11 +224,6 @@
"dark": "assets/dark/edit.svg"
}
},
{
"command": "quack.deleteGuideline",
"category": "Quack Companion",
"title": "Delete a guideline"
},
{
"command": "quack.deleteGuidelineItem",
"category": "Quack Companion",
Expand All @@ -242,6 +232,15 @@
"light": "assets/light/trash.svg",
"dark": "assets/dark/trash.svg"
}
},
{
"command": "quack.pullGuidelines",
"category": "Quack Companion",
"title": "Pull your guidelines",
"icon": {
"light": "assets/light/refresh.svg",
"dark": "assets/dark/refresh.svg"
}
}
],
"viewsWelcome": [
Expand Down Expand Up @@ -274,6 +273,11 @@
"command": "quack.createGuideline",
"when": "view == quack.guidelineTreeView",
"group": "navigation"
},
{
"command": "quack.pullGuidelines",
"when": "view == quack.guidelineTreeView",
"group": "navigation"
}
],
"view/item/context": [
Expand Down
29 changes: 9 additions & 20 deletions src/activation/activate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
createGuideline,
listGuidelines,
editGuideline,
deleteGuideline,
removeGuideline,
pullGuidelines,
} from "../commands/guidelines";

export let extensionContext: vscode.ExtensionContext | undefined = undefined;
Expand Down Expand Up @@ -94,6 +95,12 @@ export async function activateExtension(context: vscode.ExtensionContext) {
}),
);
// Guideline
context.subscriptions.push(
vscode.commands.registerCommand("quack.pullGuidelines", async () => {
await pullGuidelines(context);
guidelineTreeProvider.refresh();
}),
);
context.subscriptions.push(
vscode.commands.registerCommand(
"quack.createGuideline",
Expand All @@ -108,37 +115,19 @@ export async function activateExtension(context: vscode.ExtensionContext) {
await listGuidelines(context);
}),
);
context.subscriptions.push(
vscode.commands.registerCommand(
"quack.editGuideline",
async (index?: number, content?: string) => {
await editGuideline(index, content, context);
guidelineTreeProvider.refresh();
},
),
);
context.subscriptions.push(
vscode.commands.registerCommand("quack.editGuidelineItem", async (item) => {
const index = guidelineTreeProvider.getIndexOf(item);
await editGuideline(index, undefined, context);
guidelineTreeProvider.refresh();
}),
);
context.subscriptions.push(
vscode.commands.registerCommand(
"quack.deleteGuideline",
async (index?: number) => {
await deleteGuideline(index, context);
guidelineTreeProvider.refresh();
},
),
);
context.subscriptions.push(
vscode.commands.registerCommand(
"quack.deleteGuidelineItem",
async (item) => {
const index = guidelineTreeProvider.getIndexOf(item);
await deleteGuideline(index, context);
await removeGuideline(index, context);
guidelineTreeProvider.refresh();
},
),
Expand Down
Loading

0 comments on commit 32ac7a7

Please sign in to comment.