Allow publishing topics with ctrl+return
This commit is contained in:
@@ -1,15 +1,17 @@
|
|||||||
import * as q from '../../../../../backend/src/Model'
|
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import ClearAdornment from '../../helper/ClearAdornment'
|
import ClearAdornment from '../../helper/ClearAdornment'
|
||||||
|
import Editor from './Editor'
|
||||||
import FormatAlignLeft from '@material-ui/icons/FormatAlignLeft'
|
import FormatAlignLeft from '@material-ui/icons/FormatAlignLeft'
|
||||||
import History from '../HistoryDrawer'
|
import History from '../HistoryDrawer'
|
||||||
import Message from './Model/Message'
|
import Message from './Model/Message'
|
||||||
import Navigation from '@material-ui/icons/Navigation'
|
import Navigation from '@material-ui/icons/Navigation'
|
||||||
|
import QosSelect from './QosSelect'
|
||||||
import { AppState } from '../../../reducers'
|
import { AppState } from '../../../reducers'
|
||||||
import { bindActionCreators } from 'redux'
|
import { bindActionCreators } from 'redux'
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
|
import { EditorModeSelect } from './EditorModeSelect'
|
||||||
import { globalActions, publishActions } from '../../../actions'
|
import { globalActions, publishActions } from '../../../actions'
|
||||||
|
import { KeyCodes } from '../../../utils/KeyCodes'
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
FormControlLabel,
|
FormControlLabel,
|
||||||
@@ -22,10 +24,6 @@ import {
|
|||||||
Theme,
|
Theme,
|
||||||
withTheme,
|
withTheme,
|
||||||
} from '@material-ui/core'
|
} from '@material-ui/core'
|
||||||
import { EditorModeSelect } from './EditorModeSelect'
|
|
||||||
import QosSelect from './QosSelect'
|
|
||||||
import Editor from './Editor'
|
|
||||||
|
|
||||||
const sha1 = require('sha1')
|
const sha1 = require('sha1')
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -61,8 +59,12 @@ class Publish extends React.Component<Props, State> {
|
|||||||
this.props.actions.setEditorMode(value)
|
this.props.actions.setEditorMode(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
private publish = (e: React.MouseEvent) => {
|
private handleClickPublish = (e: React.MouseEvent) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
this.publish()
|
||||||
|
}
|
||||||
|
|
||||||
|
private publish() {
|
||||||
if (!this.props.connectionId) {
|
if (!this.props.connectionId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -118,7 +120,7 @@ class Publish extends React.Component<Props, State> {
|
|||||||
|
|
||||||
private publishButton() {
|
private publishButton() {
|
||||||
return (
|
return (
|
||||||
<Button variant="contained" size="small" color="primary" onClick={this.publish} id="publish-button">
|
<Button variant="contained" size="small" color="primary" onClick={this.handleClickPublish} id="publish-button">
|
||||||
<Navigation style={{ marginRight: '8px' }} /> Publish
|
<Navigation style={{ marginRight: '8px' }} /> Publish
|
||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
@@ -206,9 +208,17 @@ class Publish extends React.Component<Props, State> {
|
|||||||
this.props.actions.setPayload(message.payload)
|
this.props.actions.setPayload(message.payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private handleSubmit = (e: React.KeyboardEvent) => {
|
||||||
|
if (e.keyCode === KeyCodes.enter && (e.metaKey || e.ctrlKey)) {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
|
this.publish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<div style={{ flexGrow: 1, marginLeft: '8px' }}>
|
<div style={{ flexGrow: 1, marginLeft: '8px' }} onKeyDown={this.handleSubmit}>
|
||||||
{this.topic()}
|
{this.topic()}
|
||||||
<div style={{ width: '100%', display: 'block' }}>
|
<div style={{ width: '100%', display: 'block' }}>
|
||||||
{this.editorMode()}
|
{this.editorMode()}
|
||||||
|
|||||||
Reference in New Issue
Block a user