prepareSeoEditorialWorkflowComponent function
SeoEditorialWorkflowComponentPlan?
prepareSeoEditorialWorkflowComponent({
- required List<
SeoEditorialWorkflowStageEntry> stages, - required SeoEditorialWorkflowState initialState,
- required SeoEditorialWorkflowViewProjection project,
- String? interactionId,
- int headingLevel = 2,
- String heading = 'Editorial workflow',
- String interactionLabel = 'Editorial approval workflow',
- String statusLabel = 'Status',
- String progressLabel = 'Progress',
- String historyLabel = 'History',
- String submitLabel = 'Submit for review',
- String approveLabel = 'Approve',
- String rejectLabel = 'Reject',
- String publishLabel = 'Publish',
Implementation
SeoEditorialWorkflowComponentPlan? prepareSeoEditorialWorkflowComponent({
required List<SeoEditorialWorkflowStageEntry> stages,
required SeoEditorialWorkflowState initialState,
required SeoEditorialWorkflowViewProjection project,
String? interactionId,
int headingLevel = 2,
String heading = 'Editorial workflow',
String interactionLabel = 'Editorial approval workflow',
String statusLabel = 'Status',
String progressLabel = 'Progress',
String historyLabel = 'History',
String submitLabel = 'Submit for review',
String approveLabel = 'Approve',
String rejectLabel = 'Reject',
String publishLabel = 'Publish',
}) {
if (stages.length != SeoEditorialWorkflowStage.values.length) return null;
final rawLabels = <String>[
heading,
interactionLabel,
statusLabel,
progressLabel,
historyLabel,
submitLabel,
approveLabel,
rejectLabel,
publishLabel,
for (final stage in stages) stage.label,
];
if (rawLabels.fold<int>(0, (sum, label) => sum + label.length) >
seoEditorialWorkflowMaxAggregateLabelTextLength) {
return null;
}
final labels = <String>[];
for (final raw in rawLabels) {
final label = canonicalizeSeoConfiguratorText(
raw,
maxLength: seoEditorialWorkflowMaxLabelTextLength,
);
if (label == null) return null;
labels.add(label.trim());
}
final stageLabels = labels.skip(9).toList(growable: false);
if (stageLabels.toSet().length != stageLabels.length) return null;
final initial = evaluateInitialSeoEditorialWorkflowView(
project,
initialState,
);
if (initial == null) return null;
final candidateId = interactionId?.trim();
final id = candidateId != null && isValidSeoInteractionId(candidateId)
? candidateId
: null;
return SeoEditorialWorkflowComponentPlan._(
stages: List.unmodifiable([
for (final (index, stage) in stages.indexed)
(
label: stageLabels[index],
nodes: List<SeoNode>.unmodifiable(stage.nodes),
),
]),
initial: initial,
interactionId: id,
headingLevel: headingLevel.clamp(1, 6),
heading: labels[0],
interactionLabel: labels[1],
statusLabel: labels[2],
progressLabel: labels[3],
historyLabel: labels[4],
submitLabel: labels[5],
approveLabel: labels[6],
rejectLabel: labels[7],
publishLabel: labels[8],
);
}