Compare commits

..

6 Commits

Author SHA1 Message Date
Valtteri Karesto
58cde29fff Update next-auth to fix dependabot alert 2022-08-08 09:07:45 +03:00
muzamil
a06fb06610 Merge pull request #264 from XRPLF/fix/tab-switching
Switch to correct tab after renaming/closing.
2022-08-05 16:23:38 +05:30
muzam1l
1f5a9731bb Readonly files are not renamable now! 2022-08-04 18:54:20 +05:30
muzam1l
ef4f95ca3e Switch to correct tab after renaming/closing. 2022-08-03 16:02:17 +05:30
muzamil
fb9814ec76 Merge pull request #262 from XRPLF/fix/script-log-appending
Clear script log on running new script.
2022-08-03 14:33:59 +05:30
muzam1l
d459b2ee92 Clear script log on running new script. 2022-08-01 17:04:26 +05:30
8 changed files with 64 additions and 66 deletions

View File

@@ -32,7 +32,6 @@ import { SetHookDialog } from "./SetHookDialog";
import { addFunds } from "../state/actions/addFaucetAccount";
import { deleteHook } from "../state/actions/deployHook";
import { capitalize } from "../utils/helpers";
import { deleteAccount } from '../state/actions/deleteAccount';
export const AccountDialog = ({
activeAccountAddress,
@@ -100,7 +99,10 @@ export const AccountDialog = ({
css={{ ml: "auto", mr: "$9" }}
tabIndex={-1}
onClick={() => {
deleteAccount(activeAccount?.address);
const index = state.accounts.findIndex(
acc => acc.address === activeAccount?.address
);
state.accounts.splice(index, 1);
}}
>
Delete Account <Trash size="15px" />

View File

@@ -24,13 +24,19 @@ import { saveAllFiles } from "../state/actions/saveFile";
import { Tab, Tabs } from "./Tabs";
import { renameFile } from "../state/actions/createNewFile";
const validateWritability = (editor: monaco.editor.IStandaloneCodeEditor) => {
const currPath = editor.getModel()?.uri.path;
if (apiHeaderFiles.find(h => currPath?.endsWith(h))) {
editor.updateOptions({ readOnly: true });
} else {
editor.updateOptions({ readOnly: false });
const checkWritable = (filename?: string): boolean => {
if (apiHeaderFiles.find(file => file === filename)) {
return false;
}
return true;
};
const validateWritability = (
editor: monaco.editor.IStandaloneCodeEditor
) => {
const filename = editor.getModel()?.uri.path.split("/").pop();
const isWritable = checkWritable(filename);
editor.updateOptions({ readOnly: !isWritable });
};
let decorations: { [key: string]: string[] } = {};
@@ -138,7 +144,7 @@ const HooksEditor = () => {
}}
>
{snap.files.map((file, index) => {
return <Tab key={file.name} header={file.name} />;
return <Tab key={file.name} header={file.name} renameDisabled={!checkWritable(file.name)} />;
})}
</Tabs>
);

View File

@@ -162,7 +162,7 @@ export const Log: FC<ILog> = ({
const enrichAccounts = useCallback(
(str?: string): ReactNode => {
if (!str || !accounts.length) return str;
if (!str || !accounts.length) return null;
const pattern = `(${accounts.map(acc => acc.address).join("|")})`;
const res = regexifyString({

View File

@@ -143,7 +143,6 @@ const RunScript: React.FC<{ file: IFile }> = ({ file: { content, name } }) => {
setIframeCode(template);
state.scriptLogs = [
...snap.scriptLogs,
{ type: "success", message: "Started running..." },
];
} catch (err) {

View File

@@ -31,6 +31,7 @@ type Nullable<T> = T | null | undefined | false;
interface TabProps {
header: string;
children?: ReactNode;
renameDisabled?: boolean
}
// TODO customize messages shown
@@ -98,16 +99,15 @@ export const Tabs = ({
}, [tabname, setTabnameError]);
const validateTabname = useCallback(
(tabname: string): { error?: string, result?: string } => {
(tabname: string): { error?: string; result?: string } => {
if (!tabname) {
return { error: `Please enter ${label.toLocaleLowerCase()} name.` };
}
let ext =
(tabname.includes(".") && tabname.split(".").pop()) || "";
let ext = (tabname.includes(".") && tabname.split(".").pop()) || "";
if (!ext && defaultExtension) {
ext = defaultExtension
tabname = `${tabname}.${defaultExtension}`
ext = defaultExtension;
tabname = `${tabname}.${defaultExtension}`;
}
if (tabs.find(tab => tab.header === tabname)) {
return { error: `${capitalize(label)} name already exists.` };
@@ -153,16 +153,23 @@ export const Tabs = ({
return;
}
const { result: _tabname = tabname } = res
const { result: nwName = tabname } = res;
setRenamingTab(null);
setTabname("");
const oldName = tabs[renamingTab]?.header;
onRenameTab?.(renamingTab, _tabname, oldName);
onRenameTab?.(renamingTab, nwName, oldName);
handleActiveChange(renamingTab);
}, [handleActiveChange, onRenameTab, renamingTab, tabname, tabs, validateTabname]);
handleActiveChange(renamingTab, nwName);
}, [
handleActiveChange,
onRenameTab,
renamingTab,
tabname,
tabs,
validateTabname,
]);
const handleCreateTab = useCallback(() => {
const res = validateTabname(tabname);
@@ -170,7 +177,7 @@ export const Tabs = ({
setTabnameError(`Error: ${res.error}`);
return;
}
const { result: _tabname = tabname } = res
const { result: _tabname = tabname } = res;
setIsNewtabDialogOpen(false);
setTabname("");
@@ -178,17 +185,22 @@ export const Tabs = ({
onCreateNewTab?.(_tabname);
handleActiveChange(tabs.length, _tabname);
}, [validateTabname, tabname, onCreateNewTab, handleActiveChange, tabs.length]);
}, [
validateTabname,
tabname,
onCreateNewTab,
handleActiveChange,
tabs.length,
]);
const handleCloseTab = useCallback(
(idx: number) => {
if (idx <= active && active !== 0) {
setActive(active - 1);
}
onCloseTab?.(idx, tabs[idx].header);
handleActiveChange(idx, tabs[idx].header);
if (idx <= active && active !== 0) {
const nwActive = active - 1
handleActiveChange(nwActive, tabs[nwActive].header);
}
},
[active, handleActiveChange, onCloseTab, tabs]
);
@@ -200,13 +212,16 @@ export const Tabs = ({
key: "close",
onSelect: () => handleCloseTab(idx),
};
const renameOption = (idx: number): Nullable<ContentMenuOption> =>
onRenameTab && {
type: "text",
label: "Rename",
key: "rename",
onSelect: () => setRenamingTab(idx),
};
const renameOption = (idx: number, tab: TabProps): Nullable<ContentMenuOption> => {
return (
onRenameTab && !tab.renameDisabled && {
type: "text",
label: "Rename",
key: "rename",
onSelect: () => setRenamingTab(idx),
}
);
}
return (
<>
@@ -225,7 +240,7 @@ export const Tabs = ({
<ContextMenu
key={tab.header}
options={
[closeOption(idx), renameOption(idx)].filter(
[closeOption(idx), renameOption(idx, tab)].filter(
Boolean
) as ContentMenuOption[]
}

View File

@@ -36,7 +36,7 @@
"lodash.xor": "^4.5.0",
"monaco-editor": "^0.33.0",
"next": "^12.0.4",
"next-auth": "^4.10.1",
"next-auth": "^4.10.3",
"next-plausible": "^3.2.0",
"next-themes": "^0.1.1",
"normalize-url": "^7.0.2",
@@ -80,4 +80,4 @@
"resolutions": {
"ripple-binary-codec": "=1.4.2"
}
}
}

View File

@@ -1,24 +0,0 @@
import state, { transactionsState } from '..';
export const deleteAccount = (addr?: string) => {
if (!addr) return;
const index = state.accounts.findIndex(acc => acc.address === addr);
if (index === -1) return;
state.accounts.splice(index, 1);
// update selected accounts
transactionsState.transactions
.filter(t => t.state.selectedAccount?.value === addr)
.forEach(t => {
const acc = t.state.selectedAccount;
if (!acc) return;
acc.label = acc.value;
});
transactionsState.transactions
.filter(t => t.state.selectedDestAccount?.value === addr)
.forEach(t => {
const acc = t.state.selectedDestAccount;
if (!acc) return;
acc.label = acc.value;
});
};

View File

@@ -2953,10 +2953,10 @@ natural-compare@^1.4.0:
resolved "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz"
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
next-auth@^4.10.1:
version "4.10.1"
resolved "https://registry.yarnpkg.com/next-auth/-/next-auth-4.10.1.tgz#33b29265d12287bb2f6d267c8d415a407c27f0e9"
integrity sha512-F00vtwBdyMIIJ8IORHOAOHjVGTDEhhm9+HpB2BQ8r40WtGxqToWWLN7Z+2ZW/z2RFlo3zhcuAtUCPUzVJxtZwQ==
next-auth@^4.10.3:
version "4.10.3"
resolved "https://registry.yarnpkg.com/next-auth/-/next-auth-4.10.3.tgz#0a952dd5004fd2ac2ba414c990922cf9b33951a3"
integrity sha512-7zc4aXYc/EEln7Pkcsn21V1IevaTZsMLJwapfbnKA4+JY0+jFzWbt5p/ljugesGIrN4VOZhpZIw50EaFZyghJQ==
dependencies:
"@babel/runtime" "^7.16.3"
"@panva/hkdf" "^1.0.1"