Uninstall plugins from sidebar
Summary: Added UI for uninstalling plugins from sidebar. To avoid confusion between "disable" and "uninstall" and to reduce possibility of errors when plugins uninstalled accidentally by misclicks, I made it only possible to uninstall plugins after they are disabled. So for enabled plugins two steps are required for uninstalling. Reviewed By: mweststrate Differential Revision: D25454117 fbshipit-source-id: 28e67dc1ff2d39ad67e6d2770302a996affd9723
This commit is contained in:
committed by
Facebook GitHub Bot
parent
97d37abbb2
commit
df03ccbeab
@@ -140,8 +140,12 @@ export async function getInstalledPlugins(): Promise<PluginDetails[]> {
|
||||
versionDirs
|
||||
.filter(([_, versionDirs]) => versionDirs.length > 0)
|
||||
.map(([_, versionDirs]) => versionDirs[0]),
|
||||
(latestVersionDir) => getPluginDetailsFromDir(latestVersionDir),
|
||||
);
|
||||
(latestVersionDir) =>
|
||||
getPluginDetailsFromDir(latestVersionDir).catch((err) => {
|
||||
console.error(`Failed to load plugin from ${latestVersionDir}`, err);
|
||||
return null;
|
||||
}),
|
||||
).then((plugins) => plugins.filter(notNull));
|
||||
}
|
||||
|
||||
export async function cleanupOldInstalledPluginVersions(
|
||||
@@ -172,11 +176,20 @@ export async function moveInstalledPluginsFromLegacyDir() {
|
||||
fs
|
||||
.lstat(dir)
|
||||
.then((lstat) => lstat.isDirectory())
|
||||
.catch(() => Promise.resolve(false)),
|
||||
.catch(() => false),
|
||||
),
|
||||
)
|
||||
.then((dirs) =>
|
||||
pmap(dirs, (dir) => getPluginDetailsFromDir(dir).catch(() => null)),
|
||||
pmap(dirs, (dir) =>
|
||||
getPluginDetailsFromDir(dir).catch(async (err) => {
|
||||
console.error(
|
||||
`Failed to load plugin from ${dir} on moving legacy plugins. Removing it.`,
|
||||
err,
|
||||
);
|
||||
fs.remove(dir);
|
||||
return null;
|
||||
}),
|
||||
),
|
||||
)
|
||||
.then((plugins) =>
|
||||
pmap(plugins.filter(notNull), (plugin) =>
|
||||
|
||||
Reference in New Issue
Block a user