Compare commits
1 Commits
fix/update
...
fix/dest-f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aae9c7468f |
@@ -24,19 +24,13 @@ import { saveAllFiles } from "../state/actions/saveFile";
|
||||
import { Tab, Tabs } from "./Tabs";
|
||||
import { renameFile } from "../state/actions/createNewFile";
|
||||
|
||||
const checkWritable = (filename?: string): boolean => {
|
||||
if (apiHeaderFiles.find(file => file === filename)) {
|
||||
return false;
|
||||
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 });
|
||||
}
|
||||
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[] } = {};
|
||||
@@ -144,7 +138,7 @@ const HooksEditor = () => {
|
||||
}}
|
||||
>
|
||||
{snap.files.map((file, index) => {
|
||||
return <Tab key={file.name} header={file.name} renameDisabled={!checkWritable(file.name)} />;
|
||||
return <Tab key={file.name} header={file.name} />;
|
||||
})}
|
||||
</Tabs>
|
||||
);
|
||||
|
||||
@@ -31,7 +31,6 @@ type Nullable<T> = T | null | undefined | false;
|
||||
interface TabProps {
|
||||
header: string;
|
||||
children?: ReactNode;
|
||||
renameDisabled?: boolean
|
||||
}
|
||||
|
||||
// TODO customize messages shown
|
||||
@@ -99,15 +98,16 @@ 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,23 +153,16 @@ export const Tabs = ({
|
||||
return;
|
||||
}
|
||||
|
||||
const { result: nwName = tabname } = res;
|
||||
const { result: _tabname = tabname } = res
|
||||
|
||||
setRenamingTab(null);
|
||||
setTabname("");
|
||||
|
||||
const oldName = tabs[renamingTab]?.header;
|
||||
onRenameTab?.(renamingTab, nwName, oldName);
|
||||
onRenameTab?.(renamingTab, _tabname, oldName);
|
||||
|
||||
handleActiveChange(renamingTab, nwName);
|
||||
}, [
|
||||
handleActiveChange,
|
||||
onRenameTab,
|
||||
renamingTab,
|
||||
tabname,
|
||||
tabs,
|
||||
validateTabname,
|
||||
]);
|
||||
handleActiveChange(renamingTab);
|
||||
}, [handleActiveChange, onRenameTab, renamingTab, tabname, tabs, validateTabname]);
|
||||
|
||||
const handleCreateTab = useCallback(() => {
|
||||
const res = validateTabname(tabname);
|
||||
@@ -177,7 +170,7 @@ export const Tabs = ({
|
||||
setTabnameError(`Error: ${res.error}`);
|
||||
return;
|
||||
}
|
||||
const { result: _tabname = tabname } = res;
|
||||
const { result: _tabname = tabname } = res
|
||||
|
||||
setIsNewtabDialogOpen(false);
|
||||
setTabname("");
|
||||
@@ -185,22 +178,17 @@ 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);
|
||||
|
||||
if (idx <= active && active !== 0) {
|
||||
const nwActive = active - 1
|
||||
handleActiveChange(nwActive, tabs[nwActive].header);
|
||||
}
|
||||
handleActiveChange(idx, tabs[idx].header);
|
||||
},
|
||||
[active, handleActiveChange, onCloseTab, tabs]
|
||||
);
|
||||
@@ -212,16 +200,13 @@ export const Tabs = ({
|
||||
key: "close",
|
||||
onSelect: () => handleCloseTab(idx),
|
||||
};
|
||||
const renameOption = (idx: number, tab: TabProps): Nullable<ContentMenuOption> => {
|
||||
return (
|
||||
onRenameTab && !tab.renameDisabled && {
|
||||
type: "text",
|
||||
label: "Rename",
|
||||
key: "rename",
|
||||
onSelect: () => setRenamingTab(idx),
|
||||
}
|
||||
);
|
||||
}
|
||||
const renameOption = (idx: number): Nullable<ContentMenuOption> =>
|
||||
onRenameTab && {
|
||||
type: "text",
|
||||
label: "Rename",
|
||||
key: "rename",
|
||||
onSelect: () => setRenamingTab(idx),
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -240,7 +225,7 @@ export const Tabs = ({
|
||||
<ContextMenu
|
||||
key={tab.header}
|
||||
options={
|
||||
[closeOption(idx), renameOption(idx, tab)].filter(
|
||||
[closeOption(idx), renameOption(idx)].filter(
|
||||
Boolean
|
||||
) as ContentMenuOption[]
|
||||
}
|
||||
|
||||
@@ -154,10 +154,12 @@ const Transaction: FC<TransactionProps> = ({
|
||||
const nwState: Partial<TransactionState> = {
|
||||
viewType,
|
||||
selectedTransaction: transactionType,
|
||||
selectedDestAccount: null
|
||||
};
|
||||
|
||||
// Currently in schema "Destination": "SomeVal" means 'Destination is required' while empty string indicates it is optional
|
||||
// TODO Update schema with clear required tag
|
||||
if (fields.Destination !== undefined) {
|
||||
nwState.selectedDestAccount = null;
|
||||
fields.Destination = "";
|
||||
} else {
|
||||
fields.Destination = undefined;
|
||||
|
||||
@@ -58,12 +58,11 @@ export const TxUI: FC<UIProps> = ({
|
||||
const fields = getTxFields(tt);
|
||||
|
||||
if (fields.Destination !== undefined) {
|
||||
setState({ selectedDestAccount: null });
|
||||
fields.Destination = "";
|
||||
} else {
|
||||
fields.Destination = undefined;
|
||||
}
|
||||
return setState({ txFields: fields });
|
||||
return setState({ txFields: fields, selectedDestAccount: null });
|
||||
},
|
||||
[setState]
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"lodash.xor": "^4.5.0",
|
||||
"monaco-editor": "^0.33.0",
|
||||
"next": "^12.0.4",
|
||||
"next-auth": "^4.10.3",
|
||||
"next-auth": "^4.10.1",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.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==
|
||||
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==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.16.3"
|
||||
"@panva/hkdf" "^1.0.1"
|
||||
|
||||
Reference in New Issue
Block a user