commit
d018733a97
Before Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 43 KiB |
@ -0,0 +1,35 @@ |
||||
import React, { useContext, useEffect, useState } from 'react' |
||||
import { SearchContext } from '../context/context' |
||||
import { Find } from './Find' |
||||
import { OverWriteCheck } from './OverWriteCheck' |
||||
import { Replace } from './Replace' |
||||
|
||||
export const FindContainer = props => { |
||||
const { setReplaceEnabled } = useContext(SearchContext) |
||||
const [expanded, setExpanded] = useState<boolean>(false) |
||||
const toggleExpand = () => setExpanded(!expanded) |
||||
useEffect(() => { |
||||
setReplaceEnabled(expanded) |
||||
}, [expanded]) |
||||
return ( |
||||
<div className="search_plugin_find_container"> |
||||
<div |
||||
title="Toggle Replace" |
||||
data-id="toggle_replace" |
||||
className={`codicon codicon-find-${ |
||||
expanded ? 'expanded' : 'collapsed' |
||||
} search_plugin_find_container_arrow`}
|
||||
role="button" |
||||
onClick={toggleExpand} |
||||
aria-label="Toggle Replace" |
||||
aria-expanded="true" |
||||
aria-disabled="false" |
||||
></div> |
||||
<div className="search_plugin_find_container_internal"> |
||||
<Find></Find> |
||||
{expanded ?
|
||||
<><Replace></Replace><OverWriteCheck></OverWriteCheck></> : null} |
||||
</div> |
||||
</div> |
||||
) |
||||
} |
@ -0,0 +1,29 @@ |
||||
import { useDialogDispatchers } from "@remix-ui/app" |
||||
import React from "react" |
||||
import { useContext } from "react" |
||||
import { SearchContext } from "../context/context" |
||||
import * as path from 'path' |
||||
|
||||
export const Undo = () => { |
||||
const { |
||||
state, |
||||
undoReplace |
||||
} = useContext(SearchContext) |
||||
const { alert } = useDialogDispatchers() |
||||
|
||||
const undo = async () => { |
||||
try{ |
||||
await undoReplace(state.undoBuffer[`${state.workspace}/${state.currentFile}`]) |
||||
}catch(e){ |
||||
alert({ id: 'undo_error', title: 'Cannot undo this change', message: e.message }) |
||||
} |
||||
} |
||||
|
||||
return (<> |
||||
{state.undoBuffer && state.undoBuffer[`${state.workspace}/${state.currentFile}`] && state.undoBuffer[`${state.workspace}/${state.currentFile}`].visible ? |
||||
<button data-id={`undo-replace-${state.currentFile}`} disabled={!state.undoBuffer[`${state.workspace}/${state.currentFile}`].enabled} onClick={async() => await undo()} className="undo-button btn btn-secondary btn-block my-3"> |
||||
<div className="fas fa-undo mr-2"></div> |
||||
Undo changes to {path.basename(state.undoBuffer[`${state.workspace}/${state.currentFile}`].path)} |
||||
</button> : null} |
||||
</>) |
||||
} |
Loading…
Reference in new issue