Desktop: Added detailed tooltip for 'Toggle Sort Order Field' button (#5854)

pull/5862/head
Kenichi Kobayashi 2021-12-14 00:29:23 +09:00 committed by GitHub
parent deb300326b
commit 7ce9ae11c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -5,6 +5,8 @@ import SearchBar from '../SearchBar/SearchBar';
import Button, { ButtonLevel, ButtonSize, buttonSizePx } from '../Button/Button';
import CommandService from '@joplin/lib/services/CommandService';
import { runtime as focusSearchRuntime } from './commands/focusSearch';
import Note from '@joplin/lib/models/Note';
import { notesSortOrderNextField } from '../../services/sortOrder/notesSortOrderUtils';
const { connect } = require('react-redux');
const styled = require('styled-components').default;
@ -81,6 +83,14 @@ function NoteListControls(props: Props) {
void CommandService.instance().execute('toggleNotesSortOrderReverse');
}
function sortOrderFieldTooltip() {
const term1 = CommandService.instance().label('toggleNotesSortOrderField');
const field = props.sortOrderField;
const term2 = Note.fieldToLabel(field);
const term3 = Note.fieldToLabel(notesSortOrderNextField(field));
return `${term1}:\n ${term2} -> ${term3}`;
}
function sortOrderFieldIcon() {
const field = props.sortOrderField;
const iconMap: any = {
@ -110,7 +120,7 @@ function NoteListControls(props: Props) {
{showsSortOrderButtons() &&
<StyledPairButtonL
className="sort-order-field-button"
tooltip={CommandService.instance().label('toggleNotesSortOrderField')}
tooltip={sortOrderFieldTooltip()}
iconName={sortOrderFieldIcon()}
level={ButtonLevel.Secondary}
size={ButtonSize.Small}