mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import React from "react";
|
|
import type { InstalledExtension } from "../../../../extensions/extension-discovery/extension-discovery";
|
|
import type { LensExtensionId } from "../../../../extensions/lens-extension";
|
|
import { extensionDisplayName } from "../../../../extensions/lens-extension";
|
|
import { ConfirmDialog } from "../../confirm-dialog";
|
|
|
|
interface Dependencies {
|
|
uninstallExtension: (id: LensExtensionId) => Promise<boolean>;
|
|
}
|
|
|
|
export const confirmUninstallExtension =
|
|
({ uninstallExtension }: Dependencies) =>
|
|
async (extension: InstalledExtension): Promise<void> => {
|
|
const displayName = extensionDisplayName(
|
|
extension.manifest.name,
|
|
extension.manifest.version,
|
|
);
|
|
const confirmed = await ConfirmDialog.confirm({
|
|
message: (
|
|
<p>
|
|
Are you sure you want to uninstall extension <b>{displayName}</b>?
|
|
</p>
|
|
),
|
|
labelOk: "Yes",
|
|
labelCancel: "No",
|
|
});
|
|
|
|
if (confirmed) {
|
|
await uninstallExtension(extension.id);
|
|
}
|
|
};
|