2020-11-07 17:59:37 +02:00
|
|
|
import { PluginStates } from '@joplin/lib/services/plugins/reducer';
|
2020-03-10 01:24:57 +02:00
|
|
|
import * as React from 'react';
|
2020-10-09 19:35:46 +02:00
|
|
|
import NoteListUtils from './utils/NoteListUtils';
|
2020-03-10 01:24:57 +02:00
|
|
|
|
2020-11-07 17:59:37 +02:00
|
|
|
const { buildStyle } = require('@joplin/lib/theme');
|
2021-10-01 20:35:27 +02:00
|
|
|
const bridge = require('@electron/remote').require('./bridge').default;
|
2020-03-10 01:24:57 +02:00
|
|
|
|
|
|
|
interface MultiNoteActionsProps {
|
2020-11-12 21:29:22 +02:00
|
|
|
themeId: number;
|
|
|
|
selectedNoteIds: string[];
|
|
|
|
notes: any[];
|
2023-06-30 11:30:29 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-types -- Old code before rule was applied
|
2020-11-12 21:29:22 +02:00
|
|
|
dispatch: Function;
|
|
|
|
watchedNoteFiles: string[];
|
|
|
|
plugins: PluginStates;
|
2020-11-17 13:50:46 +02:00
|
|
|
inConflictFolder: boolean;
|
2021-05-19 15:00:16 +02:00
|
|
|
customCss: string;
|
2020-03-10 01:24:57 +02:00
|
|
|
}
|
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
function styles_(props: MultiNoteActionsProps) {
|
|
|
|
return buildStyle('MultiNoteActions', props.themeId, (theme: any) => {
|
2020-03-10 01:24:57 +02:00
|
|
|
return {
|
|
|
|
root: {
|
|
|
|
display: 'inline-flex',
|
|
|
|
justifyContent: 'center',
|
|
|
|
paddingTop: theme.marginTop,
|
2020-09-15 15:01:07 +02:00
|
|
|
width: '100%',
|
2020-03-10 01:24:57 +02:00
|
|
|
},
|
|
|
|
itemList: {
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'column',
|
|
|
|
},
|
|
|
|
button: {
|
|
|
|
...theme.buttonStyle,
|
|
|
|
marginBottom: 10,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
export default function MultiNoteActions(props: MultiNoteActionsProps) {
|
2020-03-10 01:24:57 +02:00
|
|
|
const styles = styles_(props);
|
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
const multiNotesButton_click = (item: any) => {
|
2020-03-10 01:24:57 +02:00
|
|
|
if (item.submenu) {
|
2023-02-22 20:15:21 +02:00
|
|
|
item.submenu.popup({ window: bridge().window() });
|
2020-03-10 01:24:57 +02:00
|
|
|
} else {
|
|
|
|
item.click();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const menu = NoteListUtils.makeContextMenu(props.selectedNoteIds, {
|
|
|
|
notes: props.notes,
|
|
|
|
dispatch: props.dispatch,
|
|
|
|
watchedNoteFiles: props.watchedNoteFiles,
|
2020-10-09 19:35:46 +02:00
|
|
|
plugins: props.plugins,
|
2020-11-17 13:50:46 +02:00
|
|
|
inConflictFolder: props.inConflictFolder,
|
2021-05-19 15:00:16 +02:00
|
|
|
customCss: props.customCss,
|
2020-03-10 01:24:57 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
const itemComps = [];
|
|
|
|
const menuItems = menu.items;
|
|
|
|
|
|
|
|
for (let i = 0; i < menuItems.length; i++) {
|
|
|
|
const item = menuItems[i];
|
|
|
|
if (!item.enabled) continue;
|
|
|
|
|
|
|
|
itemComps.push(
|
|
|
|
<button key={item.label} style={styles.button} onClick={() => multiNotesButton_click(item)}>
|
|
|
|
{item.label}
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div style={styles.root}>
|
|
|
|
<div style={styles.itemList}>{itemComps}</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|