Skip to content

Commit

Permalink
Add prefix to NavPath and remove it from path
Browse files Browse the repository at this point in the history
  • Loading branch information
jsonBackup committed Feb 22, 2024
1 parent 0d41fc3 commit 9d19df9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function RoutingMenuItem(props: MenuItemProps) {
const navigate = useNavigate();

const isOpened = (location: any): boolean => {
return location.pathname.endsWith(`/${props.MenuItem.NavPath}`);
return location.pathname.startsWith(props.MenuItem.NavPath);
};

const [IsOpened, setIsOpened] = React.useState<boolean>(isOpened(location));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Database extends React.Component<DatabasesPropsModel & DatabasesDispatchPr
const namespace = dataModel.targetModel.replace("." + context, "");
return {
Name: context,
NavPath: dataModel.targetModel,
NavPath: "/databases/" + dataModel.targetModel,
Icon: mdiBriefcase,
Content: (<p style={{ margin: "inherit", color: "gray", fontSize: "x-small" }}>{namespace}</p>),
SubMenuItems: [],
Expand Down
12 changes: 6 additions & 6 deletions src/Moryx.CommandCenter.Web/src/modules/container/Modules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,20 @@ class Modules extends React.Component<ModulesPropModel & ModulesDispatchPropMode
private static createMenuItem(moduleModel: ServerModuleModel): MenuItemModel {
return {
Name: moduleModel.name,
NavPath: moduleModel.name,
NavPath: "/modules/" + moduleModel.name,
Icon: mdiHexagon,
Content: (<span className="font-small" style={{ float: "right" }}><HealthStateBadge HealthState={moduleModel.healthState} /></span>),
SubMenuItems:
[
{
Name: "Configuration",
NavPath: moduleModel.name + "/configuration",
NavPath: "/modules/" + moduleModel.name + "/configuration",
Icon: mdiCogs,
SubMenuItems: [],
},
{
Name: "Console",
NavPath: moduleModel.name + "/console",
NavPath: "/modules/" + moduleModel.name + "/console",
Icon: mdiConsoleLine,
SubMenuItems: [],
},
Expand All @@ -104,17 +104,17 @@ class Modules extends React.Component<ModulesPropModel & ModulesDispatchPropMode
this.state.MenuModel.MenuItems.forEach((menuItem) => {
const module = this.props.Modules.filter(function (element: ServerModuleModel, index: number, array: ServerModuleModel[]): boolean { return element.name === menuItem.Name; })[0];
routes.push(
<Route key={idx} path={menuItem.NavPath} element={
<Route key={idx} path={menuItem.NavPath.replace("/modules/", "")} element={
<Module Module={module} RestClient={this.props.RestClient} />} />);

menuItem.SubMenuItems.forEach((subMenuItem) => {
if (subMenuItem.NavPath.endsWith("configuration")) {
routes.push(
<Route key={idx} path={subMenuItem.NavPath} element={
<Route key={idx} path={subMenuItem.NavPath.replace("/modules/", "")} element={
<ModuleConfiguration ModuleName={module.name} RestClient={this.props.RestClient} />} />);
} else if (subMenuItem.NavPath.endsWith("console")) {
routes.push(
<Route key={idx} path={subMenuItem.NavPath} element={
<Route key={idx} path={subMenuItem.NavPath.replace("/modules/", "")} element={
<ModuleConsole ModuleName={module.name} RestClient={this.props.RestClient} />} />);
}

Expand Down

0 comments on commit 9d19df9

Please sign in to comment.