From 6b86181999dbe0e5c03b4fe86ecc44647dd309d9 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 19 Feb 2024 10:30:14 +0100 Subject: [PATCH] implement terminal bar func --- .../lib/components/remix-ui-terminal-bar.tsx | 14 ++++----- .../src/lib/reducers/terminalReducer.ts | 19 +++++++++++- .../terminal/src/lib/remix-ui-terminal.tsx | 29 ++++++++----------- .../terminal/src/lib/types/terminalTypes.ts | 2 ++ 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/libs/remix-ui/terminal/src/lib/components/remix-ui-terminal-bar.tsx b/libs/remix-ui/terminal/src/lib/components/remix-ui-terminal-bar.tsx index 118ba1422e..5bea69856c 100644 --- a/libs/remix-ui/terminal/src/lib/components/remix-ui-terminal-bar.tsx +++ b/libs/remix-ui/terminal/src/lib/components/remix-ui-terminal-bar.tsx @@ -1,13 +1,12 @@ import { CustomTooltip } from '@remix-ui/helper' -import React, { useState, useEffect, useReducer, useRef, useContext } from 'react' // eslint-disable-line +import React, { useState, useEffect, useRef, useContext } from 'react' // eslint-disable-line import { FormattedMessage, useIntl } from 'react-intl' +import { listenOnNetworkAction } from '../actions/terminalAction' import { TerminalContext } from '../context/context' -import { initialState, registerCommandReducer } from '../reducers/terminalReducer' import { RemixUiTerminalProps } from '../types/terminalTypes' export const RemixUITerminalBar = (props: RemixUiTerminalProps) => { const { newstate: state, dispatch } = useContext(TerminalContext) - const [isVM, setIsVM] = useState(false) const intl = useIntl() const terminalMenu = useRef(null) @@ -28,11 +27,12 @@ export const RemixUITerminalBar = (props: RemixUiTerminalProps) => { } function listenOnNetwork(event: any): void { - throw new Error('Function not implemented.') + const isListening = event.target.checked + listenOnNetworkAction(props.plugin, isListening) } function setSearchInput(arg0: string): void { - throw new Error('Function not implemented.') + dispatch({ type: 'search', payload: arg0 }) } return (<> @@ -62,7 +62,7 @@ export const RemixUITerminalBar = (props: RemixUiTerminalProps) => { placement="top" tooltipId="terminalClear" tooltipClasses="text-nowrap" - tooltipText={intl.formatMessage({ id: isVM ? 'terminal.listenVM' : 'terminal.listenTitle' })} + tooltipText={intl.formatMessage({ id: state.isVM ? 'terminal.listenVM' : 'terminal.listenTitle' })} >
@@ -71,7 +71,7 @@ export const RemixUITerminalBar = (props: RemixUiTerminalProps) => { id="listenNetworkCheck" onChange={listenOnNetwork} type="checkbox" - disabled={isVM} + disabled={state.isVM} />