Merge pull request #123 from covespace/confirm_delete_topic
Confirm delete topic
This commit is contained in:
commit
3768c9f97c
@ -270,9 +270,23 @@ function activate(context: vscode.ExtensionContext) {
|
|||||||
});
|
});
|
||||||
context.subscriptions.push(yourTreeView);
|
context.subscriptions.push(yourTreeView);
|
||||||
|
|
||||||
vscode.commands.registerCommand('devchat-topicview.deleteTopic', (item: TopicTreeItem) => {
|
const topicDeleteCallback = async (item: TopicTreeItem) => {
|
||||||
|
const confirm = 'Delete';
|
||||||
|
const cancel = 'Cancel';
|
||||||
|
const label = typeof item.label === 'string' ? item.label : item.label!.label;
|
||||||
|
const truncatedLabel = label.substring(0, 20) + (label.length > 20 ? '...' : '');
|
||||||
|
const result = await vscode.window.showWarningMessage(
|
||||||
|
`Are you sure you want to delete the topic "${truncatedLabel}"?`,
|
||||||
|
{ modal: true },
|
||||||
|
confirm,
|
||||||
|
cancel
|
||||||
|
);
|
||||||
|
|
||||||
|
if (result === confirm) {
|
||||||
TopicManager.getInstance().deleteTopic(item.id);
|
TopicManager.getInstance().deleteTopic(item.id);
|
||||||
});
|
}
|
||||||
|
};
|
||||||
|
vscode.commands.registerCommand('devchat-topicview.deleteTopic', topicDeleteCallback);
|
||||||
|
|
||||||
context.subscriptions.push(
|
context.subscriptions.push(
|
||||||
vscode.languages.registerCodeActionsProvider(
|
vscode.languages.registerCodeActionsProvider(
|
||||||
@ -300,7 +314,7 @@ function activate(context: vscode.ExtensionContext) {
|
|||||||
vscode.commands.registerCommand('devchat-topicview.deleteSelectedTopic', () => {
|
vscode.commands.registerCommand('devchat-topicview.deleteSelectedTopic', () => {
|
||||||
const selectedItem = yourTreeDataProvider.selectedItem;
|
const selectedItem = yourTreeDataProvider.selectedItem;
|
||||||
if (selectedItem) {
|
if (selectedItem) {
|
||||||
TopicManager.getInstance().deleteTopic(selectedItem.id);
|
topicDeleteCallback(selectedItem);
|
||||||
} else {
|
} else {
|
||||||
vscode.window.showErrorMessage('No item selected');
|
vscode.window.showErrorMessage('No item selected');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user