💄 confirmation modal to confirm deletion of model
This commit is contained in:
parent
83e0535251
commit
2e266595a8
5 changed files with 83 additions and 27 deletions
54
gui/src/components/dialogs/ConfirmationDialog.tsx
Normal file
54
gui/src/components/dialogs/ConfirmationDialog.tsx
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import { useDispatch } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import { Button } from "..";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
|
||||
const GridDiv = styled.div`
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: 8px;
|
||||
align-items: center;
|
||||
`;
|
||||
|
||||
interface ConfirmationDialogProps {
|
||||
onConfirm: () => void;
|
||||
onCancel?: () => void;
|
||||
text: string;
|
||||
}
|
||||
|
||||
function ConfirmationDialog(props: ConfirmationDialogProps) {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
<h3>Confirmation</h3>
|
||||
<p>{props.text}</p>
|
||||
|
||||
<GridDiv>
|
||||
<Button
|
||||
onClick={() => {
|
||||
props.onCancel?.();
|
||||
dispatch(setShowDialog(false));
|
||||
dispatch(setDialogMessage(undefined));
|
||||
}}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
props.onConfirm();
|
||||
dispatch(setShowDialog(false));
|
||||
dispatch(setDialogMessage(undefined));
|
||||
}}
|
||||
>
|
||||
Confirm
|
||||
</Button>
|
||||
</GridDiv>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ConfirmationDialog;
|
||||
|
|
@ -16,7 +16,7 @@ const ScreenCover = styled.div`
|
|||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: ${parseColorForHex(VSC_BACKGROUND_VAR)}aa;
|
||||
z-index: 100;
|
||||
z-index: 1000;
|
||||
`;
|
||||
|
||||
const DialogContainer = styled.div`
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ interface ContinueInputBoxProps {
|
|||
|
||||
editorState?: JSONContent;
|
||||
contextItems?: ContextItemWithId[];
|
||||
hidden?: boolean;
|
||||
}
|
||||
|
||||
function ContinueInputBox(props: ContinueInputBoxProps) {
|
||||
|
|
@ -92,6 +93,7 @@ function ContinueInputBox(props: ContinueInputBoxProps) {
|
|||
style={{
|
||||
paddingTop: "4px",
|
||||
backgroundColor: vscBackground,
|
||||
display: props.hidden ? "none" : "inherit",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -20,10 +20,15 @@ import {
|
|||
} from "..";
|
||||
import { defaultModelSelector } from "../../redux/selectors/modelSelectors";
|
||||
import { setDefaultModel } from "../../redux/slices/stateSlice";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
import { RootStore } from "../../redux/store";
|
||||
import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import { postToIde } from "../../util/ide";
|
||||
import HeaderButtonWithText from "../HeaderButtonWithText";
|
||||
import ConfirmationDialog from "../dialogs/ConfirmationDialog";
|
||||
|
||||
const GridDiv = styled.div`
|
||||
display: grid;
|
||||
|
|
@ -118,6 +123,7 @@ function ListBoxOption({
|
|||
idx: number;
|
||||
showDelete?: boolean;
|
||||
}) {
|
||||
const dispatch = useDispatch();
|
||||
const [hovered, setHovered] = useState(false);
|
||||
|
||||
return (
|
||||
|
|
@ -144,7 +150,17 @@ function ListBoxOption({
|
|||
<HeaderButtonWithText
|
||||
text="Delete"
|
||||
onClick={(e) => {
|
||||
postToIde("config/deleteModel", { title: option.title });
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<ConfirmationDialog
|
||||
text={`Are you sure you want to delete this model? (${option.title})`}
|
||||
onConfirm={() => {
|
||||
postToIde("config/deleteModel", { title: option.title });
|
||||
}}
|
||||
/>
|
||||
)
|
||||
);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ import { newSession, setInactive } from "../redux/slices/stateSlice";
|
|||
import {
|
||||
setDialogEntryOn,
|
||||
setDialogMessage,
|
||||
setDisplayBottomMessageOnBottom,
|
||||
setShowDialog,
|
||||
} from "../redux/slices/uiStateSlice";
|
||||
import { RootStore } from "../redux/store";
|
||||
|
|
@ -166,22 +165,6 @@ function GUI(props: GUIProps) {
|
|||
const topGuiDivRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
// #region Effects
|
||||
|
||||
// Set displayBottomMessageOnBottom
|
||||
const aboveComboBoxDivRef = useRef<HTMLDivElement>(null);
|
||||
const bottomMessage = useSelector(
|
||||
(state: RootStore) => state.uiState.bottomMessage
|
||||
);
|
||||
useEffect(() => {
|
||||
if (!aboveComboBoxDivRef.current) return;
|
||||
dispatch(
|
||||
setDisplayBottomMessageOnBottom(
|
||||
aboveComboBoxDivRef.current.getBoundingClientRect().top <
|
||||
window.innerHeight / 2
|
||||
)
|
||||
);
|
||||
}, [bottomMessage, aboveComboBoxDivRef.current]);
|
||||
|
||||
const [userScrolledAwayFromBottom, setUserScrolledAwayFromBottom] =
|
||||
useState<boolean>(false);
|
||||
|
||||
|
|
@ -388,6 +371,7 @@ function GUI(props: GUIProps) {
|
|||
>
|
||||
{item.message.role === "user" ? (
|
||||
<ContinueInputBox
|
||||
key={index}
|
||||
onEnter={async (editorState) => {
|
||||
streamResponse(editorState, index);
|
||||
}}
|
||||
|
|
@ -448,14 +432,14 @@ function GUI(props: GUIProps) {
|
|||
})}
|
||||
</StepsDiv>
|
||||
|
||||
<div ref={aboveComboBoxDivRef} />
|
||||
{active || (
|
||||
<ContinueInputBox
|
||||
onEnter={sendInput}
|
||||
isLastUserInput={false}
|
||||
isMainInput={true}
|
||||
></ContinueInputBox>
|
||||
)}
|
||||
<ContinueInputBox
|
||||
key={state.history.length}
|
||||
onEnter={sendInput}
|
||||
isLastUserInput={false}
|
||||
isMainInput={true}
|
||||
hidden={active}
|
||||
></ContinueInputBox>
|
||||
|
||||
{active ? (
|
||||
<>
|
||||
<br />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue