stash
This commit is contained in:
parent
8d96bc97c4
commit
ed04d98bf1
54 changed files with 661 additions and 1214 deletions
|
|
@ -1,22 +1,4 @@
|
|||
/**
|
||||
* Workflow Catalog
|
||||
*
|
||||
* Single source of truth for every workflow type known to the frontend:
|
||||
* what it's called, what category/description/icons it has, how many steps
|
||||
* it has and what they're called, what its initial payload looks like, and
|
||||
* which Vue component renders it.
|
||||
*
|
||||
* Each workflow has a fully co-located component + metadata as a static
|
||||
* `meta` option on the component (`Component.meta`, right next to
|
||||
* `name`/`props`/etc.) in `@/components/workflow/workflows/*.vue` - this
|
||||
* file simply imports those components and reads `.meta` off of them to
|
||||
* build the catalog below.
|
||||
*
|
||||
* This replaces the previous design of a parallel `BaseWorkflow` class
|
||||
* hierarchy (metadata) plus a separate per-step `ComponentRegistry.js`
|
||||
* (components) - both concerns now live in one flat array with each
|
||||
* component responsible for its own metadata and UI implementation.
|
||||
*/
|
||||
// Workflow catalog: single source of truth built from each component's `meta`. See docs/implementation.md#workflow-catalog.
|
||||
import FotoFirstBulkImportWorkflow from '@/components/workflow/workflows/FotoFirstBulkImportWorkflow.vue';
|
||||
import BulkItemImportWorkflow from '@/components/workflow/workflows/BulkItemImportWorkflow.vue';
|
||||
import InventoryAuditWorkflow from '@/components/workflow/workflows/InventoryAuditWorkflow.vue';
|
||||
|
|
@ -25,9 +7,6 @@ import MaintenanceScheduleWorkflow from '@/components/workflow/workflows/Mainten
|
|||
import ExpiryCheckWorkflow from '@/components/workflow/workflows/ExpiryCheckWorkflow.vue';
|
||||
import BackupRestoreWorkflow from '@/components/workflow/workflows/BackupRestoreWorkflow.vue';
|
||||
|
||||
/**
|
||||
* Workflows with a fully co-located component + metadata.
|
||||
*/
|
||||
const workflows = [
|
||||
{...FotoFirstBulkImportWorkflow.meta, component: FotoFirstBulkImportWorkflow},
|
||||
{...BulkItemImportWorkflow.meta, component: BulkItemImportWorkflow},
|
||||
|
|
@ -38,56 +17,27 @@ const workflows = [
|
|||
{...BackupRestoreWorkflow.meta, component: BackupRestoreWorkflow},
|
||||
];
|
||||
|
||||
/**
|
||||
* Get every workflow in the catalog.
|
||||
* @returns {Array<Object>}
|
||||
*/
|
||||
export function getAllWorkflows() {
|
||||
return workflows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single workflow definition by id.
|
||||
* @param {string} id
|
||||
* @returns {Object|undefined}
|
||||
*/
|
||||
export function getWorkflow(slug) {
|
||||
return workflows.find(workflow => workflow.slug === slug);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Vue component implementing a workflow's UI, if any.
|
||||
* @param {string} id
|
||||
* @returns {Object|null}
|
||||
*/
|
||||
export function getWorkflowComponent(id) {
|
||||
return getWorkflow(id)?.component || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all workflows belonging to a category.
|
||||
* @param {string} category
|
||||
* @returns {Array<Object>}
|
||||
*/
|
||||
export function getWorkflowsByCategory(category) {
|
||||
return workflows.filter(workflow => workflow.category === category);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all unique categories present in the catalog.
|
||||
* @returns {Array<string>}
|
||||
*/
|
||||
export function getWorkflowCategories() {
|
||||
return [...new Set(workflows.map(workflow => workflow.category))];
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the payload sent to the backend to start a new instance of a
|
||||
* workflow, merging the common `workflow_config` metadata block with the
|
||||
* workflow's own initial payload fields.
|
||||
* @param {Object} workflow - A workflow definition, e.g. from getWorkflow()
|
||||
* @returns {Object}
|
||||
*/
|
||||
// Builds the payload sent to the backend to start a new instance of this workflow.
|
||||
export function buildWorkflowApiPayload(workflow) {
|
||||
const ownPayload = workflow.getInitialPayload ? workflow.getInitialPayload() : {};
|
||||
return {
|
||||
|
|
@ -102,11 +52,7 @@ export function buildWorkflowApiPayload(workflow) {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The backend stores WorkflowInstance.payload as an opaque string - it never
|
||||
* parses or understands it as JSON. The frontend is fully responsible for
|
||||
* serializing it before sending and deserializing it after receiving.
|
||||
*/
|
||||
// Payload is an opaque string to the backend; frontend serializes/deserializes it. See docs/implementation.md#workflow-payload-is-an-opaque-string.
|
||||
export function serializeWorkflowPayload(workflow) {
|
||||
console.log(workflow);
|
||||
if (!workflow || !('payload' in workflow)) return workflow;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue