Skip to content

Commit

Permalink
Merge pull request #332 from bptlab/291_ensure_coding_standards
Browse files Browse the repository at this point in the history
291 ensure coding standards
  • Loading branch information
WolfgangDaniel authored Jun 1, 2021
2 parents 491fb57 + 6e6ce06 commit 5e809d7
Show file tree
Hide file tree
Showing 29 changed files with 119 additions and 149 deletions.
8 changes: 4 additions & 4 deletions frontend/src/api/routes/robots/robots.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
*/

/**
* @description Triggers parsing of the Ssot to .robot file
* @description Triggers parsing of the ssot to .robot file
* @returns {String} .robot file code
*/
const getParsedRobotFile = async (robotId) =>
fetch(`/robots/${robotId}/robotCode`);

/**
* @description Fetch the ssot correlating to the specified Id
* @param {String} robotId - Id of the robot that will be retrieved
* @param {String} robotId Id of the robot that will be retrieved
* @returns {Object} Found ssot
*/
const getSsot = async (robotId) => {
Expand All @@ -23,8 +23,8 @@ const getSsot = async (robotId) => {

/**
* @description Rename the robot in the ssot
* @param {String} robotId - RobotId of the robot that will be renamed
* @param {String} newRobotName - String with the new RobotName
* @param {String} robotId RobotId of the robot that will be renamed
* @param {String} newRobotName String with the new RobotName
* @returns {Object} Object containing robotName and starterId
*/
const changeSsotName = async (robotId, newRobotName) => {
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/api/routes/users/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/**
* @description Fetch all those ssot names and ids, which are available for the current user
* @param { String } userId - UserId for which the ssots will be fetched
* @param { String } userId UserId for which the ssots will be fetched
* @returns {Array} Array of objects containing ssotId, robotName and starterId of each found robot
*/
const fetchSsotsForUser = async (userId) => {
Expand All @@ -16,8 +16,8 @@ const fetchSsotsForUser = async (userId) => {

/**
* @description Create a new robot with the specified name for the specified user
* @param {String} userId - User for which the robot will be created
* @param {String} robotName - Name of the new robot
* @param {String} userId User for which the robot will be created
* @param {String} robotName Name of the new robot
* @returns {Object} Object containing robotId and robotName
*/
const createNewRobot = async (userId, robotName) => {
Expand All @@ -36,4 +36,4 @@ const createNewRobot = async (userId, robotName) => {
return response;
};

export { fetchSsotsForUser, createNewRobot /* , shareRobotWithUser */ };
export { fetchSsotsForUser, createNewRobot };
2 changes: 1 addition & 1 deletion frontend/src/api/socketHandler/socketListeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const newRobotMonitorUpdate = (logSetterMethod) => {

/**
* @description Register listener on when a new robot status has been set
* @param {function} logSetterMethod Method reference to update the status of the log in the robotInteractionCockpit
* @param {function} statusSetterMethod Method reference to update the status of the log in the robotInteractionCockpit
*/
const newRobotStatusUpdate = (statusSetterMethod) => {
socket.on('changedRobotStatus', (status) => statusSetterMethod(status));
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const App = () => (
<Switch>
<Route path='/' component={Home} exact />
<Route path='/modeler/:robotId' component={RobotModeler} />
<Route path='/robotcode_editor' component={RobotFile} />
<Route path='/robot_overview' component={RobotOverview} />
<Route path='/robotCodeEditor' component={RobotFile} />
<Route path='/robotOverview' component={RobotOverview} />
<Route
path='/interaction_cockpit/:robotId'
path='/interactionCockpit/:robotId'
component={RobotInteractionCockpit}
/>
<Route component={Error} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,32 @@ const { Header } = Layout;

/**
* @component
* @description Renders the header navbar for all pages and initially selects the passed key-element.
* @description Renders the header navbar for all pages and initially selects the passed key element.
* @category Frontend
* @example return <HeaderNavbar selectedKey={2} />
*/
const HeaderNavbar = (props) => {
const { selectedKey } = props;
const iconKey = 0;
const robotOverviewPageKey = 1;
const bpmnModelerPageKey = 2;
const robotCodeEditorPageKey = 3;
const robotInteractionPageKey = 4;
const ICON_KEY = 0;
const ROBOT_OVERVIEW_PAGE_KEY = 1;
const BPMN_MODELER_PAGE_KEY = 2;
const ROBOT_CODE_EDITOR_PAGE_KEY = 3;
const ROBOT_INTERACTION_PAGE_KEY = 4;

let onOverview = false;
if (selectedKey === robotOverviewPageKey) {
if (selectedKey === ROBOT_OVERVIEW_PAGE_KEY) {
onOverview = true;
}

let onRobotInteraction = false;
if (selectedKey === robotInteractionPageKey) {
if (selectedKey === ROBOT_INTERACTION_PAGE_KEY) {
onRobotInteraction = true;
}

let bpmnModelerLink = '/modeler';
if (
selectedKey === bpmnModelerPageKey ||
selectedKey === robotCodeEditorPageKey
selectedKey === BPMN_MODELER_PAGE_KEY ||
selectedKey === ROBOT_CODE_EDITOR_PAGE_KEY
) {
bpmnModelerLink += `/${getRobotId()}`;
}
Expand All @@ -46,7 +46,7 @@ const HeaderNavbar = (props) => {
mode='horizontal'
defaultSelectedKeys={[selectedKey.toString()]}
>
<Menu.Item className={styles.modifiedMenuItem} key={iconKey}>
<Menu.Item className={styles.modifiedMenuItem} key={ICON_KEY}>
<Link to='/'>
<img
style={{ height: '3rem' }}
Expand All @@ -56,28 +56,28 @@ const HeaderNavbar = (props) => {
</Link>
</Menu.Item>

<Menu.Item key={robotOverviewPageKey}>
<Menu.Item key={ROBOT_OVERVIEW_PAGE_KEY}>
Overview
<Link to='/robot_overview' />
<Link to='/robotOverview' />
</Menu.Item>
{!onRobotInteraction && (
<>
{!onOverview && (
<Menu.Item key={bpmnModelerPageKey}>
<Menu.Item key={BPMN_MODELER_PAGE_KEY}>
Modeler
<Link to={bpmnModelerLink} />
</Menu.Item>
)}
{!onOverview && (
<Menu.Item key={robotCodeEditorPageKey}>
<Menu.Item key={ROBOT_CODE_EDITOR_PAGE_KEY}>
Robot Code
<Link to='/robotcode_editor' />
<Link to='/robotCodeEditor' />
</Menu.Item>
)}
</>
)}
{onRobotInteraction && (
<Menu.Item key={robotInteractionPageKey}>
<Menu.Item key={ROBOT_INTERACTION_PAGE_KEY}>
Robot Interaction Cockpit
</Menu.Item>
)}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/pages/Home/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const Home = () => {
fast, easy, automation
</Title>
<p>{message}</p>
<Link to='/robot_overview'>
<Link to='/robotOverview'>
<Button style={{ margin: '0 auto', display: 'block' }} type='primary'>
Go to my Robots
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ const RobotInteractionExecutionSection = (props) => {
const { executionLogs } = props;
const { robotState } = props;

/**
* @description Displays the suitable status icon for robot execution
* @param {String} status Current Status of the robot execution
* @returns {React.ReactElement} Returns an icon component or undefined
*/
const displayStatusIcon = (status) => {
if (status === 'PASS' || status === 'successful') {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { getAllAttributes } from '../../../../api/routes/robots/rpaAttributes';
/**
* @description Will return a boolean regarding the correct configuration of the given parameterObejcts belonging to a robot.
* If a paramter is required and no value is passed and the value will not be specified later by the user, the paramter is not correctly configured.
* @param {Object[]} parameterObjects Array of parameterObjects that will be checked
* @returns {boolean} Boolean value regarding the correctness of the parameter configuration
* @param {Array} parameterObjects Array of parameterObjects that will be checked
* @returns {Boolean} Boolean value regarding the correctness of the parameter configuration
*/
const configuredRobotParamsCorrectly = (parameterObjects) => {
let executability = true;
Expand All @@ -36,8 +36,8 @@ const configuredRobotParamsCorrectly = (parameterObjects) => {
/**
* @description Will return a boolean regarding the correct configuration regarding the given attributeObjects of a robot.
* If an attribute has no specified application or task, the attribute is not correctly configured.
* @param {Object[]} attributeObjects Array of attributeObjects that will be checked
* @returns {boolean} A boolean value regarding the correctness of the attribute configuration
* @param {Array} attributeObjects Array of attributeObjects that will be checked
* @returns {Boolean} A boolean value regarding the correctness of the attribute configuration
*/
const configuredRobotActivitesCorrectly = (attributeObjects) => {
let executability = true;
Expand All @@ -64,7 +64,7 @@ const configuredRobotActivitesCorrectly = (attributeObjects) => {
* @description Will return a boolean regarding the correct configuration of a robot.
* If a robot has incorrectly configured attributes or parameters, then the robot is not correctly configured.
* @param {String} robotId RobotId of the robot that will be checked
* @returns {boolean} Boolean value regarding the executability of the robot
* @returns {Boolean} Boolean value regarding the executability of the robot
*/
const isRobotExecutable = async (robotId) => {
const attributes = await getAllAttributes(robotId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const RobotContainer = (props) => {
<Col type='flex' span={8}>
<Link
to={{
pathname: `/interaction_cockpit/${robotId}`,
pathname: `/interactionCockpit/${robotId}`,
state: { userId },
}}
>
Expand All @@ -94,7 +94,7 @@ const RobotContainer = (props) => {
</Link>
</Col>
<Col type='flex' span={8}>
<Link onclick={setRobotMetadata()} to={`/modeler/${robotId}`}>
<Link onClick={setRobotMetadata()} to={`/modeler/${robotId}`}>
<Tooltip title='Edit Robot'>
<EditOutlined className={styles.clickableIcon} />
</Tooltip>
Expand Down
11 changes: 0 additions & 11 deletions frontend/src/layout/customizedTheme.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const corporateDesign = require('./corporateDesign');

const customizedTheme = {
// general
'@primary-color': corporateDesign.colorPrimary,
'@link-color': corporateDesign.colorBackgroundCta,
'@success-color': corporateDesign.colorBackgroundCta,
Expand All @@ -11,27 +10,17 @@ const customizedTheme = {
'@layout-body-background': corporateDesign.colorBackground,
'@border-radius-base': '5px',
'@label-color': corporateDesign.colorPrimaryInvertedText,

// text
'@heading-color': corporateDesign.colorBackgroundText,
'@text-color': corporateDesign.colorBackgroundText,
'@text-color-dark': corporateDesign.colorPrimaryInvertedText,
// button
'@btn-primary-bg': corporateDesign.colorBackgroundCta,
// input
'@input-color': corporateDesign.colorBackgroundText,
// sider
'@layout-sider-background': corporateDesign.colorPrimaryInverted2,
// component
'@component-background': corporateDesign.colorBackground2,
// footer
'@layout-footer-background': corporateDesign.colorPrimaryInverted,
// dropdown
'@dropdown-menu-bg': corporateDesign.colorPrimaryInverted2,
'@select-item-selected-color': corporateDesign.colorBackgroundText,
// header
'@layout-header-background': corporateDesign.colorPrimaryInverted,
// fonts
'@font-family': 'Lato, sans-serif',
};

Expand Down
21 changes: 11 additions & 10 deletions frontend/src/utils/parser/bpmnToSsotParsing/bpmnToSsotParsing.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
/* eslint-disable no-param-reassign */
import { parseString } from 'xmljs2';
import customNotification from '../../componentsFunctionality/notificationUtils';
import {
getRobotId,
getRobotName,
} from '../../sessionStorage/localSsotController/ssot';

const { parseString } = require('xmljs2');
import ssotBaseObjects from '../ssotBaseObjects';

/**
* @category Frontend
* @module
*/

const ssotBaseObjects = require('../ssotBaseObjects');

const ssotBaseElement = ssotBaseObjects.baseElement;

/**
* @description Creates a base element of the single source of truth
* @returns {object} Base element of the single source of truth
* @returns {Object} Base element of the single source of truth
*/
const createBaseElement = (id) => {
// creates deep copy of baseElement
const baseElement = JSON.parse(JSON.stringify(ssotBaseElement));
baseElement.id = id;
return baseElement;
};

/**
* @description Checks if the given id can be found in the given Array of element objects
* @returns {boolean} Boolean if element is tracked in Array
* @returns {Boolean} Boolean if element is tracked in Array
*/
const isElementTracked = (elementsArray, id) => {
if (elementsArray.find((element) => element.id === id)) {
Expand All @@ -39,7 +36,7 @@ const isElementTracked = (elementsArray, id) => {
};

/**
*
* @description Gets all bpmn elements
* @param {Array} bpmnShapes All shapes of the BPMN diagram
* @param {Array} localElementsArray Current version of the localElementsArray with all elements
* @returns {Array} Array of elements with their id, successors, predecessors and name
Expand All @@ -62,13 +59,14 @@ const returnElementsArrayWithNameLabel = (bpmnShapes, localElementsArray) => {
/**
* @description Creates the array full of elements by iterating over the
* referenced ids in the flow and adding new elements (incl. name) if they have not been added yet
* @param {Array} flows All flow elements of the BPMN diagram
* @param {Array} bpmnShapes All shapes of the BPMN diagram
* @returns {Array} Array of elements with their id, successors, predecessors and name
*/
const findElements = (flows, bpmnShapes) => {
if (typeof flows === 'undefined') {
return [];
}

const localElementsArray = [];

flows.forEach((flow) => {
Expand Down Expand Up @@ -102,6 +100,8 @@ const findElements = (flows, bpmnShapes) => {

/**
* @description Enriches elements in the elementsArray that should be of type instruction
* @param {Array} elementsArray All elements of the BPMN diagram
* @param {Array} bpmnActivities All activities of the BPMN diagram
* @returns {Array} Array of elements for single source of truth
*/
const enrichInstructionElements = (elementsArray, bpmnActivities) => {
Expand Down Expand Up @@ -139,6 +139,7 @@ const enrichInstructionElements = (elementsArray, bpmnActivities) => {

/**
* @description Enriches elements in the elementsArray that should be of type marker
* @param {Array} elementsArray All elements of the BPMN diagram
* @returns {Array} Array of elements for single source of truth
*/
const enrichMarkerElements = (elementsArray) => {
Expand Down Expand Up @@ -182,6 +183,7 @@ const getStartEventId = (bpmnJson) => {

/**
* @description Parses an JSON created from the xml of the bpmn model to the single source of truth
* @param {Object} bpmnXml The xml object of the bpmn diagram
* @returns {string} XML that has to be put in single source of truth file
*/
const parseBpmnToSsot = async (bpmnXml) => {
Expand All @@ -192,7 +194,6 @@ const parseBpmnToSsot = async (bpmnXml) => {

if (typeof startEventId === 'undefined') return undefined;

// Build basic ssot-frame
const ssot = {
_id: robotId,
starterId: startEventId[0],
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5e809d7

Please sign in to comment.