Skip to content

Commit

Permalink
Merge pull request #379 from fahad-aot/bugfix/fwf-4035-sidebar-fix-in…
Browse files Browse the repository at this point in the history
…-preview

bugfix/fwf-4035:Hid sidebar in preview page
  • Loading branch information
arun-s-aot authored Dec 20, 2024
2 parents 30110dc + bbbb553 commit 63448f5
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 7 deletions.
13 changes: 10 additions & 3 deletions forms-flow-nav/src/root.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Sidebar from "./sidenav/Sidebar";
import React, { useRef, useEffect, useState } from "react";
import "./Navbar.scss";
import HamburgerMenu from "./sidenav/hamburgerMenu";
import { StyleServices } from "@formsflow/service";
import { StyleServices ,HelperServices } from "@formsflow/service";

export default function Root(props) {
const customLogoPath = StyleServices?.getCSSVariable("--custom-logo-path");
Expand All @@ -13,12 +13,19 @@ export default function Root(props) {
const sidenavRef = useRef(null);
const [sidenavHeight, setSidenavHeight] = useState("100%");
const hasMultitenancyHeader = customLogoPath || customTitle;
const [isPreviewRoute,setIsPreviewRoute] = useState(false);

useEffect(() => {
const headerHeight = headerRef.current?.offsetHeight || 0;
const totalHeight = `calc(100% - ${headerHeight}px)`;
setSidenavHeight(totalHeight);
}, [ hasMultitenancyHeader ]);

useEffect(()=>{
const location = window.location.pathname;
const viewOnlyRoutes = new Set (["view-edit"]);
setIsPreviewRoute(() => HelperServices.isViewOnlyRoute(location,viewOnlyRoutes));
})
return (
<Router>
{/* <NavBar props={props} /> */}
Expand All @@ -38,9 +45,9 @@ export default function Root(props) {
</div>
)}
<HamburgerMenu props={props} />
<div className="main-sidenav" ref={sidenavRef}>
{ !isPreviewRoute && <div className="main-sidenav" ref={sidenavRef}>
<Sidebar props={props} sidenavHeight={sidenavHeight}/>
</div>
</div>}
</>
</Router>
);
Expand Down
8 changes: 7 additions & 1 deletion forms-flow-service/src/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ export const DATE_FORMAT =
(window as any)._env_ && (window as any)._env_.REACT_APP_DATE_FORMAT || "DD-MM-YYYY";

export const TIME_FORMAT =
(window as any)._env_ && (window as any)._env_.REACT_APP_TIME_FORMAT || "hh:mm:ss A";
(window as any)._env_ && (window as any)._env_.REACT_APP_TIME_FORMAT || "hh:mm:ss A";

const MULTITENANCY_ENABLED_VARIABLE = (window as any)._env_?.REACT_APP_MULTI_TENANCY_ENABLED || false;

export const MULTITENANCY_ENABLED =
MULTITENANCY_ENABLED_VARIABLE === "true" ||
MULTITENANCY_ENABLED_VARIABLE === true
35 changes: 32 additions & 3 deletions forms-flow-service/src/helpers/helperServices.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import moment from 'moment'
import { DATE_FORMAT } from '../constants/constants'
import { TIME_FORMAT } from '../constants/constants'
import { DATE_FORMAT ,MULTITENANCY_ENABLED ,TIME_FORMAT} from '../constants/constants';

class HelperServices {
public static getLocalDateAndTime(date: string): any {
Expand Down Expand Up @@ -42,8 +41,38 @@ class HelperServices {
}

public static getMoment(date: any): any {
return moment(date)
return moment(date);
}

// method to remove tenant key
public static removeTenantKeyFromData(
value: string,
tenantKey: string
): string {
if (!value || !tenantKey) {
return value;
}

const tenantKeyCheck = new RegExp(`${tenantKey}-`).exec(value)?.[0]
const startWithSlash = value.startsWith("/");

if (
MULTITENANCY_ENABLED &&
tenantKey &&
tenantKeyCheck?.toLowerCase() === `${tenantKey.toLowerCase()}-`
) {
return value.replace(
`${startWithSlash ? "/" : ""}${tenantKey.toLowerCase()}-`,
""
);
}
return value;
}

public static isViewOnlyRoute(location: string, routes: Set<string>): boolean {
return Array.from(routes).some((route) => location.includes(route));
}

}

export default HelperServices

0 comments on commit 63448f5

Please sign in to comment.