Skip to content

Commit

Permalink
updated public workflow issue (#1730)
Browse files Browse the repository at this point in the history
  • Loading branch information
abilpraju-aot authored Nov 17, 2023
1 parent 520b9e0 commit 37b16f7
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 42 deletions.
1 change: 1 addition & 0 deletions forms-flow-web/src/actions/actionConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ const ACTION_CONSTANTS = {
BPMN_SEARCH_TEXT: "BPMN_SEARCH_TEXT",
DMN_SEARCH_TEXT: "DMN_SEARCH_TEXT",
IS_BPMN_MODEL: "IS_BPMN_MODEL",
IS_PUBLIC_DIAGRAM: "IS_PUBLIC_DIAGRAM",
//BPM FORMS
BPM_FORM_LIST: "BPM_FORM_LIST",
IS_BPM_FORM_LIST_LOADING: "IS_BPM_FORM_LIST_LOADING",
Expand Down
7 changes: 7 additions & 0 deletions forms-flow-web/src/actions/processActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,11 @@ export const setBpmnModel = (data) => (dispatch) => {
type: ACTION_CONSTANTS.IS_BPMN_MODEL,
payload: data,
});
};

export const setIsPublicDiagram = (data) => (dispatch) => {
dispatch({
type: ACTION_CONSTANTS.IS_PUBLIC_DIAGRAM,
payload: data,
});
};
11 changes: 5 additions & 6 deletions forms-flow-web/src/components/Form/List.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@
}

.published-forms-label{
color: #2F6846;
color: #52C41A;
background: #EAFBE7 0% 0% no-repeat padding-box;
border: 1px solid #C6F0C2;
border: 1px solid #52C41A;
border-radius: 7px;
}

.unpublished-forms-label{
background: #EAF5FF 0% 0% no-repeat padding-box;
background: #E6F7FF 0% 0% no-repeat padding-box;
border-radius: 7px;
border: 1px solid #B8E1FF;
color: #006096;
border: 1px solid #91D5FF;
color: #1890FF;
}

