Skip to content

Commit

Permalink
WIP: HACK navigate sections in editor mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ancorgs committed Nov 20, 2024
1 parent 62f0785 commit 9978519
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions web/src/components/core/ConfigEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@

import { _ } from "~/i18n";
import React, { useState } from "react";
import { Button, Stack } from "@patternfly/react-core";
import { Button, Stack, Split } from "@patternfly/react-core";
import { CodeEditor, Language } from '@patternfly/react-code-editor';
import { useConfigMutation, useConfig } from '~/queries/config';
import { Link } from "react-router-dom";

const ConfigEditor = ({ sections }): React.ReactNode => {
const setConfig = useConfigMutation();
Expand All @@ -51,9 +52,12 @@ const ConfigEditor = ({ sections }): React.ReactNode => {
return (
<Stack hasGutter>
<CodeEditor height="65vh" onChange={onChange} language={Language.json} code={configJson} />
<Button onClick={updateConfig}>
{_("Do it!")}
</Button>
<Split hasGutter>
<Link to={{ path: ".", index: false }}>{_("Cancel")}</Link>
<Button onClick={updateConfig}>
{_("Save")}
</Button>
</Split>
</Stack>
);
};
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/core/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ const Submit = ({ children, ...props }: SubmitActionProps) => {
*/
const Content = ({ editorSections, children, ...pageSectionProps }: React.PropsWithChildren<PageSectionProps>) => {
const [searchParams] = useSearchParams();
const editorMode = searchParams.get("editorMode");
const ui = searchParams.get("ui");

if (editorMode) return (
if (ui && ui.toLowerCase() === "editor") return (
<PageSection isFilled component="div">
<ConfigEditor sections={editorSections} />
</PageSection>
Expand Down
8 changes: 6 additions & 2 deletions web/src/components/layout/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@
*/

import React from "react";
import { NavLink } from "react-router-dom";
import { NavLink, useSearchParams, createSearchParams } from "react-router-dom";
import { Nav, NavItem, NavList, PageSidebar, PageSidebarBody, Stack } from "@patternfly/react-core";
import { Icon } from "~/components/layout";
import { ChangeProductLink } from "~/components/core";
import { rootRoutes } from "~/router";
import { _ } from "~/i18n";

const MainNavigation = (): React.ReactNode => {
const [searchParams] = useSearchParams();
const ui = searchParams.get("ui");
const propagated = ui ? { ui: searchParams.get("ui") } : {};

const links = rootRoutes().map((r) => {
if (!r.handle) return null;

Expand All @@ -41,7 +45,7 @@ const MainNavigation = (): React.ReactNode => {
key={r.path}
component={({ className }) => (
<NavLink
to={r.path}
to={{ pathname: r.path, search: `${createSearchParams(propagated)}` }}
className={({ isActive }) => [className, isActive ? "pf-m-current" : ""].join(" ")}
>
{iconName && <Icon size="s" name={iconName} />} {name}
Expand Down

0 comments on commit 9978519

Please sign in to comment.