This commit is contained in:
nickofolas 2022-01-20 11:05:12 -06:00
parent b4a78c26f3
commit bc50f5180a

@ -34,6 +34,7 @@ import Link from "@mui/material/Link";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import SettingsIcon from "@mui/icons-material/Settings"; import SettingsIcon from "@mui/icons-material/Settings";
import SyncIcon from '@mui/icons-material/Sync'; import SyncIcon from '@mui/icons-material/Sync';
import CloseIcon from '@mui/icons-material/Close';
import Table from "@mui/material/Table"; import Table from "@mui/material/Table";
import TableCell from "@mui/material/TableCell"; import TableCell from "@mui/material/TableCell";
import TableRow from "@mui/material/TableRow"; import TableRow from "@mui/material/TableRow";
@ -42,6 +43,7 @@ import { PromptEvent } from "../../ui/React/PromptManager";
import { Modal } from "../../ui/React/Modal"; import { Modal } from "../../ui/React/Modal";
import libSource from "!!raw-loader!../NetscriptDefinitions.d.ts"; import libSource from "!!raw-loader!../NetscriptDefinitions.d.ts";
import { Tooltip } from "@mui/material";
interface IProps { interface IProps {
// Map of filename -> code // Map of filename -> code
@ -700,7 +702,7 @@ export function Root(props: IProps): React.ReactElement {
if (openScript.code !== serverScriptCode) { if (openScript.code !== serverScriptCode) {
PromptEvent.emit({ PromptEvent.emit({
txt: "Do you want to overwrite " + openScript.fileName + " with the contents saved on the server?", txt: "Do you want to overwrite " + openScript.fileName + " with the contents saved on the server? This cannot be undone.",
resolve: (result: boolean) => { resolve: (result: boolean) => {
if (result) { if (result) {
// Save changes // Save changes
@ -718,7 +720,6 @@ export function Root(props: IProps): React.ReactElement {
updateRAM(openScript.code); updateRAM(openScript.code);
editorRef.current.focus(); editorRef.current.focus();
} }
rerender();
} }
}, },
}); });
@ -773,7 +774,23 @@ export function Root(props: IProps): React.ReactElement {
overflowX: "scroll", overflowX: "scroll",
}} }}
> >
{openScripts.map(({ fileName, hostname }, index) => ( {openScripts.map(({ fileName, hostname }, index) => {
const iconButtonStyle = {
maxWidth: "25px",
minWidth: "25px",
minHeight: '38.5px',
maxHeight: '38.5px',
...(currentScript?.fileName === openScripts[index].fileName ? {
background: Settings.theme.button,
borderColor: Settings.theme.button,
color: Settings.theme.primary
} : {
background: Settings.theme.backgroundsecondary,
borderColor: Settings.theme.backgroundsecondary,
color: Settings.theme.secondary
})
};
return (
<Draggable <Draggable
key={fileName + hostname} key={fileName + hostname}
draggableId={fileName + hostname} draggableId={fileName + hostname}
@ -789,6 +806,7 @@ export function Root(props: IProps): React.ReactElement {
...provided.draggableProps.style, ...provided.draggableProps.style,
marginRight: "5px", marginRight: "5px",
flexShrink: 0, flexShrink: 0,
border: '1px solid ' + Settings.theme.well,
}} }}
> >
<Button <Button
@ -797,55 +815,33 @@ export function Root(props: IProps): React.ReactElement {
e.preventDefault(); e.preventDefault();
if (e.button === 1) onTabClose(index); if (e.button === 1) onTabClose(index);
}} }}
style={ style={{
currentScript?.fileName === openScripts[index].fileName ? { ...(currentScript?.fileName === openScripts[index].fileName ? {
background: Settings.theme.button, background: Settings.theme.button,
borderColor: Settings.theme.button,
color: Settings.theme.primary color: Settings.theme.primary
} : { } : {
background: Settings.theme.backgroundsecondary, background: Settings.theme.backgroundsecondary,
borderColor: Settings.theme.backgroundsecondary,
color: Settings.theme.secondary color: Settings.theme.secondary
})
}} }}
> >
{hostname}:~/{fileName} {dirty(index)} {hostname}:~/{fileName} {dirty(index)}
</Button> </Button>
<Button <Tooltip title="Overwrite editor content with saved file content">
onClick={() => onTabClose(index)} <Button onClick={() => onTabUpdate(index)} style={iconButtonStyle} >
style={{
maxWidth: "20px",
minWidth: "20px",
...(currentScript?.fileName === openScripts[index].fileName ? {
background: Settings.theme.button,
color: Settings.theme.primary
} : {
background: Settings.theme.backgroundsecondary,
color: Settings.theme.secondary
})
}}
>
x
</Button>
<Button
onClick={() => onTabUpdate(index)}
style={{
maxWidth: "20px",
minWidth: "20px",
minHeight: '38.5px',
maxHeight: '38.5px',
...(currentScript?.fileName === openScripts[index].fileName ? {
background: Settings.theme.button,
color: Settings.theme.primary
} : {
background: Settings.theme.backgroundsecondary,
color: Settings.theme.secondary
})
}}
>
<SyncIcon fontSize='small' /> <SyncIcon fontSize='small' />
</Button> </Button>
</Tooltip>
<Button onClick={() => onTabClose(index)} style={iconButtonStyle}>
<CloseIcon fontSize='small' />
</Button>
</div> </div>
)} )}
</Draggable> </Draggable>
))} )
})}
{provided.placeholder} {provided.placeholder}
</Box> </Box>
)} )}