mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-22 11:18:20 +02:00
We're migrating to ESM, which will allow us to import the latest versions of our dependencies. Co-Authored-By: Christopher Kolstad <chriswk@getunleash.io>
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import type { IReleasePlan } from 'interfaces/releasePlans';
|
|
import { useReleasePlanTemplate } from './api/getters/useReleasePlanTemplates/useReleasePlanTemplate.js';
|
|
|
|
export const useReleasePlanPreview = (
|
|
templateId: string,
|
|
featureName: string,
|
|
environment: string,
|
|
): IReleasePlan => {
|
|
const { template } = useReleasePlanTemplate(templateId);
|
|
|
|
return {
|
|
...template,
|
|
featureName,
|
|
environment,
|
|
milestones: template.milestones.map((milestone) => ({
|
|
...milestone,
|
|
releasePlanDefinitionId: template.id,
|
|
strategies: (milestone.strategies || []).map((strategy) => ({
|
|
...strategy,
|
|
parameters: {
|
|
...strategy.parameters,
|
|
...(strategy.parameters.groupId && {
|
|
groupId: String(strategy.parameters.groupId).replaceAll(
|
|
'{{featureName}}',
|
|
featureName,
|
|
),
|
|
}),
|
|
},
|
|
milestoneId: milestone.id,
|
|
})),
|
|
})),
|
|
};
|
|
};
|