Skip to content

Commit

Permalink
FWF-4276 [feature] enabled edit for default role and optimized code (#…
Browse files Browse the repository at this point in the history
…450)

* FWF-4276 [feature] enabled edit for default role and optimized code

* added working directory as comment in ci for fomsflow-component
  • Loading branch information
shuhaib-aot authored Feb 12, 2025
1 parent bdf6e7c commit dfd6508
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 52 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/forms-flow-component-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:
defaults:
run:
shell: bash
working-directory: ./forms-flow-components
jobs:
Forms-Flow-Components-CI:
name: Run Tests and Lint Checks
Expand All @@ -29,8 +30,6 @@ jobs:
- name: Install dependencies
run: |
npm ci --force
working-directory: ./forms-flow-components
- name: Run Tests
run: |
npm run test
working-directory: ./forms-flow-components
37 changes: 6 additions & 31 deletions forms-flow-admin/src/components/roles/roles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ import Dropdown from "react-bootstrap/Dropdown";
import OverlayTrigger from "react-bootstrap/OverlayTrigger";
import Popover from "react-bootstrap/Popover";
import { toast } from "react-toastify";
import {
KEYCLOAK_ENABLE_CLIENT_AUTH,
MULTITENANCY_ENABLED,
} from "../../constants";
import { DEFAULT_ROLES } from "../../constants";


import {removingTenantId} from "../../utils/utils.js";
import { TableFooter, CustomSearch } from "@formsflow/components";
Expand Down Expand Up @@ -60,7 +56,7 @@ const Roles = React.memo((props: any) => {
React.useState("");
const [editCandidate, setEditCandidate] = React.useState(initialRoleType);
const [disabled, setDisabled] = React.useState(true);
const [search, setSerach] = React.useState("");
const [search, setSearch] = React.useState("");
const [permission, setPermission] = React.useState([]);

const filterList = (filterTerm, List) => {
Expand Down Expand Up @@ -120,7 +116,7 @@ const Roles = React.memo((props: any) => {

const handlFilter = (e) => {
if (e && e.key === 'Enter') {
setSerach(e.target.value);
setSearch(e.target.value);
setRoles(filterList(e.target.value, props.roles));

}
Expand Down Expand Up @@ -340,29 +336,8 @@ const Roles = React.memo((props: any) => {
setDisabled(false);
};

const checkDefaultRoleOrNot = (role: any) => {
if (MULTITENANCY_ENABLED && tenantId) {
const roles = [
`${tenantId}-designer`,
`${tenantId}-client`,
`${tenantId}-reviewer`,
`${tenantId}-admin`,
"formsflow-reviewer",
"formsflow-designer",
"formsflow-client",
"camunda-admin",
"Approver",
"clerk",
"designer",
];
return roles.includes(role);
} else {
return DEFAULT_ROLES.includes(role);
}
};

const handleClearSearch = () => {
setSerach("");
setSearch("");
let updatedRoleName = removingTenantId(props.roles,tenantId);
setRoles(updatedRoleName);
};
Expand Down Expand Up @@ -696,7 +671,7 @@ const Roles = React.memo((props: any) => {
dataField: "id",
text: <Translation>{(t) => t("Actions")}</Translation>,
formatter: (cell, rowData, rowIdx, formatExtraData) => {
return checkDefaultRoleOrNot(rowData.name) ? null : (
return (
<div>
<i
className="fa fa-pencil me-4"
Expand Down Expand Up @@ -733,7 +708,7 @@ const Roles = React.memo((props: any) => {
<CustomSearch
handleClearSearch={handleClearSearch}
search={search}
setSearch={setSerach}
setSearch={setSearch}
handleSearch={handlFilter}
placeholder="Search by role name"
title="Search"
Expand Down
23 changes: 4 additions & 19 deletions forms-flow-admin/src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
const MULTITENANCY_ENABLED_VARIABLE =
(window._env_ && window._env_.REACT_APP_MULTI_TENANCY_ENABLED) || false;
window._env_?.REACT_APP_MULTI_TENANCY_ENABLED || false;
const KEYCLOAK_ENABLE_CLIENT_AUTH_VARIABLE =
(window._env_ && window._env_.REACT_APP_KEYCLOAK_ENABLE_CLIENT_AUTH) || false;
window._env_?.REACT_APP_KEYCLOAK_ENABLE_CLIENT_AUTH || false;

export const MULTITENANCY_ENABLED =
MULTITENANCY_ENABLED_VARIABLE === "true" ||
MULTITENANCY_ENABLED_VARIABLE === true
? true
: false;
MULTITENANCY_ENABLED_VARIABLE === "true" || MULTITENANCY_ENABLED_VARIABLE === true;

export const KEYCLOAK_ENABLE_CLIENT_AUTH =
KEYCLOAK_ENABLE_CLIENT_AUTH_VARIABLE === "true" ||
KEYCLOAK_ENABLE_CLIENT_AUTH_VARIABLE === true
? true
: false;
KEYCLOAK_ENABLE_CLIENT_AUTH_VARIABLE === "true" || KEYCLOAK_ENABLE_CLIENT_AUTH_VARIABLE === true;

export const BASE_ROUTE = MULTITENANCY_ENABLED ? "/tenant/:tenantId/" : "/";

export const ADMIN_ROLE = "formsflow-admin";

export const DEFAULT_ROLES = [
"/camunda-admin",
"/formsflow",
"/formsflow/formsflow-designer",
"/formsflow/formsflow-reviewer",
"/formsflow/formsflow-client",
"/formsflow-admin"
];

0 comments on commit dfd6508

Please sign in to comment.