-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathTerminal.tsx
More file actions
executable file
·74 lines (65 loc) · 2.71 KB
/
Copy pathTerminal.tsx
File metadata and controls
executable file
·74 lines (65 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import * as React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
// Neos dependencies are provided by the UI
// @ts-ignore
import { neos } from '@neos-project/neos-ui-decorators';
// @ts-ignore
import { selectors, actions } from '@neos-project/neos-ui-redux-store';
import ReplWrapper from './components/ReplWrapper';
import { CommandsProvider } from './provider/CommandsProvider';
import { Node, I18nRegistry, FeedbackEnvelope, NeosRootState } from './interfaces';
import { actions as terminalActions, selectors as terminalSelectors } from './actions';
interface TerminalProps {
config: TerminalConfig;
user: TerminalUser;
siteNode: Node;
documentNode: Node;
focusedNodes: string[];
i18nRegistry: I18nRegistry;
terminalOpen: boolean;
toggleNeosTerminal: (visible?: boolean) => void;
handleServerFeedback: (feedback: FeedbackEnvelope) => void;
}
class Terminal extends React.PureComponent<TerminalProps> {
static propTypes = {
config: PropTypes.object.isRequired,
i18nRegistry: PropTypes.object.isRequired,
user: PropTypes.object.isRequired,
siteNode: PropTypes.object,
documentNode: PropTypes.object,
focusedNodes: PropTypes.array,
terminalOpen: PropTypes.bool,
toggleNeosTerminal: PropTypes.func,
handleServerFeedback: PropTypes.func,
};
render() {
return (
<CommandsProvider i18nRegistry={this.props.i18nRegistry}>
<ReplWrapper
config={this.props.config}
user={this.props.user}
siteNode={this.props.siteNode}
documentNode={this.props.documentNode}
terminalOpen={this.props.terminalOpen}
toggleNeosTerminal={this.props.toggleNeosTerminal}
/>
</CommandsProvider>
);
}
}
const mapStateToProps = (state: NeosRootState) => ({
user: state?.user?.name,
siteNode: selectors.CR.Nodes.siteNodeSelector(state),
documentNode: selectors.CR.Nodes.documentNodeSelector(state),
focusedNodes: selectors.CR.Nodes.focusedNodePathsSelector(state),
terminalOpen: terminalSelectors.terminalOpen(state),
});
const mapDispatchToProps = () => ({ handleServerFeedback: actions.ServerFeedback.handleServerFeedback });
const mapGlobalRegistryToProps = neos((globalRegistry: any) => ({
i18nRegistry: globalRegistry.get('i18n'),
config: globalRegistry.get('frontendConfiguration').get('Shel.Neos.Terminal:Terminal'),
}));
export default connect(() => ({}), { toggleNeosTerminal: terminalActions.toggleNeosTerminal })(
connect(mapStateToProps, mapDispatchToProps)(mapGlobalRegistryToProps(Terminal))
);