mirror of https://github.com/laurent22/joplin.git
Desktop: Make "toggle all folders" button also expand the folder list (#11917)
parent
b831d8c068
commit
1924dd31d2
|
@ -1026,6 +1026,7 @@ packages/lib/commands/renderMarkup.test.js
|
|||
packages/lib/commands/renderMarkup.js
|
||||
packages/lib/commands/showEditorPlugin.js
|
||||
packages/lib/commands/synchronize.js
|
||||
packages/lib/commands/toggleAllFolders.test.js
|
||||
packages/lib/commands/toggleAllFolders.js
|
||||
packages/lib/commands/toggleEditorPlugin.js
|
||||
packages/lib/components/EncryptionConfigScreen/utils.test.js
|
||||
|
|
|
@ -1001,6 +1001,7 @@ packages/lib/commands/renderMarkup.test.js
|
|||
packages/lib/commands/renderMarkup.js
|
||||
packages/lib/commands/showEditorPlugin.js
|
||||
packages/lib/commands/synchronize.js
|
||||
packages/lib/commands/toggleAllFolders.test.js
|
||||
packages/lib/commands/toggleAllFolders.js
|
||||
packages/lib/commands/toggleEditorPlugin.js
|
||||
packages/lib/components/EncryptionConfigScreen/utils.test.js
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
import { setupDatabase, switchClient } from '../testing/test-utils';
|
||||
import { runtime } from './toggleAllFolders';
|
||||
import Setting from '../models/Setting';
|
||||
import { CommandContext } from '../services/CommandService';
|
||||
import { defaultState } from '../reducer';
|
||||
|
||||
const command = runtime();
|
||||
|
||||
const makeContext = (): CommandContext => {
|
||||
return {
|
||||
state: defaultState,
|
||||
dispatch: ()=>{},
|
||||
};
|
||||
};
|
||||
|
||||
describe('toggleAllFolders', () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
await setupDatabase(0);
|
||||
await switchClient(0);
|
||||
});
|
||||
|
||||
test('expanding all should expand the folders header, if previously collapsed', async () => {
|
||||
Setting.setValue('folderHeaderIsExpanded', false);
|
||||
|
||||
// Collapsing all should leave the folder header as-is
|
||||
const context = makeContext();
|
||||
await command.execute(context, true);
|
||||
expect(Setting.value('folderHeaderIsExpanded')).toBe(false);
|
||||
|
||||
// Expanding all should also expand the folder header
|
||||
await command.execute(context, false);
|
||||
expect(Setting.value('folderHeaderIsExpanded')).toBe(true);
|
||||
});
|
||||
|
||||
});
|
|
@ -1,6 +1,7 @@
|
|||
import { CommandRuntime, CommandDeclaration, CommandContext } from '../services/CommandService';
|
||||
import { _ } from '../locale';
|
||||
import getCanBeCollapsedFolderIds from '../models/utils/getCanBeCollapsedFolderIds';
|
||||
import Setting from '../models/Setting';
|
||||
|
||||
export const declaration: CommandDeclaration = {
|
||||
name: 'toggleAllFolders',
|
||||
|
@ -10,6 +11,10 @@ export const declaration: CommandDeclaration = {
|
|||
export const runtime = (): CommandRuntime => {
|
||||
return {
|
||||
execute: async (context: CommandContext, collapseAll: boolean) => {
|
||||
if (!collapseAll && !Setting.value('folderHeaderIsExpanded')) {
|
||||
Setting.setValue('folderHeaderIsExpanded', true);
|
||||
}
|
||||
|
||||
context.dispatch({
|
||||
type: 'FOLDER_SET_COLLAPSED',
|
||||
ids: collapseAll ? getCanBeCollapsedFolderIds(context.state.folders) : [],
|
||||
|
|
Loading…
Reference in New Issue