Skip to content

Commit

Permalink
Desktop: Resolves #7934: Add Simple Backup as a default plugin (#9360)
Browse files Browse the repository at this point in the history
  • Loading branch information
personalizedrefrigerator authored Dec 11, 2023
1 parent 6306a0f commit 4fc786c
Show file tree
Hide file tree
Showing 42 changed files with 754 additions and 378 deletions.
14 changes: 12 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ packages/app-mobile/locales
packages/app-mobile/node_modules
packages/app-mobile/pluginAssets/
packages/fork-*
packages/default-plugins/plugin-base-repo/
packages/default-plugins/plugin-sources/
packages/htmlpack/dist/
packages/lib/assets/
packages/lib/lib/lib.js
Expand Down Expand Up @@ -380,10 +382,12 @@ packages/app-desktop/gui/style/StyledTextInput.js
packages/app-desktop/gui/utils/NoteListUtils.js
packages/app-desktop/gui/utils/convertToScreenCoordinates.js
packages/app-desktop/gui/utils/loadScript.js
packages/app-desktop/gulpfile.js
packages/app-desktop/integration-tests/main.spec.js
packages/app-desktop/integration-tests/models/MainScreen.js
packages/app-desktop/integration-tests/models/NoteEditorScreen.js
packages/app-desktop/integration-tests/models/SettingsScreen.js
packages/app-desktop/integration-tests/simpleBackup.spec.js
packages/app-desktop/integration-tests/util/activateMainMenuItem.js
packages/app-desktop/integration-tests/util/createStartupArgs.js
packages/app-desktop/integration-tests/util/firstNonDevToolsWindow.js
Expand Down Expand Up @@ -415,6 +419,7 @@ packages/app-desktop/services/sortOrder/PerFolderSortOrderService.js
packages/app-desktop/services/sortOrder/notesSortOrderUtils.test.js
packages/app-desktop/services/sortOrder/notesSortOrderUtils.js
packages/app-desktop/services/spellChecker/SpellCheckerServiceDriverNative.js
packages/app-desktop/tools/copy7Zip.js
packages/app-desktop/tools/notarizeMacApp.js
packages/app-desktop/tools/renameReleaseAssets.js
packages/app-desktop/utils/checkForUpdatesUtils.test.js
Expand Down Expand Up @@ -530,6 +535,13 @@ packages/app-mobile/utils/fs-driver/runOnDeviceTests.js
packages/app-mobile/utils/setupNotifications.js
packages/app-mobile/utils/shareHandler.js
packages/app-mobile/utils/types.js
packages/default-plugins/build.js
packages/default-plugins/buildDefaultPlugins.js
packages/default-plugins/commands/buildAll.js
packages/default-plugins/commands/editPatch.js
packages/default-plugins/utils/getPathToPatchFileFor.js
packages/default-plugins/utils/readRepositoryJson.js
packages/default-plugins/utils/waitForCliInput.js
packages/editor/CodeMirror/CodeMirror5Emulation/CodeMirror5Emulation.test.js
packages/editor/CodeMirror/CodeMirror5Emulation/CodeMirror5Emulation.js
packages/editor/CodeMirror/CodeMirror5Emulation/Decorator.js
Expand Down Expand Up @@ -1013,8 +1025,6 @@ packages/tools/build-translation.js
packages/tools/build-welcome.js
packages/tools/buildServerDocker.test.js
packages/tools/buildServerDocker.js
packages/tools/bundleDefaultPlugins.test.js
packages/tools/bundleDefaultPlugins.js
packages/tools/checkIgnoredFiles.js
packages/tools/checkLibPaths.test.js
packages/tools/checkLibPaths.js
Expand Down
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,12 @@ packages/app-desktop/gui/style/StyledTextInput.js
packages/app-desktop/gui/utils/NoteListUtils.js
packages/app-desktop/gui/utils/convertToScreenCoordinates.js
packages/app-desktop/gui/utils/loadScript.js
packages/app-desktop/gulpfile.js
packages/app-desktop/integration-tests/main.spec.js
packages/app-desktop/integration-tests/models/MainScreen.js
packages/app-desktop/integration-tests/models/NoteEditorScreen.js
packages/app-desktop/integration-tests/models/SettingsScreen.js
packages/app-desktop/integration-tests/simpleBackup.spec.js
packages/app-desktop/integration-tests/util/activateMainMenuItem.js
packages/app-desktop/integration-tests/util/createStartupArgs.js
packages/app-desktop/integration-tests/util/firstNonDevToolsWindow.js
Expand Down Expand Up @@ -397,6 +399,7 @@ packages/app-desktop/services/sortOrder/PerFolderSortOrderService.js
packages/app-desktop/services/sortOrder/notesSortOrderUtils.test.js
packages/app-desktop/services/sortOrder/notesSortOrderUtils.js
packages/app-desktop/services/spellChecker/SpellCheckerServiceDriverNative.js
packages/app-desktop/tools/copy7Zip.js
packages/app-desktop/tools/notarizeMacApp.js
packages/app-desktop/tools/renameReleaseAssets.js
packages/app-desktop/utils/checkForUpdatesUtils.test.js
Expand Down Expand Up @@ -512,6 +515,13 @@ packages/app-mobile/utils/fs-driver/runOnDeviceTests.js
packages/app-mobile/utils/setupNotifications.js
packages/app-mobile/utils/shareHandler.js
packages/app-mobile/utils/types.js
packages/default-plugins/build.js
packages/default-plugins/buildDefaultPlugins.js
packages/default-plugins/commands/buildAll.js
packages/default-plugins/commands/editPatch.js
packages/default-plugins/utils/getPathToPatchFileFor.js
packages/default-plugins/utils/readRepositoryJson.js
packages/default-plugins/utils/waitForCliInput.js
packages/editor/CodeMirror/CodeMirror5Emulation/CodeMirror5Emulation.test.js
packages/editor/CodeMirror/CodeMirror5Emulation/CodeMirror5Emulation.js
packages/editor/CodeMirror/CodeMirror5Emulation/Decorator.js
Expand Down Expand Up @@ -995,8 +1005,6 @@ packages/tools/build-translation.js
packages/tools/build-welcome.js
packages/tools/buildServerDocker.test.js
packages/tools/buildServerDocker.js
packages/tools/bundleDefaultPlugins.test.js
packages/tools/bundleDefaultPlugins.js
packages/tools/checkIgnoredFiles.js
packages/tools/checkLibPaths.test.js
packages/tools/checkLibPaths.js
Expand Down
4 changes: 3 additions & 1 deletion .npmpackagejsonlintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
packages/app-clipper/popup/
packages/app-cli/tests/support/plugins/
packages/doc-builder/
packages/doc-builder/
packages/default-plugins/plugin-base-repo/
packages/default-plugins/plugin-sources/
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,11 @@ describe('defaultPluginsUtils', () => {

const defaultPluginsInfo: DefaultPluginsInfo = {
'io.github.jackgruber.backup': {
version: '1.0.2',
settings: {
'path': `${Setting.value('profileDir')}`,
},
},
'plugin.calebjohn.rich-markdown': {
version: '0.8.3',
},
};

Expand Down Expand Up @@ -245,14 +243,12 @@ describe('defaultPluginsUtils', () => {

const defaultPluginsInfo: DefaultPluginsInfo = {
'io.github.jackgruber.backup': {
version: '1.0.2',
settings: {
'path': `${Setting.value('profileDir')}`,
'missing-key1': 'someValue',
},
},
'plugin.calebjohn.rich-markdown': {
version: '0.8.3',
settings: {
'missing-key2': 'someValue',
},
Expand Down
3 changes: 3 additions & 0 deletions packages/app-desktop/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ test-results/
playwright-report/
playwright/.cache/
integration-tests/test-profile/
build/defaultPlugins/
build/7zip/7za
build/7zip/7za.exe
7 changes: 6 additions & 1 deletion packages/app-desktop/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { reg } from '@joplin/lib/registry';
const packageInfo: PackageInfo = require('./packageInfo.js');
import DecryptionWorker from '@joplin/lib/services/DecryptionWorker';
import ClipperServer from '@joplin/lib/ClipperServer';
const { webFrame } = require('electron');
import { ipcRenderer, webFrame } from 'electron';
const Menu = bridge().Menu;
const PluginManager = require('@joplin/lib/services/PluginManager');
import RevisionService from '@joplin/lib/services/RevisionService';
Expand Down Expand Up @@ -333,6 +333,11 @@ class Application extends BaseApplication {
type: 'STARTUP_PLUGINS_LOADED',
value: true,
});

// Sends an event to the main process -- this is used by the Playwright
// tests to wait for plugins to load.
ipcRenderer.send('startup-plugins-loaded');

setSettingsForDefaultPlugins(getDefaultPluginsInfo());
}
}, 500);
Expand Down
90 changes: 90 additions & 0 deletions packages/app-desktop/build/7zip/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
7-Zip
~~~~~
License for use and distribution
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

7-Zip Copyright (C) 1999-2023 Igor Pavlov.

The licenses for files are:

1) 7z.dll:
- The "GNU LGPL" as main license for most of the code
- The "GNU LGPL" with "unRAR license restriction" for some code
- The "BSD 3-clause License" for some code
2) All other files: the "GNU LGPL".