.custom-grid {
.col {
min-height: 50px;
Expand Down
2 changes: 1 addition & 1 deletion forms-flow-web/src/components/Modeler/Create.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
/>
) : (
<DmnEditor
mode="Create"
mode="Create"
processKey={''}
tenant={''}
isNewDiagram={true}
Expand Down
35 changes: 24 additions & 11 deletions forms-flow-web/src/components/Modeler/Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,41 @@ import BpmnEditor from './Editors/BpmnEditor';
import { useParams } from "react-router-dom";
import DmnEditor from './Editors/DmnEditor';
import { useDispatch } from 'react-redux';
import { push } from "connected-react-router";
import {
fetchDiagram,
} from "../../apiManager/services/processServices";
import Loading from '../../containers/Loading';
import { setProcessDiagramXML } from '../../actions/processActions';
import { setIsPublicDiagram, setProcessDiagramXML } from '../../actions/processActions';
import { MULTITENANCY_ENABLED } from '../../constants/constants';

const EditWorkflow = () => {
//select typeOf workflow form useSelector / redux
const tenantKey = useSelector((state) => state.tenants?.tenantId);
const tenantKey = useSelector((state) => state.tenants?.tenantId);
const {processId, type} = useParams();
const dispatch = useDispatch();
const [diagramLoading, setDiagramLoading] = useState(false);
const diagramXML = useSelector((state) => state.process.processDiagramXML);

const diagramXML = useSelector((state) => state.process.processDiagramXML);
const isPublicDiagram = useSelector((state) => state.process.isPublicDiagram);
const redirectUrl = MULTITENANCY_ENABLED ? `/tenant/${tenantKey}/` : "/";

useEffect(()=>{
setDiagramLoading(true);
dispatch(fetchDiagram(processId, tenantKey, type === "bpmn" ? false : true,()=>{
setDiagramLoading(false);
}));
if(MULTITENANCY_ENABLED && isPublicDiagram === null){
dispatch(push(`${redirectUrl}processes`));
}
else{
const updatedTenantKey = (MULTITENANCY_ENABLED && !isPublicDiagram) ? null : tenantKey;
dispatch(fetchDiagram(processId,updatedTenantKey, type === "bpmn" ? false : true,()=>{
setDiagramLoading(false);
}));
}
},[processId]);

useEffect(()=>{
return () => {
dispatch(setProcessDiagramXML(''));
dispatch(setIsPublicDiagram(null));
};
},[]);

Expand All @@ -39,20 +50,22 @@ const EditWorkflow = () => {
<div>

{type === "bpmn" ? (
diagramXML ?
<BpmnEditor
mode="Edit"
mode="Edit"
processKey={processId}
tenant={tenantKey}
isNewDiagram={false}
bpmnXml={diagramXML}
/>
/> : null
) : (
diagramXML ?
<DmnEditor
mode="Edit"
mode="Edit"
processKey={processId}
tenant={tenantKey}
isNewDiagram={false}
/>
/> : null
)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default React.memo(
if (diagramXML) {
dispatch(setProcessDiagramLoading(true));
dispatch(setProcessDiagramXML(diagramXML));
} else if (processKey && !isNewDiagram) {
} else if (processKey && !isNewDiagram && !bpmnXml) {
dispatch(setProcessDiagramLoading(true));
dispatch(fetchDiagram(processKey, tenant));
} else {
Expand Down Expand Up @@ -302,7 +302,7 @@ export default React.memo(
<div>
<h3 className="d-flex align-items-center font-weight-bold">
<i className="fa fa-cogs mr-2" aria-hidden="true" />
<span>{t(`${mode} Processes`)}</span>
<span>{t(`${mode} Process`)}</span>
</h3>
</div>

Expand All @@ -314,7 +314,7 @@ export default React.memo(
checked={applyAllTenants}
onClick={handleApplyAllTenants}
/>{" "}
Apply for all tenants
{t("Apply for all tenants")}
</label>
) : null}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export default React.memo(({ processKey, tenant, isNewDiagram, mode}) => {
<div>
<h3 className="d-flex align-items-center font-weight-bold">
<i className="fa fa-cogs mr-2" aria-hidden="true" />
<span>{t(`${mode} Processes`)}</span>
<span>{t(`${mode} Dmn`)}</span>
</h3>
</div>
<div className="task-head d-flex justify-content-end mb-2">
Expand All @@ -276,7 +276,7 @@ export default React.memo(({ processKey, tenant, isNewDiagram, mode}) => {
checked={applyAllTenants}
onClick={handleApplyAllTenants}
/>{" "}
Apply for all tenants
{t("Apply for all tenants")}
</label>
) : null}
<button type="button"
Expand Down
2 changes: 2 additions & 0 deletions forms-flow-web/src/components/Modeler/Editors/Editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@

.deploy-checkbox {
margin-right: 15px;
font-size: 16px;
margin-top: 7px;
}

// Override bpmn-js-properties-panel style for removing entry (trash can)
Expand Down
20 changes: 12 additions & 8 deletions forms-flow-web/src/components/Modeler/constants/bpmnTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
fetchAllBpmProcessesCount,
} from "../../../apiManager/services/processServices";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { MULTITENANCY_ENABLED } from "../../../constants/constants";
import { setBpmnSearchText } from "../../../actions/processActions";
import { setBpmnSearchText, setIsPublicDiagram } from "../../../actions/processActions";
import { push } from "connected-react-router";
function BpmnTable() {
const dispatch = useDispatch();
const process = useSelector((state) => state.process.processList);
Expand Down Expand Up @@ -74,6 +74,13 @@ function BpmnTable() {
dispatch(setBpmnSearchText(""));
setActivePage(1);
};

const gotoEdit = (data) => {
if(MULTITENANCY_ENABLED){
dispatch(setIsPublicDiagram(data.tenantId ? true : false));
}
dispatch(push(`${redirectUrl}processes/bpmn/${data.key}/edit`));
};

const pageOptions = [
{ text: "5", value: 5 },
Expand Down Expand Up @@ -152,12 +159,9 @@ function BpmnTable() {
<td>{processItem.key}</td>
<td>{t("BPMN")}</td>
<td className="d-flex justify-content-end w-100">
<Link
to={`${redirectUrl}processes/bpmn/${processItem.key}/edit`}
>
<i className="fas fa-edit mr-2"/>
{t("Edit Workflow")}
</Link>
<button className="btn btn-link" onClick={()=>{gotoEdit(processItem);}}>
<i className="fas fa-edit mr-2"/>
{t("Edit Workflow")}</button>
</td>
</tr>
))}
Expand Down
23 changes: 14 additions & 9 deletions forms-flow-web/src/components/Modeler/constants/dmnTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import {
fetchAllDmnProcessesCount,
} from "../../../apiManager/services/processServices";
import { useTranslation } from "react-i18next";
import { Link } from "react-router-dom";
import { MULTITENANCY_ENABLED } from "../../../constants/constants";
import { setDmnSearchText } from "../../../actions/processActions";
import { setDmnSearchText,setIsPublicDiagram } from "../../../actions/processActions";
import { push } from "connected-react-router";

function DmnTable() {
const dispatch = useDispatch();
const dmn = useSelector((state) => state.process?.dmnProcessList);
Expand Down Expand Up @@ -77,6 +78,13 @@ function DmnTable() {
setActivePage(1);
};

const gotoEdit = (data) => {
if(MULTITENANCY_ENABLED){
dispatch(setIsPublicDiagram(data.tenantId ? true : false));
}
dispatch(push(`${redirectUrl}processes/dmn/${data.key}/edit`));
};

const pageOptions = [
{ text: "5", value: 5 },
{ text: "10", value: 10 },
Expand Down Expand Up @@ -141,7 +149,7 @@ function DmnTable() {
style={{ height: "300px" }}
className="text-center"
>
{ isLoading ? null : t("No Process Found")}
{ isLoading ? null : t("No Dmn Found")}
</td>
</tr>
</tbody>
Expand All @@ -153,12 +161,9 @@ function DmnTable() {
<td>{processItem.key}</td>
<td>{t("DMN")}</td>
<td className="d-flex justify-content-end w-100">
<Link
to={`${redirectUrl}processes/dmn/${processItem.key}/edit`}
>
<i className="fas fa-edit mr-2"/>
{t("Edit Workflow")}
</Link>
<button className="btn btn-link" onClick={()=>{gotoEdit(processItem);}}>
<i className="fas fa-edit mr-2"/>
{t("Edit Workflow")}</button>
</td>
</tr>
))}
Expand Down
4 changes: 3 additions & 1 deletion forms-flow-web/src/modules/processReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const initialState = {
isBpmnModel:true,
bpmnSearchText:"",
dmnSearchText:"",

isPublicDiagram:null,
};

const process = (state = initialState, action) => {
Expand Down Expand Up @@ -95,6 +95,8 @@ const process = (state = initialState, action) => {
return { ...state, bpmnSearchText: action.payload };
case ACTION_CONSTANTS.DMN_SEARCH_TEXT:
return { ...state, dmnSearchText: action.payload };
case ACTION_CONSTANTS.IS_PUBLIC_DIAGRAM:
return { ...state, isPublicDiagram: action.payload };
default:
return state;
}
Expand Down
2 changes: 1 addition & 1 deletion forms-flow-web/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ body {
}

.page-item.active .page-link {
background-color: #036 !important;
background-color: #4183c4 !important;
border-color: #56595d !important;
}

Expand Down

0 comments on commit 37b16f7

Please sign in to comment.