Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYNC] Develop to Design System MF #261

Merged
merged 14 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions forms-flow-admin/src/components/dashboard/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import "react-bootstrap-table2-paginator/dist/react-bootstrap-table2-paginator.m
import paginationFactory from "react-bootstrap-table2-paginator";
import { toast } from "react-toastify";
import Loading from "../loading";
import { useParams } from "react-router-dom";
import {removeTenantKey} from "../../utils/utils.js";
import { MULTITENANCY_ENABLED } from "../../constants";

import {
updateAuthorization,
fetchAuthorizations,
Expand Down Expand Up @@ -44,7 +48,7 @@ export const InsightDashboard = React.memo((props: any) => {
const [isAuthUpdated, setIsAuthUpdated] = React.useState(false);

const { t } = useTranslation();

const { tenantId } = useParams();
const [remainingGroups, setRemainingGroups] = React.useState([]);

const [activeRow, setActiveRow] = React.useState(null);
Expand Down Expand Up @@ -181,7 +185,7 @@ export const InsightDashboard = React.memo((props: any) => {
},
{
dataField: "roles",
text: <Translation>{(t) => t("Access Groups")}</Translation>,
text: <Translation>{(t) => t("Access Roles")}</Translation>,
formatter: (cell, rowData) => {
return (
<div className="d-flex flex-wrap col-12">
Expand All @@ -190,7 +194,7 @@ export const InsightDashboard = React.memo((props: any) => {
style={{ background: "#EAEFFF" }}
data-testid={`dashboard-access-group-${i}`}>
<span className="">
{label}
{MULTITENANCY_ENABLED ? removeTenantKey(label,tenantId) : label}
<i
className="fa-solid fa-xmark chip-close ms-2"
onClick={() => removeDashboardAuth(rowData, label)}
Expand Down Expand Up @@ -227,7 +231,7 @@ export const InsightDashboard = React.memo((props: any) => {
onClick={() => addDashboardAuth(item)}
data-testid={`dashboard-remaining-group-${key}`}
>
{item.path}
{MULTITENANCY_ENABLED ? removeTenantKey(item.path, tenantId) : item.path}
</div>
))
) : (
Expand Down
21 changes: 19 additions & 2 deletions forms-flow-admin/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Route, Switch,useHistory, useParams,useLocation } from "react-router-dom";
import { Route, Switch,useHistory, useParams,useLocation,Redirect } from "react-router-dom";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import { KeycloakService, StorageService } from "@formsflow/service";
Expand Down Expand Up @@ -97,7 +97,8 @@ const Admin = React.memo(({ props }: any) => {
const restricted =
(location === '/admin/dashboard' && !isDashboardManager) ||
(location === '/admin/roles' && !isRoleManager) ||
(location === '/admin/users' && !isUserManager);
(location === '/admin/users' && !isUserManager) ||
(!(isDashboardManager ||isRoleManager ||isUserManager));
setIsAccessRestricted(restricted);
},[location,userRoles]);
return (
Expand Down Expand Up @@ -146,6 +147,22 @@ const Admin = React.memo(({ props }: any) => {
/>
)}
/>)}
<Route
exact
path={`${BASE_ROUTE}admin`}
>
{
userRoles.length && (
<Redirect
to ={
isDashboardManager ? `${BASE_ROUTE}admin/dashboard`
:isRoleManager ? `${BASE_ROUTE}admin/roles`
: `${BASE_ROUTE}admin/users`
}
/>
)
}
</Route>
</Switch>
</div>):
<div className="min-container-height ps-md-3" >
Expand Down
13 changes: 13 additions & 0 deletions forms-flow-admin/src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,16 @@ export const removingTenantId = (roles=[], tenantId, tenantIdInPath = false) =>
}
return roles;
};


export const removeTenantKey = (value, tenantkey) => {
const tenantKeyCheck = value.match(`${tenantkey}-`);
if (
tenantKeyCheck &&
tenantKeyCheck[0].toLowerCase() === `${tenantkey.toLowerCase()}-`
) {
return value.replace(`${tenantkey.toLowerCase()}-`, "");
} else {
return false;
}
};
4 changes: 2 additions & 2 deletions forms-flow-integration/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
KEYCLOAK_CLIENT,
} from "./endpoints/config";
import Footer from "./components/Footer";
import { BASE_ROUTE, DESIGNER_ROLE, MULTITENANCY_ENABLED, ENABLE_INTEGRATION_PREMIUM } from "./constants";
import { BASE_ROUTE, MULTITENANCY_ENABLED, ENABLE_INTEGRATION_PREMIUM } from "./constants";
import Recipes from "./components/Recipes";
import ConnectedApps from "./components/ConnectedApps";
import PremiumSubscription from "./components/PremiumSubscription";
Expand Down Expand Up @@ -65,7 +65,7 @@ const Integration = React.memo(({ props }: any) => {
React.useEffect(() => {
if (!isAuth) return
const roles = JSON.parse(StorageService.get(StorageService.User.USER_ROLE));
if (roles.includes(DESIGNER_ROLE)) {
if (roles.includes('view_designs')) {
setIsDesigner(true);
}
const locale = localStorage.getItem("i18nextLng")
Expand Down
11 changes: 2 additions & 9 deletions forms-flow-nav/src/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,7 @@ const isViewDashboard=userRoles?.includes("view_dashboards")
const isDashboardManager = userRoles?.includes("manage_dashboard_authorizations");
const isRoleManager = userRoles?.includes("manage_roles");
const isUserManager = userRoles?.includes("manage_users");
const ADMIN_BASE_ROUTE = isDashboardManager
? `${baseUrl}admin/dashboard`
: isRoleManager
? `${baseUrl}admin/roles`
: isUserManager
? `${baseUrl}admin/users`
: null;


const onResize = React.useCallback(() => {
if (navbarRef?.current) {
Expand Down Expand Up @@ -337,7 +331,7 @@ const isUserManager = userRoles?.includes("manage_users");
<Nav.Link
eventKey={"admin"}
as={Link}
to={`${ADMIN_BASE_ROUTE}`}
to={`${baseUrl}admin`}
className={`nav-menu-item py-md-3 px-0 mx-2 ${
pathname.match(createURLPathMatchExp("admin", baseUrl))
? "active"
Expand Down Expand Up @@ -369,7 +363,6 @@ const isUserManager = userRoles?.includes("manage_users");
{t("Processes")}
</Nav.Link>
)}

{userRoles?.includes("manage_integrations")
? (integrationEnabled || ENABLE_INTEGRATION_PREMIUM) && (
<Nav.Link
Expand Down
Loading
Loading