Redistributions in binary form must reproduce related license information from this file.

Note:
You can use 7-Zip on any computer, including a computer in a commercial
organization. You don't need to register or pay for 7-Zip.


GNU LGPL information
--------------------

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You can receive a copy of the GNU Lesser General Public License from
http://www.gnu.org/




BSD 3-clause License
--------------------

The "BSD 3-clause License" is used for the code in 7z.dll that implements LZFSE data decompression.
That code was derived from the code in the "LZFSE compression library" developed by Apple Inc,
that also uses the "BSD 3-clause License":

----
Copyright (c) 2015-2016, Apple Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder(s) nor the names of any contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----




unRAR license restriction
-------------------------

The decompression engine for RAR archives was developed using source
code of unRAR program.
All copyrights to original unRAR code are owned by Alexander Roshal.

The license for original unRAR code has the following restriction:

The unRAR sources cannot be used to re-create the RAR compression algorithm,
which is proprietary. Distribution of modified unRAR sources in separate form
or as a part of other software is permitted, provided that it is clearly
stated in the documentation and source comments that the code may
not be used to develop a RAR (WinRAR) compatible archiver.


--
Igor Pavlov
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const CellRoot = styled.div<{ isCompatible: boolean }>`
box-sizing: border-box;
background-color: ${props => props.theme.backgroundColor};
flex-direction: column;
align-items: flex-start;
align-items: stretch;
padding: 15px;
border: 1px solid ${props => props.theme.dividerColor};
border-radius: 6px;
Expand Down Expand Up @@ -96,12 +96,15 @@ const NeedUpgradeMessage = styled.span`
font-size: ${props => props.theme.fontSize}px;
`;

const DevModeLabel = styled.div`
const BoxedLabel = styled.div`
border: 1px solid ${props => props.theme.color};
border-radius: 4px;
padding: 4px 6px;
font-size: ${props => props.theme.fontSize * 0.75}px;
color: ${props => props.theme.color};
flex-grow: 0;
height: min-content;
margin-top: auto;
`;

