Merge branch 'refactor/cleanup-stray-props' into 'main'
Remove old comments and deprecated code snippets See merge request vkuchenik/website-framework!40
This commit is contained in:
@@ -11,11 +11,8 @@ import { CancelButton } from "../components/CancelButton";
|
|||||||
import { SaveButton } from "../components/SaveButton";
|
import { SaveButton } from "../components/SaveButton";
|
||||||
import DeleteAllButton from "../components/DeleteAllButton";
|
import DeleteAllButton from "../components/DeleteAllButton";
|
||||||
|
|
||||||
export function DashboardCanvas({ onCancel, isEditable, setIsEditable, isDelete, setIsDelete, view, setView, layout, setLayout, originalLayout, setOriginalLayout, onLayoutChange, onChangeView }) {
|
export function DashboardCanvas({ onCancel, isEditable, setIsEditable, isDelete, setIsDelete, view, layout, setLayout, originalLayout, setOriginalLayout, onLayoutChange, onChangeView }) {
|
||||||
// const [isEditable, setIsEditable] = useState(false); // editable=true means static=false (vice versa)
|
|
||||||
// const [isDelete, setIsDelete] = useState(false);
|
|
||||||
const [newCounter, setNewCounter] = useState(3);
|
const [newCounter, setNewCounter] = useState(3);
|
||||||
// const [originalLayout, setOriginalLayout] = useState([]);
|
|
||||||
|
|
||||||
const onAddWidget = () => {
|
const onAddWidget = () => {
|
||||||
const newId = newCounter.toString();
|
const newId = newCounter.toString();
|
||||||
@@ -55,20 +52,6 @@ export function DashboardCanvas({ onCancel, isEditable, setIsEditable, isDelete,
|
|||||||
setOriginalLayout([]) // Clear backup layout
|
setOriginalLayout([]) // Clear backup layout
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lifting up to Dashboard.jsx for prop drilling
|
|
||||||
// const onCancel = () => {
|
|
||||||
// console.log("canceling changes...");
|
|
||||||
// if (originalLayout.length) {
|
|
||||||
// setLayout(originalLayout.map(item => ({
|
|
||||||
// ...item,
|
|
||||||
// static: true
|
|
||||||
// })));
|
|
||||||
// };
|
|
||||||
// setIsEditable(false);
|
|
||||||
// setIsDelete(false);
|
|
||||||
// setOriginalLayout([]);
|
|
||||||
// }
|
|
||||||
|
|
||||||
const onDeleteWidgets = () => {
|
const onDeleteWidgets = () => {
|
||||||
console.log("Start deleting widgets...");
|
console.log("Start deleting widgets...");
|
||||||
setOriginalLayout(layout);
|
setOriginalLayout(layout);
|
||||||
@@ -102,14 +85,6 @@ export function DashboardCanvas({ onCancel, isEditable, setIsEditable, isDelete,
|
|||||||
onValueChange={(e) => {
|
onValueChange={(e) => {
|
||||||
const nextView = e.value;
|
const nextView = e.value;
|
||||||
onChangeView(nextView);
|
onChangeView(nextView);
|
||||||
// if (view === "widget" && isEditable && nextView !== "widget") {
|
|
||||||
// const confirmed = window.confirm(
|
|
||||||
// "You have unsaved changes. Do you wish to discard them and continue?"
|
|
||||||
// );
|
|
||||||
// if (!confirmed) return;
|
|
||||||
// onCancel();
|
|
||||||
// }
|
|
||||||
// setView(nextView);
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ export default function Dashboard() {
|
|||||||
view={ view }
|
view={ view }
|
||||||
onChangeView={ handleViewChange }
|
onChangeView={ handleViewChange }
|
||||||
isEditabe={ isEditable }
|
isEditabe={ isEditable }
|
||||||
// onChangeView={ setView }
|
|
||||||
/>
|
/>
|
||||||
</GridItem>
|
</GridItem>
|
||||||
<GridItem colSpan={1} width="100%" overflow="auto">
|
<GridItem colSpan={1} width="100%" overflow="auto">
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const user = {
|
|||||||
// avatar: "src\\assets\\user_profile.svg"
|
// avatar: "src\\assets\\user_profile.svg"
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Header({ view, setView, onChangeView }) {
|
export default function Header({ onChangeView }) {
|
||||||
const recipe = useRecipe({ key: "header" });
|
const recipe = useRecipe({ key: "header" });
|
||||||
const styles = recipe();
|
const styles = recipe();
|
||||||
|
|
||||||
@@ -23,8 +23,6 @@ export default function Header({ view, setView, onChangeView }) {
|
|||||||
<UserAvatarMenu
|
<UserAvatarMenu
|
||||||
name={user.name}
|
name={user.name}
|
||||||
avatar={user.avatar}
|
avatar={user.avatar}
|
||||||
view={ view }
|
|
||||||
setView={ setView }
|
|
||||||
onChangeView={ onChangeView }
|
onChangeView={ onChangeView }
|
||||||
/>
|
/>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Avatar, Menu, Portal, Box } from "@chakra-ui/react"
|
import { Avatar, Menu, Portal, Box } from "@chakra-ui/react"
|
||||||
|
|
||||||
|
|
||||||
export default function UserAvatarMenu({ view, setView, onChangeView, name, avatar }) {
|
export default function UserAvatarMenu({ onChangeView, name, avatar }) {
|
||||||
return (
|
return (
|
||||||
<Menu.Root>
|
<Menu.Root>
|
||||||
<Menu.Trigger focusRing="none">
|
<Menu.Trigger focusRing="none">
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { useSlotRecipe, Box, Button, IconButton } from "@chakra-ui/react";
|
import { useSlotRecipe, Box, Button, IconButton } from "@chakra-ui/react";
|
||||||
import { ColorModeButton, useColorMode } from "@/components/ui/color-mode";
|
import { ColorModeButton, useColorMode } from "@/components/ui/color-mode";
|
||||||
// import { Tooltip } from "@/components/ui/tooltip";
|
|
||||||
import Tooltip from "../Canvas/components/Tooltip.jsx";
|
import Tooltip from "../Canvas/components/Tooltip.jsx";
|
||||||
import { FaVolcano } from "react-icons/fa6";
|
import { FaVolcano } from "react-icons/fa6";
|
||||||
import { FaHome } from "react-icons/fa";
|
import { FaHome } from "react-icons/fa";
|
||||||
@@ -9,7 +8,6 @@ import { FaMapMarkerAlt } from "react-icons/fa";
|
|||||||
import { HiUsers } from "react-icons/hi2";
|
import { HiUsers } from "react-icons/hi2";
|
||||||
import { VscThreeBars } from "react-icons/vsc";
|
import { VscThreeBars } from "react-icons/vsc";
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { Seismic } from "../Canvas/views/DashboardCanvasNav/Seismic";
|
|
||||||
import { DASHBOARD_VIEWS } from "@/constants/viewKeys";
|
import { DASHBOARD_VIEWS } from "@/constants/viewKeys";
|
||||||
|
|
||||||
export default function Sidebar({ view, onChangeView, darkMode, setDarkMode }) {
|
export default function Sidebar({ view, onChangeView, darkMode, setDarkMode }) {
|
||||||
@@ -35,14 +33,13 @@ export default function Sidebar({ view, onChangeView, darkMode, setDarkMode }) {
|
|||||||
|
|
||||||
// Track currrent view from both Sidebar and Canvas when 'view' changes
|
// Track currrent view from both Sidebar and Canvas when 'view' changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// console.log("typeof view =", typeof view);
|
|
||||||
console.log("Current view = ", view);
|
console.log("Current view = ", view);
|
||||||
|
|
||||||
const newIndex = buttons.findIndex((btn) => {
|
const newIndex = buttons.findIndex((btn) => {
|
||||||
if (btn.view === "widget") {
|
if (btn.view === "widget") {
|
||||||
return DASHBOARD_VIEWS.includes(view); // Group match
|
return DASHBOARD_VIEWS.includes(view);
|
||||||
}
|
}
|
||||||
return btn.view === view; // Exact match
|
return btn.view === view;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (newIndex !== -1 ) {
|
if (newIndex !== -1 ) {
|
||||||
@@ -52,7 +49,6 @@ export default function Sidebar({ view, onChangeView, darkMode, setDarkMode }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
// key={button.name}
|
|
||||||
css={styles.root}
|
css={styles.root}
|
||||||
width={isOpen ? "210px" : "71px"}
|
width={isOpen ? "210px" : "71px"}
|
||||||
transition="width 0.4s ease"
|
transition="width 0.4s ease"
|
||||||
@@ -76,7 +72,6 @@ export default function Sidebar({ view, onChangeView, darkMode, setDarkMode }) {
|
|||||||
key={button.name}
|
key={button.name}
|
||||||
css={styles.buttons}
|
css={styles.buttons}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
// setActiveButton(idx);
|
|
||||||
onChangeView(button.view); // Trigger state change in Dashboard
|
onChangeView(button.view); // Trigger state change in Dashboard
|
||||||
}}
|
}}
|
||||||
bg={activeButton === idx ? "primary":undefined}
|
bg={activeButton === idx ? "primary":undefined}
|
||||||
|
|||||||
Reference in New Issue
Block a user