feat: ability to uninstall any extension
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { ContentType, SNComponent } from '@standardnotes/snjs';
|
import { ButtonType, ContentType, SNComponent } from '@standardnotes/snjs';
|
||||||
import { Button } from '@/components/Button';
|
import { Button } from '@/components/Button';
|
||||||
import { DecoratedInput } from '@/components/DecoratedInput';
|
import { DecoratedInput } from '@/components/DecoratedInput';
|
||||||
import { WebApplication } from '@/ui_models/application';
|
import { WebApplication } from '@/ui_models/application';
|
||||||
@@ -35,8 +35,22 @@ export const Extensions: FunctionComponent<{
|
|||||||
}, [confirmableExtension, confirmableEnd]);
|
}, [confirmableExtension, confirmableEnd]);
|
||||||
|
|
||||||
const uninstallExtension = async (extension: SNComponent) => {
|
const uninstallExtension = async (extension: SNComponent) => {
|
||||||
|
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);
|
await application.deleteItem(extension);
|
||||||
setExtensions(loadExtensions(application));
|
setExtensions(loadExtensions(application));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err: string) => {
|
||||||
|
application.alertService.alert(err);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const submitExtensionUrl = async (url: string) => {
|
const submitExtensionUrl = async (url: string) => {
|
||||||
@@ -78,6 +92,7 @@ export const Extensions: FunctionComponent<{
|
|||||||
.sort((e1, e2) => e1.name.toLowerCase().localeCompare(e2.name.toLowerCase()))
|
.sort((e1, e2) => e1.name.toLowerCase().localeCompare(e2.name.toLowerCase()))
|
||||||
.map((extension, i) => (
|
.map((extension, i) => (
|
||||||
<ExtensionItem
|
<ExtensionItem
|
||||||
|
key={extension.uuid}
|
||||||
application={application}
|
application={application}
|
||||||
extension={extension}
|
extension={extension}
|
||||||
latestVersion={extensionsLatestVersions.getVersion(extension)}
|
latestVersion={extensionsLatestVersions.getVersion(extension)}
|
||||||
|
|||||||
@@ -101,7 +101,6 @@ export const ExtensionItem: FunctionComponent<ExtensionItemProps> =
|
|||||||
};
|
};
|
||||||
|
|
||||||
const localInstallable = extension.package_info.download_url;
|
const localInstallable = extension.package_info.download_url;
|
||||||
const isExternal = !extension.package_info.identifier.startsWith('org.standardnotes.');
|
|
||||||
const installedVersion = extension.package_info.version;
|
const installedVersion = extension.package_info.version;
|
||||||
const isToggleable = [ComponentArea.EditorStack, ComponentArea.TagsList].includes(extension.area);
|
const isToggleable = [ComponentArea.EditorStack, ComponentArea.TagsList].includes(extension.area);
|
||||||
|
|
||||||
@@ -120,7 +119,6 @@ export const ExtensionItem: FunctionComponent<ExtensionItemProps> =
|
|||||||
{localInstallable && <AutoUpdateLocal autoupdateDisabled={autoupdateDisabled} toggleAutoupdate={toggleAutoupdate} />}
|
{localInstallable && <AutoUpdateLocal autoupdateDisabled={autoupdateDisabled} toggleAutoupdate={toggleAutoupdate} />}
|
||||||
{localInstallable && <UseHosted offlineOnly={offlineOnly} toggleOfllineOnly={toggleOffllineOnly} />}
|
{localInstallable && <UseHosted offlineOnly={offlineOnly} toggleOfllineOnly={toggleOffllineOnly} />}
|
||||||
|
|
||||||
{(isToggleable || isExternal) &&
|
|
||||||
<>
|
<>
|
||||||
<div className="min-h-2" />
|
<div className="min-h-2" />
|
||||||
<div className="flex flex-row">
|
<div className="flex flex-row">
|
||||||
@@ -134,10 +132,9 @@ export const ExtensionItem: FunctionComponent<ExtensionItemProps> =
|
|||||||
<div className="min-w-3" />
|
<div className="min-w-3" />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{isExternal && <Button className="min-w-20" type="normal" label="Uninstall" onClick={() => uninstall(extension)} />}
|
<Button className="min-w-20" type="normal" label="Uninstall" onClick={() => uninstall(extension)} />
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
}
|
|
||||||
</PreferencesSegment >
|
</PreferencesSegment >
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user