1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Revert "Desktop: Resolve #3695: Show notebook and note title in the title bar (#4390)"

This reverts commit c79c9c4c2f.

Reason: Still need to discuss how it should be implemented. Ref:

https://discourse.joplinapp.org/t/testing-v1-8-2-title-bar-path-format-minor/16937/10
This commit is contained in:
Laurent Cozic 2021-05-04 10:34:18 +02:00
parent eb82ae87ca
commit a0ead2c48e
5 changed files with 9 additions and 94 deletions

View File

@ -616,12 +616,6 @@ packages/app-desktop/gui/ToolbarButton/styles/index.js.map
packages/app-desktop/gui/dialogs.d.ts
packages/app-desktop/gui/dialogs.js
packages/app-desktop/gui/dialogs.js.map
packages/app-desktop/gui/getWindowTitle.d.ts
packages/app-desktop/gui/getWindowTitle.js
packages/app-desktop/gui/getWindowTitle.js.map
packages/app-desktop/gui/getWindowTitle.test.d.ts
packages/app-desktop/gui/getWindowTitle.test.js
packages/app-desktop/gui/getWindowTitle.test.js.map
packages/app-desktop/gui/hooks/useEffectDebugger.d.ts
packages/app-desktop/gui/hooks/useEffectDebugger.js
packages/app-desktop/gui/hooks/useEffectDebugger.js.map

6
.gitignore vendored
View File

@ -603,12 +603,6 @@ packages/app-desktop/gui/ToolbarButton/styles/index.js.map
packages/app-desktop/gui/dialogs.d.ts
packages/app-desktop/gui/dialogs.js
packages/app-desktop/gui/dialogs.js.map
packages/app-desktop/gui/getWindowTitle.d.ts
packages/app-desktop/gui/getWindowTitle.js
packages/app-desktop/gui/getWindowTitle.js.map
packages/app-desktop/gui/getWindowTitle.test.d.ts
packages/app-desktop/gui/getWindowTitle.test.js
packages/app-desktop/gui/getWindowTitle.test.js.map
packages/app-desktop/gui/hooks/useEffectDebugger.d.ts
packages/app-desktop/gui/hooks/useEffectDebugger.js
packages/app-desktop/gui/hooks/useEffectDebugger.js.map

View File

@ -1,19 +1,22 @@
const React = require('react');
const Component = React.Component;
const Setting = require('@joplin/lib/models/Setting').default;
const { connect } = require('react-redux');
const bridge = require('electron').remote.require('./bridge').default;
const getWindowTitle = require('./getWindowTitle').default;
class NavigatorComponent extends Component {
constructor(props) {
super(props);
}
UNSAFE_componentWillReceiveProps(newProps) {
if (newProps.route) {
this.updateWindowTitle(getWindowTitle(newProps.notes, newProps.selectedNoteIds, newProps.selectedFolderId, newProps.folders, newProps.screens, newProps.route));
const screenInfo = this.props.screens[newProps.route.routeName];
const devMarker = Setting.value('env') === 'dev' ? ' (DEV)' : '';
const windowTitle = [`Joplin${devMarker}`];
if (screenInfo.title) {
windowTitle.push(screenInfo.title());
}
this.updateWindowTitle(windowTitle.join(' - '));
}
}
updateWindowTitle(title) {
try {
if (bridge().window()) bridge().window().setTitle(title);
@ -46,10 +49,6 @@ class NavigatorComponent extends Component {
const Navigator = connect(state => {
return {
route: state.route,
selectedNoteIds: state.selectedNoteIds,
selectedFolderId: state.selectedFolderId,
folders: state.folders,
notes: state.notes,
};
})(NavigatorComponent);

View File

@ -1,47 +0,0 @@
import getWindowTitle from './getWindowTitle';
const Setting = require('@joplin/lib/models/Setting').default;
const props: any = {
'screens': { 'Main': {}, 'DropboxLogin': { title: function() { return 'Dropbox Login'; } } },
'route': { 'type': 'NAV_GO', 'routeName': 'Main', 'props': {} },
'selectedNoteIds': ['1ce557cf187249e38f2458c78c20d09a'],
'selectedFolderId': 'cea30a191961480ea7284861e90d5a54',
'folders': [
{
'id': '349fcee65ad14fb2b64e69746c29a2d9',
'title': 'self care',
},
{
'id': 'cea30a191961480ea7284861e90d5a54',
'title': 'testbook',
}],
'notes': [{
'id': '1ce557cf187249e38f2458c78c20d09a',
'title': 'Open source projects to contribute',
'parent_id': 'cea30a191961480ea7284861e90d5a54',
}],
};
describe('Get Window Title', () => {
Setting.setConstant('env', 'dev');
test('Should produce string as Folder > Note', () => {
const title = getWindowTitle(props.notes, props.selectedNoteIds, props.selectedFolderId, props.folders, props.screens, props.route);
expect(title).toBe('testbook > Open source projects to contribute - Joplin (DEV)');
});
test('When no note is selected', () => {
const title = getWindowTitle(props.notes, [], props.selectedFolderId, props.folders, props.screens, props.route);
expect(title).toBe('testbook - Joplin (DEV)');
});
test('When no folder is selected', () => {
const title = getWindowTitle(props.notes, props.selectedNoteIds, null, props.folders, props.screens, props.route);
expect(title).toBe('testbook > Open source projects to contribute - Joplin (DEV)');
});
test('When no note and folder is selected', () => {
const title = getWindowTitle(props.notes, [], null, props.folders, props.screens, props.route);
expect(title).toBe('Joplin (DEV)');
});
test('When not on main screen (dropbox login)', () => {
const title = getWindowTitle(props.notes, props.selectedNoteIds, props.selectedFolderId, props.folders, props.screens, { 'type': 'NAV_GO', 'routeName': 'DropboxLogin', 'props': {} });
expect(title).toBe('Dropbox Login - Joplin (DEV)');
});
});

View File

@ -1,25 +0,0 @@
const Setting = require('@joplin/lib/models/Setting').default;
import BaseModel from '@joplin/lib/BaseModel';
import { _ } from '@joplin/lib/locale';
const { substrWithEllipsis } = require('@joplin/lib/string-utils');
export default function getWindowTitle(notes: any[], selectedNoteIds: string[], selectedFolderId: string, folders: any[], screens: any, route: { type: string; routeName: string; props: any}) {
const windowTitle = [];
const note = selectedNoteIds.length ? BaseModel.byId(notes, selectedNoteIds[0]) : null;
const folderId = note ? note.parent_id : selectedFolderId;
const folder = folderId ? BaseModel.byId(folders, folderId) : null;
const screenInfo = screens[route.routeName];
if (screenInfo.title) {
windowTitle.push(screenInfo.title());
} else if (route.routeName == 'Main' && folder) {
const folderTitle = folder.title;
if (note) {
const noteTitle = note.title.length ? note.title : _('Untitled');
windowTitle.push(`${substrWithEllipsis(folderTitle, 0, 30)} > ${substrWithEllipsis(noteTitle, 0, 50)}`);
} else { windowTitle.push(folderTitle); }
}
const devMarker = Setting.value('env') === 'dev' ? ' (DEV)' : '';
windowTitle.push(`Joplin${devMarker}`);
return windowTitle.join(' - ');
}