const StyledNameAndVersion = styled.div<{ mb: any }>`
Expand Down Expand Up @@ -170,7 +173,7 @@ export default function(props: Props) {
if (!props.onToggle) return null;

if (item.devMode) {
return <DevModeLabel>DEV</DevModeLabel>;
return <BoxedLabel>DEV</BoxedLabel>;
}

return <ToggleButton
Expand Down Expand Up @@ -217,6 +220,17 @@ export default function(props: Props) {
/>;
}

const renderDefaultPluginLabel = () => {
// Built-in plugins can only be disabled
if (item.manifest._built_in) {
return (
<BoxedLabel>{_('Built in')}</BoxedLabel>
);
}

return null;
};

function renderFooter() {
if (item.devMode) return null;

Expand All @@ -236,6 +250,7 @@ export default function(props: Props) {
{renderInstallButton()}
{renderUpdateButton()}
<div style={{ display: 'flex', flex: 1 }}/>
{renderDefaultPluginLabel()}
</CellFooter>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,18 @@ export default function(props: Props) {
let cancelled = false;

async function fetchPluginIds() {
const pluginIds = await repoApi().canBeUpdatedPlugins(pluginItems.map(p => p.manifest), pluginService.appVersion);
// Built-in plugins can't be updated from the main repoApi
const nonDefaultPlugins = pluginItems
.map(p => p.manifest)
.filter(manifest => !manifest._built_in);

const pluginIds = await repoApi().canBeUpdatedPlugins(nonDefaultPlugins, pluginService.appVersion);
if (cancelled) return;

const conv: Record<string, boolean> = {};
// eslint-disable-next-line github/array-foreach -- Old code before rule was applied
pluginIds.forEach(id => conv[id] = true);
for (const id of pluginIds) {
conv[id] = true;
}
setCanBeUpdatedPluginIds(conv);
}

Expand Down Expand Up @@ -281,10 +288,17 @@ export default function(props: Props) {
</UserPluginsRoot>
);
} else {
const nonDefaultPlugins = pluginItems.filter(item => !item.manifest._built_in);
const defaultPlugins = pluginItems.filter(item => item.manifest._built_in);
return (
<UserPluginsRoot>
{renderCells(pluginItems)}
</UserPluginsRoot>
<>
<UserPluginsRoot>
{renderCells(nonDefaultPlugins)}
</UserPluginsRoot>
<UserPluginsRoot>
{renderCells(defaultPlugins)}
</UserPluginsRoot>
</>
);
}
}
Expand Down
Loading

0 comments on commit 4fc786c

Please sign in to comment.