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 DeleteAllButton from "../components/DeleteAllButton";
|
||||
|
||||
export function DashboardCanvas({ onCancel, isEditable, setIsEditable, isDelete, setIsDelete, view, setView, layout, setLayout, originalLayout, setOriginalLayout, onLayoutChange, onChangeView }) {
|
||||
// const [isEditable, setIsEditable] = useState(false); // editable=true means static=false (vice versa)
|
||||
// const [isDelete, setIsDelete] = useState(false);
|
||||
export function DashboardCanvas({ onCancel, isEditable, setIsEditable, isDelete, setIsDelete, view, layout, setLayout, originalLayout, setOriginalLayout, onLayoutChange, onChangeView }) {
|
||||
const [newCounter, setNewCounter] = useState(3);
|
||||
// const [originalLayout, setOriginalLayout] = useState([]);
|
||||
|
||||
const onAddWidget = () => {
|
||||
const newId = newCounter.toString();
|
||||
@@ -55,20 +52,6 @@ export function DashboardCanvas({ onCancel, isEditable, setIsEditable, isDelete,
|
||||
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 = () => {
|
||||
console.log("Start deleting widgets...");
|
||||
setOriginalLayout(layout);
|
||||
@@ -102,14 +85,6 @@ export function DashboardCanvas({ onCancel, isEditable, setIsEditable, isDelete,
|
||||
onValueChange={(e) => {
|
||||
const nextView = e.value;
|
||||
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
|
||||
|
||||
@@ -67,7 +67,6 @@ export default function Dashboard() {
|
||||
view={ view }
|
||||
onChangeView={ handleViewChange }
|
||||
isEditabe={ isEditable }
|
||||
// onChangeView={ setView }
|
||||
/>
|
||||
</GridItem>
|
||||
<GridItem colSpan={1} width="100%" overflow="auto">
|
||||
|
||||
@@ -8,7 +8,7 @@ const user = {
|
||||
// avatar: "src\\assets\\user_profile.svg"
|
||||
}
|
||||
|
||||
export default function Header({ view, setView, onChangeView }) {
|
||||
export default function Header({ onChangeView }) {
|
||||
const recipe = useRecipe({ key: "header" });
|
||||
const styles = recipe();
|
||||
|
||||
@@ -23,8 +23,6 @@ export default function Header({ view, setView, onChangeView }) {
|
||||
<UserAvatarMenu
|
||||
name={user.name}
|
||||
avatar={user.avatar}
|
||||
view={ view }
|
||||
setView={ setView }
|
||||
onChangeView={ onChangeView }
|
||||
/>
|
||||
</Flex>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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 (
|
||||
<Menu.Root>
|
||||
<Menu.Trigger focusRing="none">
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useSlotRecipe, Box, Button, IconButton } from "@chakra-ui/react";
|
||||
import { ColorModeButton, useColorMode } from "@/components/ui/color-mode";
|
||||
// import { Tooltip } from "@/components/ui/tooltip";
|
||||
import Tooltip from "../Canvas/components/Tooltip.jsx";
|
||||
import { FaVolcano } from "react-icons/fa6";
|
||||
import { FaHome } from "react-icons/fa";
|
||||
@@ -9,7 +8,6 @@ import { FaMapMarkerAlt } from "react-icons/fa";
|
||||
import { HiUsers } from "react-icons/hi2";
|
||||
import { VscThreeBars } from "react-icons/vsc";
|
||||
import { useState, useEffect } from "react";
|
||||
import { Seismic } from "../Canvas/views/DashboardCanvasNav/Seismic";
|
||||
import { DASHBOARD_VIEWS } from "@/constants/viewKeys";
|
||||
|
||||
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
|
||||
useEffect(() => {
|
||||
// console.log("typeof view =", typeof view);
|
||||
console.log("Current view = ", view);
|
||||
|
||||
const newIndex = buttons.findIndex((btn) => {
|
||||
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 ) {
|
||||
@@ -52,7 +49,6 @@ export default function Sidebar({ view, onChangeView, darkMode, setDarkMode }) {
|
||||
|
||||
return (
|
||||
<Box
|
||||
// key={button.name}
|
||||
css={styles.root}
|
||||
width={isOpen ? "210px" : "71px"}
|
||||
transition="width 0.4s ease"
|
||||
@@ -76,7 +72,6 @@ export default function Sidebar({ view, onChangeView, darkMode, setDarkMode }) {
|
||||
key={button.name}
|
||||
css={styles.buttons}
|
||||
onClick={() => {
|
||||
// setActiveButton(idx);
|
||||
onChangeView(button.view); // Trigger state change in Dashboard
|
||||
}}
|
||||
bg={activeButton === idx ? "primary":undefined}
|
||||
|
||||
Reference in New Issue
Block a user