Remove "empty payload" toggle switch
This function is redundat, simply send an empty message wil suffice
This commit is contained in:
@@ -17,12 +17,6 @@ export const setPayload = (payload?: string): Action => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const toggleEmptyPayload = (): Action => {
|
|
||||||
return {
|
|
||||||
type: ActionTypes.PUBLISH_TOGGLE_EMPTY_PAYLOAD,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const setQoS = (qos: 0 | 1 | 2): Action => {
|
export const setQoS = (qos: 0 | 1 | 2): Action => {
|
||||||
return {
|
return {
|
||||||
qos,
|
qos,
|
||||||
@@ -48,7 +42,7 @@ export const publish = (connectionId: string) => (dispatch: Dispatch<Action>, ge
|
|||||||
const publishEvent = makePublishEvent(connectionId)
|
const publishEvent = makePublishEvent(connectionId)
|
||||||
const mqttMessage = {
|
const mqttMessage = {
|
||||||
topic,
|
topic,
|
||||||
payload: state.publish.emptyPayload ? null : state.publish.payload,
|
payload: state.publish.payload,
|
||||||
retain: state.publish.retain,
|
retain: state.publish.retain,
|
||||||
qos: state.publish.qos,
|
qos: state.publish.qos,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ interface Props {
|
|||||||
topic?: string
|
topic?: string
|
||||||
payload?: string
|
payload?: string
|
||||||
actions: typeof publishActions
|
actions: typeof publishActions
|
||||||
emptyPayload: boolean
|
|
||||||
retain: boolean
|
retain: boolean
|
||||||
editorMode: string
|
editorMode: string
|
||||||
qos: 0 | 1 | 2
|
qos: 0 | 1 | 2
|
||||||
@@ -164,9 +163,6 @@ class Publish extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private renderEditorModeSelection() {
|
private renderEditorModeSelection() {
|
||||||
if (this.props.emptyPayload) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
const labelStyle = { margin: '0 8px 0 8px' }
|
const labelStyle = { margin: '0 8px 0 8px' }
|
||||||
return (
|
return (
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
@@ -234,20 +230,13 @@ class Publish extends React.Component<Props, State> {
|
|||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
<div style={{ marginTop: '8px', clear: 'both' }}>
|
<div style={{ marginTop: '8px', clear: 'both' }}>
|
||||||
<div style={{ width: '100%' }}>
|
<div style={{ width: '100%', textAlign: 'right' }}>
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
style={labelStyle}
|
style={labelStyle}
|
||||||
control={qosSelect}
|
control={qosSelect}
|
||||||
label="QoS"
|
label="QoS"
|
||||||
labelPlacement="start"
|
labelPlacement="start"
|
||||||
/>
|
/>
|
||||||
<FormControlLabel
|
|
||||||
value="empty"
|
|
||||||
style={labelStyle}
|
|
||||||
control={<Checkbox color="primary" checked={this.props.emptyPayload} onChange={this.props.actions.toggleEmptyPayload} />}
|
|
||||||
label="no message"
|
|
||||||
labelPlacement="end"
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
value="retain"
|
value="retain"
|
||||||
style={labelStyle}
|
style={labelStyle}
|
||||||
@@ -286,10 +275,6 @@ class Publish extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private renderEditor() {
|
private renderEditor() {
|
||||||
if (this.props.emptyPayload) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AceEditor
|
<AceEditor
|
||||||
mode={this.props.editorMode}
|
mode={this.props.editorMode}
|
||||||
@@ -317,7 +302,6 @@ const mapStateToProps = (state: AppState) => {
|
|||||||
return {
|
return {
|
||||||
topic: state.publish.topic,
|
topic: state.publish.topic,
|
||||||
payload: state.publish.payload,
|
payload: state.publish.payload,
|
||||||
emptyPayload: state.publish.emptyPayload,
|
|
||||||
editorMode: state.publish.editorMode,
|
editorMode: state.publish.editorMode,
|
||||||
retain: state.publish.retain,
|
retain: state.publish.retain,
|
||||||
qos: state.publish.qos,
|
qos: state.publish.qos,
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ class TreeNodeTitle extends React.Component<TreeNodeProps, {}> {
|
|||||||
marginLeft: '5px',
|
marginLeft: '5px',
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
}
|
}
|
||||||
return this.props.treeNode.message
|
|
||||||
|
return this.props.treeNode.message && this.props.treeNode.message.length > 0
|
||||||
? <span style={style}> = {this.props.treeNode.message.value.toString()}</span>
|
? <span style={style}> = {this.props.treeNode.message.value.toString()}</span>
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,18 +4,16 @@ import { createReducer } from './lib'
|
|||||||
export interface PublishState {
|
export interface PublishState {
|
||||||
topic?: string
|
topic?: string
|
||||||
payload?: string
|
payload?: string
|
||||||
emptyPayload: boolean
|
|
||||||
retain: boolean
|
retain: boolean
|
||||||
editorMode: string
|
editorMode: string
|
||||||
qos: 0 | 1 | 2
|
qos: 0 | 1 | 2
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Action = SetPayload | SetTopic | ToggleEmptyPayload | ToggleRetain | SetEditorMode | SetQoS
|
export type Action = SetPayload | SetTopic | ToggleRetain | SetEditorMode | SetQoS
|
||||||
|
|
||||||
export enum ActionTypes {
|
export enum ActionTypes {
|
||||||
PUBLISH_SET_TOPIC = 'PUBLISH_SET_TOPIC',
|
PUBLISH_SET_TOPIC = 'PUBLISH_SET_TOPIC',
|
||||||
PUBLISH_SET_PAYLOAD = 'PUBLISH_SET_PAYLOAD',
|
PUBLISH_SET_PAYLOAD = 'PUBLISH_SET_PAYLOAD',
|
||||||
PUBLISH_TOGGLE_EMPTY_PAYLOAD = 'PUBLISH_TOGGLE_EMPTY_PAYLOAD',
|
|
||||||
PUBLISH_TOGGLE_RETAIN = 'PUBLISH_TOGGLE_RETAIN',
|
PUBLISH_TOGGLE_RETAIN = 'PUBLISH_TOGGLE_RETAIN',
|
||||||
PUBLISH_SET_EDITOR_MODE = 'PUBLISH_SET_EDITOR_MODE',
|
PUBLISH_SET_EDITOR_MODE = 'PUBLISH_SET_EDITOR_MODE',
|
||||||
PUBLISH_SET_QOS = 'PUBLISH_SET_QOS',
|
PUBLISH_SET_QOS = 'PUBLISH_SET_QOS',
|
||||||
@@ -36,10 +34,6 @@ export interface SetQoS {
|
|||||||
qos: 0 | 1 | 2
|
qos: 0 | 1 | 2
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ToggleEmptyPayload {
|
|
||||||
type: ActionTypes.PUBLISH_TOGGLE_EMPTY_PAYLOAD
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SetEditorMode {
|
export interface SetEditorMode {
|
||||||
type: ActionTypes.PUBLISH_SET_EDITOR_MODE
|
type: ActionTypes.PUBLISH_SET_EDITOR_MODE
|
||||||
editorMode: string
|
editorMode: string
|
||||||
@@ -51,7 +45,6 @@ export interface ToggleRetain {
|
|||||||
|
|
||||||
const initialState: PublishState = {
|
const initialState: PublishState = {
|
||||||
editorMode: 'text',
|
editorMode: 'text',
|
||||||
emptyPayload: false,
|
|
||||||
retain: false,
|
retain: false,
|
||||||
qos: 0,
|
qos: 0,
|
||||||
}
|
}
|
||||||
@@ -59,7 +52,6 @@ const initialState: PublishState = {
|
|||||||
export const publishReducer = createReducer(initialState, {
|
export const publishReducer = createReducer(initialState, {
|
||||||
PUBLISH_SET_TOPIC: setTopic,
|
PUBLISH_SET_TOPIC: setTopic,
|
||||||
PUBLISH_SET_PAYLOAD: setPayload,
|
PUBLISH_SET_PAYLOAD: setPayload,
|
||||||
PUBLISH_TOGGLE_EMPTY_PAYLOAD: toggleEmptyPayload,
|
|
||||||
PUBLISH_TOGGLE_RETAIN: toggleRetain,
|
PUBLISH_TOGGLE_RETAIN: toggleRetain,
|
||||||
PUBLISH_SET_EDITOR_MODE: setEditorMode,
|
PUBLISH_SET_EDITOR_MODE: setEditorMode,
|
||||||
PUBLISH_SET_QOS: setQoS,
|
PUBLISH_SET_QOS: setQoS,
|
||||||
@@ -93,13 +85,6 @@ function setEditorMode(state: PublishState, action: SetEditorMode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleEmptyPayload(state: PublishState) {
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
emptyPayload: !state.emptyPayload,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleRetain(state: PublishState) {
|
function toggleRetain(state: PublishState) {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|||||||
Reference in New Issue
Block a user