Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: add color rename dialog

thecodrrb6433257a7ac
diff --git a/apps/web/src/common/dialogcontroller.js b/apps/web/src/common/dialogcontroller.js
index d064089d0..bbbb68907 100644
--- a/apps/web/src/common/dialogcontroller.js
+++ b/apps/web/src/common/dialogcontroller.js
@@ -14,6 +14,7 @@ import download from "../utils/download";
import { zip } from "../utils/zip";
import Config from "../utils/config";
import Dialogs from "../components/dialogs";
+import { toTitleCase } from "../utils/string";
function showDialog(dialog) {
const root = document.getElementById("dialogContainer");
@@ -572,6 +573,26 @@ export function showEditTagDialog(tagId) {
));
}
+export function showRenameColorDialog(colorId) {
+ const color = db.colors.tag(colorId);
+ if (!color) return;
+ return showDialog((Dialogs, perform) => (
+ <Dialogs.ItemDialog
+ title={"Rename color"}
+ subtitle={`You are renaming color ${toTitleCase(color.title)}.`}
+ item={color}
+ onClose={() => perform(false)}
+ onAction={async (title) => {
+ if (!title) return;
+ await db.colors.rename(colorId, title);
+ showToast("success", "Color renamed!");
+ appStore.refreshColors();
+ perform(true);
+ }}
+ />
+ ));
+}
+
export function showSessionExpiredDialog(email) {
return showDialog((Dialogs, perform) => (
<Dialogs.SessionExpiredDialog
diff --git a/apps/web/src/components/navigation-menu/index.js b/apps/web/src/components/navigation-menu/index.js
index 0dcd9b262..2c85e4be4 100644
--- a/apps/web/src/components/navigation-menu/index.js
+++ b/apps/web/src/components/navigation-menu/index.js
@@ -12,6 +12,7 @@ import { COLORS } from "../../common";
import { db } from "../../common/db";
import useMobile from "../../utils/use-mobile";
import { useLocation } from "wouter";
+import { showRenameColorDialog } from "../../common/dialog-controller";
function shouldSelectNavItem(route, pin) {
if (pin.type === "notebook") {
@@ -135,13 +136,25 @@ function NavigationMenu(props) {
{colors.map((color) => (
<NavigationItem
key={color.id}
- title={toTitleCase(color.title)}
+ title={toTitleCase(color.alias || color.title)}
icon={Icon.Circle}
selected={location === `/colors/${color.id}`}
color={COLORS[color.title]}
onClick={() => {
navigate(`/colors/${color.id}`);
}}
+ menu={{
+ items: [
+ {
+ key: "rename",
+ title: () => "Rename color",
+ onClick: async ({ color }) => {
+ await showRenameColorDialog(color.id);
+ },
+ },
+ ],
+ extraData: { color },
+ }}
/>
))}
<Box width="85%" height="0.8px" bg="border" alignSelf="center" my={1} />