From 04136159dcb19c09f83b2fbcfdec510863684278 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Sun, 14 Nov 2021 14:27:26 -0600 Subject: [PATCH] feat: ability to uninstall any extension --- .../preferences/panes/Extensions.tsx | 97 +++++++++++-------- .../extensions-segments/ExtensionItem.tsx | 35 +++---- 2 files changed, 72 insertions(+), 60 deletions(-) diff --git a/app/assets/javascripts/preferences/panes/Extensions.tsx b/app/assets/javascripts/preferences/panes/Extensions.tsx index 5bf8b8f01..9fdb73d12 100644 --- a/app/assets/javascripts/preferences/panes/Extensions.tsx +++ b/app/assets/javascripts/preferences/panes/Extensions.tsx @@ -1,4 +1,4 @@ -import { ContentType, SNComponent } from '@standardnotes/snjs'; +import { ButtonType, ContentType, SNComponent } from '@standardnotes/snjs'; import { Button } from '@/components/Button'; import { DecoratedInput } from '@/components/DecoratedInput'; import { WebApplication } from '@/ui_models/application'; @@ -35,8 +35,22 @@ export const Extensions: FunctionComponent<{ }, [confirmableExtension, confirmableEnd]); const uninstallExtension = async (extension: SNComponent) => { - await application.deleteItem(extension); - setExtensions(loadExtensions(application)); + application.alertService.confirm( + 'Are you sure you want to uninstall this extension? Note that extensions managed by your subscription will automatically be re-installed on application restart.', + 'Uninstall Extension?', + 'Uninstall', + ButtonType.Danger, + 'Cancel' + ) + .then(async (shouldRemove: boolean) => { + if (shouldRemove) { + await application.deleteItem(extension); + setExtensions(loadExtensions(application)); + } + }) + .catch((err: string) => { + application.alertService.alert(err); + }); }; const submitExtensionUrl = async (url: string) => { @@ -72,50 +86,51 @@ export const Extensions: FunctionComponent<{ return (
{visibleExtensions.length > 0 && -
- { - visibleExtensions - .sort((e1, e2) => e1.name.toLowerCase().localeCompare(e2.name.toLowerCase())) - .map((extension, i) => ( - - )) - } -
+
+ { + visibleExtensions + .sort((e1, e2) => e1.name.toLowerCase().localeCompare(e2.name.toLowerCase())) + .map((extension, i) => ( + + )) + } +
}
{!confirmableExtension && - - Install Custom Extension -
- { setCustomUrl(value); }} - /> -
-
- - } + <> +
+
+ {isToggleable && ( + <> + {(extension.active ? ( +
+ ); };