Skip to content

Commit

Permalink
start handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
gpalade committed Nov 2, 2023
1 parent a47cf98 commit 796fad2
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 19 deletions.
10 changes: 9 additions & 1 deletion gql-bff/src/features/workflow/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ const workflowResolvers = {
const { dataSources, tenant } = context;

const workflow = await dataSources.workflowApi.getWorkflow(name, version);
if (!isMultiTenant) return workflow;
const conductorHandlers =
await dataSources.eventHandlerApi.getEventHandlerList();
const startHandlers = conductorHandlers.filter((a) =>
a.actions.some(
(x) =>
x.action === "start_workflow" && x?.start_workflow?.name === name
)
);
if (!isMultiTenant) return { ...workflow, startHandlers };

const wfTenantId = getTenantIdFromDescription(workflow?.description);
if (userCanSeeResource(wfTenantId, tenant?.id)) {
Expand Down
3 changes: 2 additions & 1 deletion gql-bff/src/features/workflow/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extend type WorkflowDef {
readOnly: Boolean
readOnly: Boolean,
startHandlers: [EventHandler]
}

type ExportWorkflows {
Expand Down
3 changes: 2 additions & 1 deletion react-ui/public/static/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@
"Export": "Export as JSON",
"Delete": "Delete selection",
"Execute": "Execute workflow",
"GeneralSettings": "General settings"
"GeneralSettings": "General settings",
"StartHandler": "Start Event Handlers"
},
"Tour": {
"BadgeContent": "{{curr}} of {{tot}}",
Expand Down
3 changes: 2 additions & 1 deletion react-ui/public/static/locales/fr/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@
"Export": "Exporter au format JSON",
"Delete": "Supprimer la sélection",
"Execute": "Exécuter le workflow",
"GeneralSettings": "Paramètres généraux"
"GeneralSettings": "Paramètres généraux",
"StartHandler": "Start Event Handlers"
},
"Tour": {
"BadgeContent": "{{curr}} sur {{tot}}",
Expand Down
3 changes: 2 additions & 1 deletion react-ui/public/static/locales/ro/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@
"Export": "Exporta ca JSON",
"Delete": "Sterge selectia",
"Execute": "Executa fluxul",
"GeneralSettings": "Setari generale"
"GeneralSettings": "Setari generale",
"StartHandler": "Start Event Handlers"
},
"Tour": {
"BadgeContent": "{{curr}} din {{tot}}",
Expand Down
2 changes: 1 addition & 1 deletion react-ui/src/features/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export const sortingDirection = {
DESC: 'DESC'
}

export const fieldsToBeRemoved = ['__typename', 'historyId', 'readOnly']
export const fieldsToBeRemoved = ['__typename', 'historyId', 'readOnly', 'startHandlers']
16 changes: 11 additions & 5 deletions react-ui/src/features/designer/components/UtilitiesBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import {
Redo,
DescriptionOutlined,
SettingsOutlined
} from '@mui/icons-material'
} from '@mui/icons-material'
import PlayCircleIcon from '@mui/icons-material/PlayCircleOutline'
import StartIcon from '@mui/icons-material/Start';
import PolylineIcon from '@mui/icons-material/Polyline'
import AbcIcon from '@mui/icons-material/Abc'
import { Grid } from '@mui/material'
import { useTranslation } from 'react-i18next'
import styles from '../styles/styles'

const useStyles = makeStyles(styles)

const UtilitiesBar = ({
Expand All @@ -33,7 +33,8 @@ const UtilitiesBar = ({
onUndo,
onRedo,
viewType,
handleViewType
handleViewType,
onViewStartHandler
}) => {
const { t } = useTranslation()
const classes = useStyles()
Expand Down Expand Up @@ -107,8 +108,12 @@ const UtilitiesBar = ({
</IconButton>
</>
)}
<IconButton variant='text' color='secondary' tooltip={t('Designer.UtilitiesBar.StartHandler')} onClick={onViewStartHandler}>
<StartIcon />
</IconButton>

<ToggleButtonGroup value={viewType} exclusive onChange={handleViewType} aria-label='view type'>
<ToggleButton style={{ color: '#26C6DA' }} color='secondary' value='draw' aria-label='draw'>
<ToggleButton color='secondary' value='draw' aria-label='draw'>
<PolylineIcon />
</ToggleButton>
<ToggleButton color='secondary' value='json' aria-label='json'>
Expand All @@ -132,7 +137,8 @@ UtilitiesBar.propTypes = {
onUndo: PropTypes.func.isRequired,
onRedo: PropTypes.func.isRequired,
viewType: PropTypes.string.isRequired,
handleViewType: PropTypes.func.isRequired
handleViewType: PropTypes.func.isRequired,
onViewStartHandler: PropTypes.func.isRequired
}

export default UtilitiesBar
14 changes: 13 additions & 1 deletion react-ui/src/features/workflow/edit/components/Workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ import SideMenu from './sideMenu/SideMenu'
import PreviewJsonDialog from './modals/PreviewJsonDialog'
import { defaultFileName } from 'features/workflow/common/constants'
import workflowConfig from 'features/designer/constants/WorkflowConfig'
import { useToast } from '@totalsoft/rocket-ui'
import { useToast, Dialog } from '@totalsoft/rocket-ui'
import WorkflowJson from './WorkflowJson'
import JsonViewer from 'features/common/components/JsonViewer'

const Workflow = ({ loading, isNew, resetWorkflow, isDirty, workflowLens, diagram, setIsDirty, taskDefs }) => {
const { t } = useTranslation()
Expand All @@ -47,7 +48,9 @@ const Workflow = ({ loading, isNew, resetWorkflow, isDirty, workflowLens, diagra
const [settingsDialog, setSettingsDialog] = useState(false)
const [previewDialog, setPreviewDialog] = useState(false)
const [currentWorkflow, setCurrentWorkflow] = useState(null)
const [startHandlersDialog, showStartHandlersDialog] = useState(false)

const toggleStartHandlersDialog = useCallback(() => showStartHandlersDialog(current => !current), [])
const workflow = workflowLens |> get
const { engine } = diagram

Expand Down Expand Up @@ -268,6 +271,7 @@ const Workflow = ({ loading, isNew, resetWorkflow, isDirty, workflowLens, diagra
onRedo={handleRedo}
viewType={viewType}
handleViewType={handleChangeViewType}
onViewStartHandler={toggleStartHandlersDialog}
/>
{viewType === 'draw' && (
<React.Fragment>
Expand Down Expand Up @@ -303,6 +307,14 @@ const Workflow = ({ loading, isNew, resetWorkflow, isDirty, workflowLens, diagra
workflowLens={workflowLens}
/>
<PreviewJsonDialog open={previewDialog} onClose={togglePreviewDialog} workflow={currentWorkflow || emptyObject} />

<Dialog
id='startHandlers'
open={startHandlersDialog}
title={t('Designer.UtilitiesBar.StartHandler')}
onClose={toggleStartHandlersDialog}
content={<JsonViewer workflow={{ StartHandlers: workflow?.startHandlers }} />}
/>
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const WorkflowContainer = () => {
const [nameDialog, showNameDialog] = useState(false)
const [tourDialog, showTourDialog] = useState(false)
const [startTourDialog, showStartTourDialog] = useState(false)

const toggleNameDialog = useCallback(() => showNameDialog(current => !current), [])
const toggleTourDialog = useCallback(() => showTourDialog(current => !current), [])
const toggleStartTourDialog = useCallback(() => showStartTourDialog(current => !current), [])
Expand Down Expand Up @@ -175,7 +175,7 @@ const WorkflowContainer = () => {
showError(err)
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
createOrUpdateWorkflow,
engine,
Expand Down Expand Up @@ -237,10 +237,7 @@ const WorkflowContainer = () => {
parseObjectParameters(node.inputs, skipParametersByParsing)

node.options.name = inputs?.inputs?.name
if (
inputs?.inputs.type === nodeConfig.DECISION.type &&
(isPropertyDirty('inputs.decisionCases', inputsDirtyInfo))
) {
if (inputs?.inputs.type === nodeConfig.DECISION.type && isPropertyDirty('inputs.decisionCases', inputsDirtyInfo)) {
const cases = keys(inputs?.inputs?.decisionCases)
decisionCasesToPorts(node, cases)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const WorkflowJson = ({ loading, workflow, onChangeJson }) => {
value={JSON.stringify(
workflow,
(key, value) => {
if (key === '__typename') return
if (key === '__typename' || key === 'startHandlers') return
return value
},
'\t'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const GeneralSettingsDialog = ({ open, onClose, onYes, workflowLens }) => {
<Dialog
id='generalSettings'
open={open}
onClose={onClose}
actions={[
<Button key={1} color='primary' size='small' style={{ marginRight: '20px' }} onClick={onYes}>
{t('General.Buttons.Save')}
Expand Down
25 changes: 25 additions & 0 deletions react-ui/src/features/workflow/edit/queries/WorkflowQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,31 @@ export const WORKFLOW_QUERY = gql`
query getWorkflow($name: String!, $version: Int!, $skip: Boolean!) {
getWorkflow(name: $name, version: $version) @skip(if: $skip) {
...partialWorkflowDef
startHandlers {
name
active
event
condition
actions {
action
completeTask {
output
workflowId
taskRefName
}
failTask {
output
workflowId
taskRefName
}
startWorkflow {
name
version
input
}
expandInlineJSON
}
}
tasks {
...workflowTask
forkTasks {
Expand Down

0 comments on commit 796fad2

Please sign in to comment.