Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions src/components/EditorHeader/ControlPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ export default function ControlPanel({
indices: table.indices.map((index) =>
index.id === a.iid
? {
...index,
...a.undo,
}
...index,
...a.undo,
}
: index,
),
});
Expand Down Expand Up @@ -420,9 +420,9 @@ export default function ControlPanel({
indices: table.indices.map((index) =>
index.id === a.iid
? {
...index,
...a.redo,
}
...index,
...a.redo,
}
: index,
),
});
Expand Down Expand Up @@ -786,18 +786,18 @@ export default function ControlPanel({
t.id
? t
: {
...t,
id: nanoid(),
fields: t.fields.map((f) =>
f.id ? f : { ...f, id: nanoid() },
),
},
...t,
id: nanoid(),
fields: t.fields.map((f) =>
f.id ? f : { ...f, id: nanoid() },
),
},
),
);
}
setEnums(
diagram.enums.map((e) => (!e.id ? { ...e, id: nanoid() } : e)) ??
[],
[],
);
window.name = `d ${diagram.id}`;
} else {
Expand Down Expand Up @@ -829,31 +829,31 @@ export default function ControlPanel({
children: [
...(recentlyOpenedDiagrams && recentlyOpenedDiagrams.length > 0
? [
...recentlyOpenedDiagrams.map((diagram) => ({
name: diagram.name,
label: DateTime.fromJSDate(new Date(diagram.lastModified))
.setLocale(i18n.language)
.toRelative(),
function: async () => {
await loadDiagram(diagram.id);
save();
},
})),
{ divider: true },
{
name: t("see_all"),
function: () => open(),
...recentlyOpenedDiagrams.map((diagram) => ({
name: diagram.name,
label: DateTime.fromJSDate(new Date(diagram.lastModified))
.setLocale(i18n.language)
.toRelative(),
function: async () => {
await loadDiagram(diagram.id);
save();
},
]
})),
{ divider: true },
{
name: t("see_all"),
function: () => open(),
},
]
: [
{
name: t("no_saved_diagrams"),
disabled: true,
},
]),
{
name: t("no_saved_diagrams"),
disabled: true,
},
]),
],

function: () => {},
function: () => { },
},
save: {
function: save,
Expand Down Expand Up @@ -1269,7 +1269,7 @@ export default function ControlPanel({
},
},
],
function: () => {},
function: () => { },
},
exit: {
function: () => {
Expand Down Expand Up @@ -1501,7 +1501,7 @@ export default function ControlPanel({
function: () => setSettings((prev) => ({ ...prev, mode: "dark" })),
},
],
function: () => {},
function: () => { },
},
zoom_in: {
function: zoomIn,
Expand Down Expand Up @@ -1573,7 +1573,7 @@ export default function ControlPanel({
shortcut: "Ctrl+H",
},
shortcuts: {
function: () => window.open(`${socials.docs}/shortcuts`, "_blank"),
function: () => setModal(MODAL.SHORTCUTS),
},
ask_on_discord: {
function: () => window.open(socials.discord, "_blank"),
Expand Down Expand Up @@ -2050,7 +2050,7 @@ export default function ControlPanel({
type="light"
prefixIcon={
saveState === State.LOADING ||
saveState === State.SAVING ? (
saveState === State.SAVING ? (
<Spin size="small" />
) : null
}
Expand Down
17 changes: 10 additions & 7 deletions src/components/EditorHeader/Modal/Modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Open from "./Open";
import Rename from "./Rename";
import SetTableWidth from "./SetTableWidth";
import Share from "./Share";
import Shortcuts from "./Shortcuts";
import { IdContext } from "../../Workspace";
import { nanoid } from "nanoid";

Expand Down Expand Up @@ -135,18 +136,18 @@ export default function Modal({
t.id
? t
: {
...t,
id: nanoid(),
fields: t.fields.map((f) =>
f.id ? f : { ...f, id: nanoid() },
),
},
...t,
id: nanoid(),
fields: t.fields.map((f) =>
f.id ? f : { ...f, id: nanoid() },
),
},
),
);
}
setEnums(
diagram.enums.map((e) => (!e.id ? { ...e, id: nanoid() } : e)) ??
[],
[],
);
window.name = `d ${diagram.id}`;
setSaveState(State.SAVING);
Expand Down Expand Up @@ -379,6 +380,8 @@ export default function Modal({
);
case MODAL.SHARE:
return <Share title={title} setModal={setModal} />;
case MODAL.SHORTCUTS:
return <Shortcuts />;
default:
return <></>;
}
Expand Down
44 changes: 44 additions & 0 deletions src/components/EditorHeader/Modal/Shortcuts.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { useTranslation } from "react-i18next";

export default function Shortcuts() {
const { t } = useTranslation();

Check failure on line 4 in src/components/EditorHeader/Modal/Shortcuts.jsx

View workflow job for this annotation

GitHub Actions / build (20.x)

't' is assigned a value but never used

const shortcuts = [
{ action: "Open", key: "Ctrl + O" },
{ action: "Save", key: "Ctrl + S" },
{ action: "Save As", key: "Ctrl + Shift + S" },
{ action: "Undo", key: "Ctrl + Z" },
{ action: "Redo", key: "Ctrl + Y" },
{ action: "Edit", key: "Ctrl + E" },
{ action: "Cut", key: "Ctrl + X" },
{ action: "Copy", key: "Ctrl + C" },
{ action: "Paste", key: "Ctrl + V" },
{ action: "Duplicate", key: "Ctrl + D" },
{ action: "Delete", key: "Del" },
{ action: "Copy as Image", key: "Ctrl + Alt + C" },
{ action: "DBML View", key: "Alt + E" },
{ action: "Strict Mode", key: "Ctrl + Shift + M" },
{ action: "Field Details", key: "Ctrl + Shift + F" },
{ action: "Reset View", key: "Enter" },
{ action: "Show Grid", key: "Ctrl + Shift + G" },
{ action: "Zoom In", key: "Ctrl + Up" },
{ action: "Zoom Out", key: "Ctrl + Down" },
{ action: "Docs", key: "Ctrl + H" },
];

return (
<div className="grid grid-cols-2 gap-4">
{shortcuts.map((s, i) => (
<div
key={i}
className="flex justify-between items-center border-b border-zinc-200 py-2"
>
<div className="font-medium text-zinc-700">{s.action}</div>
<div className="bg-zinc-100 px-2 py-1 rounded text-sm font-mono text-zinc-600">
{s.key}
</div>
</div>
))}
</div>
);
}
1 change: 1 addition & 0 deletions src/data/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const MODAL = {
TABLE_WIDTH: 9,
LANGUAGE: 10,
SHARE: 11,
SHORTCUTS: 12,
};

export const STATUS = {
Expand Down
5 changes: 5 additions & 0 deletions src/utils/modalData.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const getModalTitle = (modal) => {
return i18n.t("language");
case MODAL.SHARE:
return i18n.t("share");
case MODAL.SHORTCUTS:
return i18n.t("keyboard_shortcuts");
default:
return "";
}
Expand All @@ -36,6 +38,7 @@ export const getModalWidth = (modal) => {
case MODAL.OPEN:
case MODAL.CODE:
case MODAL.NEW:
case MODAL.SHORTCUTS:
return 740;
default:
return 600;
Expand All @@ -60,6 +63,8 @@ export const getOkText = (modal) => {
return i18n.t("create");
case MODAL.SHARE:
return i18n.t("share");
case MODAL.SHORTCUTS:
return i18n.t("close");
default:
return i18n.t("confirm");
}
Expand Down
Loading