Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop: Disable built-in copy of Simple Backup by default in Joplin Portable #9907

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/app-cli/tests/services/plugins/defaultPluginsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,34 @@ describe('defaultPluginsUtils', () => {
expect(Setting.value('plugin-io.github.jackgruber.backup.path')).toBe('initial-path');
});

it('should support disabled-by-default plugins', async () => {
const service = newPluginService();

const plugin = await service.loadPluginFromJsBundle('', sampleJsBundlePlugin);
plugin.builtIn = false;
await service.runPlugin(plugin);

const defaultPluginsInfo: DefaultPluginsInfo = {
'joplin.plugin.ambrt.backlinksToNote': {
enabled: false,
},
'org.joplinapp.plugins.ToggleSidebars': {},
};
Setting.setValue('installedDefaultPlugins', []);

const { pluginSettings } = await getDefaultPluginPathsAndSettings(
testDefaultPluginsDir, defaultPluginsInfo, {}, service,
);

expect(pluginSettings).toMatchObject({
'joplin.plugin.ambrt.backlinksToNote': {
enabled: false,
deleted: false,
},
'org.joplinapp.plugins.ToggleSidebars': defaultPluginSetting(),
});
});

it('should not throw error on missing setting key', async () => {

const service = newPluginService();
Expand Down
1 change: 1 addition & 0 deletions packages/lib/services/plugins/PluginService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface SettingAndValue {

export interface DefaultPluginSettings {
settings?: SettingAndValue;
enabled?: boolean;
}

export interface DefaultPluginsInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export const getDefaultPluginPathsAndSettings = async (
// As such, we recreate the plugin state if necessary.
if (!draft[pluginId]) {
draft[pluginId] = defaultPluginSetting();

const enabledByDefault = defaultPluginsInfo[pluginId].enabled;
if (typeof enabledByDefault === 'boolean') {
draft[pluginId].enabled = enabledByDefault;
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { DefaultPluginsInfo } from '../PluginService';
import Setting from '../../../models/Setting';
import shim from '../../../shim';

const getDefaultPluginsInfo = (): DefaultPluginsInfo => {
const defaultPlugins = {
'io.github.jackgruber.backup': {
settings: {
'path': `${Setting.value('profileDir')}`,
},

// Joplin Portable is more likely to run on a device with low write speeds
// and memory. Because Simple Backup has auto-backup enabled by default,
// we disable it in Joplin Portable.
enabled: !shim.isPortable(),
},
};
return defaultPlugins;
Expand Down
Loading