add hotkey to go to activity log, and hotkey to copy logs
This commit is contained in:
parent
f727ee6a45
commit
a622b0b947
3 changed files with 31 additions and 13 deletions
|
@ -2,6 +2,7 @@ import React, { useEffect, useReducer, useRef } from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
import Column from 'mastodon/components/column';
|
||||
import ColumnHeader from 'mastodon/components/column_header';
|
||||
import { HotKeys } from 'react-hotkeys';
|
||||
|
||||
import dummy_data from './dummy-data.json';
|
||||
|
||||
|
@ -39,23 +40,30 @@ export default function ActivityLog({ multiColumn }) {
|
|||
|
||||
const darkMode = !(document.body && document.body.classList.contains('theme-mastodon-light'));
|
||||
|
||||
// hijack the toggleHidden shortcut to copy the logs to clipbaord
|
||||
const handlers = {
|
||||
toggleHidden: () => navigator.clipboard.writeText(JSON.stringify(logs, null, 2)),
|
||||
};
|
||||
|
||||
return (
|
||||
<Column bindToDocument={!multiColumn} ref={columnElement} label='Activity Log'>
|
||||
<ColumnHeader
|
||||
icon='comments'
|
||||
title='Activity Log'
|
||||
onClick={() => { columnElement.current.scrollTop() }}
|
||||
multiColumn={multiColumn}
|
||||
/>
|
||||
<HotKeys handlers={handlers}>
|
||||
<Column bindToDocument={!multiColumn} ref={columnElement} label='Activity Log'>
|
||||
<ColumnHeader
|
||||
icon='comments'
|
||||
title='Activity Log'
|
||||
onClick={() => { columnElement.current.scrollTop() }}
|
||||
multiColumn={multiColumn}
|
||||
/>
|
||||
|
||||
<button onClick={() => navigator.clipboard.writeText(JSON.stringify(logs, null, 2))}>Copy logs</button>
|
||||
<button onClick={() => dispatch(['reset-logs'])}>Clear logs</button>
|
||||
{/* <button onClick={() => navigator.clipboard.writeText(JSON.stringify(logs, null, 2))}>Copy logs</button> */}
|
||||
{/* <button onClick={() => dispatch(['reset-logs'])}>Clear logs</button> */}
|
||||
|
||||
<div className={`${darkMode ? 'dark' : ''}`}>
|
||||
<ActivityPubVisualization logs={logs} />
|
||||
</div>
|
||||
<div className={`${darkMode ? 'dark' : ''}`}>
|
||||
<ActivityPubVisualization logs={logs} />
|
||||
</div>
|
||||
|
||||
</Column>
|
||||
</Column>
|
||||
</HotKeys>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -158,6 +158,10 @@ class KeyboardShortcuts extends ImmutablePureComponent {
|
|||
<td><kbd>g</kbd>+<kbd>r</kbd></td>
|
||||
<td><FormattedMessage id='keyboard_shortcuts.requests' defaultMessage='to open follow requests list' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><kbd>g</kbd>+<kbd>a</kbd></td>
|
||||
<td><FormattedMessage id='keyboard_shortcuts.activity_log' defaultMessage='to open activity log' /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><kbd>?</kbd></td>
|
||||
<td><FormattedMessage id='keyboard_shortcuts.legend' defaultMessage='to display this legend' /></td>
|
||||
|
|
|
@ -106,6 +106,7 @@ const keyMap = {
|
|||
goToBlocked: 'g b',
|
||||
goToMuted: 'g m',
|
||||
goToRequests: 'g r',
|
||||
goToActivityLog: 'g a',
|
||||
toggleHidden: 'x',
|
||||
toggleSensitive: 'h',
|
||||
openMedia: 'e',
|
||||
|
@ -487,6 +488,10 @@ class UI extends React.PureComponent {
|
|||
this.context.router.history.push('/home');
|
||||
}
|
||||
|
||||
handleHotkeyGoToActivityLog = () => {
|
||||
this.context.router.history.push('/activity_log');
|
||||
}
|
||||
|
||||
handleHotkeyGoToNotifications = () => {
|
||||
this.context.router.history.push('/notifications');
|
||||
}
|
||||
|
@ -544,6 +549,7 @@ class UI extends React.PureComponent {
|
|||
focusColumn: this.handleHotkeyFocusColumn,
|
||||
back: this.handleHotkeyBack,
|
||||
goToHome: this.handleHotkeyGoToHome,
|
||||
goToActivityLog: this.handleHotkeyGoToActivityLog,
|
||||
goToNotifications: this.handleHotkeyGoToNotifications,
|
||||
goToLocal: this.handleHotkeyGoToLocal,
|
||||
goToFederated: this.handleHotkeyGoToFederated,
|
||||
|
|
Loading…
Add table
Reference in a new issue