links in activity log open explorer
This commit is contained in:
parent
cc17641f51
commit
d484826923
4 changed files with 30 additions and 10 deletions
|
@ -1,6 +1,12 @@
|
||||||
export const ACTIVITYPUB_EXPLORER_DATA ='ACTIVITYPUB_EXPLORER_DATA';
|
export const ACTIVITYPUB_EXPLORER_DATA ='ACTIVITYPUB_EXPLORER_DATA';
|
||||||
|
export const ACTIVITYPUB_EXPLORER_URL ='ACTIVITYPUB_EXPLORER_URL';
|
||||||
|
|
||||||
export const setExplorerData = (value) => ({
|
export const setExplorerData = (value) => ({
|
||||||
type: ACTIVITYPUB_EXPLORER_DATA,
|
type: ACTIVITYPUB_EXPLORER_DATA,
|
||||||
value,
|
value,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const setExplorerUrl = (value) => ({
|
||||||
|
type: ACTIVITYPUB_EXPLORER_URL,
|
||||||
|
value,
|
||||||
|
});
|
||||||
|
|
|
@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
|
||||||
import Column from 'mastodon/components/column';
|
import Column from 'mastodon/components/column';
|
||||||
import ColumnHeader from 'mastodon/components/column_header';
|
import ColumnHeader from 'mastodon/components/column_header';
|
||||||
import { HotKeys } from 'react-hotkeys';
|
import { HotKeys } from 'react-hotkeys';
|
||||||
import { setExplorerData } from 'mastodon/actions/activitypub_explorer';
|
import { setExplorerData, setExplorerUrl } from 'mastodon/actions/activitypub_explorer';
|
||||||
import DismissableBanner from 'mastodon/components/dismissable_banner';
|
import DismissableBanner from 'mastodon/components/dismissable_banner';
|
||||||
|
|
||||||
import { ActivityPubVisualization } from 'activitypub-visualization';
|
import { ActivityPubVisualization } from 'activitypub-visualization';
|
||||||
|
@ -77,10 +77,19 @@ class ActivityLog extends ImmutablePureComponent {
|
||||||
|
|
||||||
<HotKeys handlers={handlers}>
|
<HotKeys handlers={handlers}>
|
||||||
<div className={`${darkMode ? 'dark' : ''}`}>
|
<div className={`${darkMode ? 'dark' : ''}`}>
|
||||||
<ActivityPubVisualization logs={logs} showExplorerLink onExplorerLinkClick={(data) => {
|
<ActivityPubVisualization
|
||||||
dispatch(setExplorerData(data));
|
logs={logs}
|
||||||
this.context.router.history.push('/activitypub_explorer');
|
clickableLinks
|
||||||
}} />
|
onLinkClick={(url) => {
|
||||||
|
dispatch(setExplorerUrl(url));
|
||||||
|
this.context.router.history.push('/activitypub_explorer');
|
||||||
|
}}
|
||||||
|
showExplorerLink
|
||||||
|
onExplorerLinkClick={(data) => {
|
||||||
|
dispatch(setExplorerData(data));
|
||||||
|
this.context.router.history.push('/activitypub_explorer');
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</HotKeys>
|
</HotKeys>
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
|
||||||
import Column from 'mastodon/components/column';
|
import Column from 'mastodon/components/column';
|
||||||
import ColumnHeader from 'mastodon/components/column_header';
|
import ColumnHeader from 'mastodon/components/column_header';
|
||||||
import DismissableBanner from 'mastodon/components/dismissable_banner';
|
import DismissableBanner from 'mastodon/components/dismissable_banner';
|
||||||
import { setExplorerData } from 'mastodon/actions/activitypub_explorer';
|
import { setExplorerData, setExplorerUrl } from 'mastodon/actions/activitypub_explorer';
|
||||||
|
|
||||||
import { ActivityPubExplorer as Explorer } from 'activitypub-visualization';
|
import { ActivityPubExplorer as Explorer } from 'activitypub-visualization';
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ import { ActivityPubExplorer as Explorer } from 'activitypub-visualization';
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
return {
|
return {
|
||||||
data: state.getIn(['activitypub_explorer', 'data']),
|
data: state.getIn(['activitypub_explorer', 'data']),
|
||||||
|
url: state.getIn(['activitypub_explorer', 'url']),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,14 +34,15 @@ class ActivityPubExplorer extends ImmutablePureComponent {
|
||||||
this.column = c;
|
this.column = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount () {
|
componentWillUnmount () {
|
||||||
// clear explorer data on unbound so that we start with a clean slate on next navigation
|
// clear explorer data on unbound so that we start with a clean slate on next navigation
|
||||||
this.props.dispatch(setExplorerData(null));
|
this.props.dispatch(setExplorerData(null));
|
||||||
|
this.props.dispatch(setExplorerUrl(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
const { data, multiColumn } = this.props;
|
const { data, url, multiColumn } = this.props;
|
||||||
|
|
||||||
const darkMode = !(document.body && document.body.classList.contains('theme-mastodon-light'));
|
const darkMode = !(document.body && document.body.classList.contains('theme-mastodon-light'));
|
||||||
|
|
||||||
|
@ -66,7 +68,7 @@ class ActivityPubExplorer extends ImmutablePureComponent {
|
||||||
</DismissableBanner>
|
</DismissableBanner>
|
||||||
|
|
||||||
<div className={`${darkMode ? 'dark' : ''}`}>
|
<div className={`${darkMode ? 'dark' : ''}`}>
|
||||||
<Explorer initialValue={data} />
|
<Explorer initialValue={data} initialUrl={url} />
|
||||||
</div>
|
</div>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
import { Map as ImmutableMap } from 'immutable';
|
import { Map as ImmutableMap } from 'immutable';
|
||||||
import { ACTIVITYPUB_EXPLORER_DATA } from '../actions/activitypub_explorer';
|
import { ACTIVITYPUB_EXPLORER_DATA, ACTIVITYPUB_EXPLORER_URL } from '../actions/activitypub_explorer';
|
||||||
|
|
||||||
const initialState = ImmutableMap({
|
const initialState = ImmutableMap({
|
||||||
data: null,
|
data: null,
|
||||||
|
url: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function activitypub_explorer(state = initialState, action) {
|
export default function activitypub_explorer(state = initialState, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case ACTIVITYPUB_EXPLORER_DATA:
|
case ACTIVITYPUB_EXPLORER_DATA:
|
||||||
return state.set('data', action.value);
|
return state.set('data', action.value);
|
||||||
|
case ACTIVITYPUB_EXPLORER_URL:
|
||||||
|
return state.set('url', action.value);
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue