Skip to content

Commit

Permalink
frontend: Fixing feature flags and workflow routes (#2975)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdslaugh committed Apr 11, 2024
1 parent bd6d030 commit 18e0aa9
Showing 1 changed file with 35 additions and 25 deletions.
60 changes: 35 additions & 25 deletions frontend/packages/core/src/AppProvider/registrar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,42 @@ const registeredWorkflows = async (
configuration: UserConfiguration,
filters: { (workflows: Workflow[]): Promise<Workflow[]> }[] = []
): Promise<Workflow[]> => {
let validWorkflows = Object.keys(workflows || [])
.map((workflowId: string) => {
const workflow = workflows[workflowId]();
const icon = configuration?.[workflowId]?.icon || { path: "" };
try {
return {
...workflow,
icon,
routes: workflowRoutes(workflowId, workflow, configuration),
};
} catch {
// n.b. if the routes aren't configured properly we drop the workflow
/* eslint-disable-next-line no-console */
console.warn(
`Skipping registration of ${workflowId || "unknown"} workflow due to invalid config`
);
return null;
}
})
.filter(workflow => workflow !== null);
filters.forEach(f => {
f(validWorkflows).then(w => {
validWorkflows = w;
});
// eslint-disable-next-line no-async-promise-executor
return new Promise(async resolve => {
let validWorkflows = Object.keys(workflows || [])
.map((workflowId: string) => {
const workflow = workflows[workflowId]();
const icon = configuration?.[workflowId]?.icon || { path: "" };
try {
return {
...workflow,
icon,
routes: workflowRoutes(workflowId, workflow, configuration),
};
} catch {
// n.b. if the routes aren't configured properly we drop the workflow
/* eslint-disable-next-line no-console */
console.warn(
`Skipping registration of ${workflowId || "unknown"} workflow due to invalid config`
);
return null;
}
})
.filter(workflow => workflow !== null);
try {
await Promise.all(
filters.map(f =>
f(validWorkflows).then(w => {
validWorkflows = w;
})
)
);
} catch (e) {
/* eslint-disable-next-line no-console */
console.warn("Error applying filters to workflows", e);
}
resolve(validWorkflows);
});
return validWorkflows;
};

export { registeredWorkflows, workflowRoutes };

0 comments on commit 18e0aa9

Please sign in to comment.