Skip to content

Commit

Permalink
feat(dashboard): improvements & fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ChmaraX committed Dec 9, 2024
1 parent 0302cd8 commit 01e4a62
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function toResponseWorkflowDto(
tags: workflow.tags,
active: workflow.active,
preferences: preferencesDto,
steps: steps,
steps,
description: workflow.description,
origin: computeOrigin(workflow),
updatedAt: workflow.updatedAt || 'Missing Updated At',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ export class BuildStepDataUsecase {
const workflow = await this.fetchWorkflow(command);

const { currentStep } = await this.loadStepsFromDb(command, workflow);
if (
currentStep.name === undefined ||
!currentStep._templateId ||
currentStep.stepId === undefined ||
!currentStep.template?.type
) {

if (!currentStep._templateId || !currentStep.template?.type) {
throw new InvalidStepException(currentStep);
}
const controlValues = await this.getValues(command, currentStep, workflow._id);
const stepName = currentStep.name || 'Missing Step Name';

return {
controls: {
Expand All @@ -43,10 +40,10 @@ export class BuildStepDataUsecase {
stepInternalId: currentStep._templateId,
workflow,
}),
name: currentStep.name,
slug: buildSlug(currentStep.name, ShortIsPrefixEnum.STEP, currentStep._templateId),
name: stepName,
slug: buildSlug(stepName, ShortIsPrefixEnum.STEP, currentStep._templateId),
_id: currentStep._templateId,
stepId: currentStep.stepId,
stepId: currentStep.stepId || 'Missing Step Id',
type: currentStep.template?.type,
origin: workflow.origin || WorkflowOriginEnum.EXTERNAL,
workflowId: workflow.triggers[0].identifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
WorkflowInternalResponseDto,
} from '@novu/application-generic';

import { NotificationStepEntity } from '@novu/dal';
import { GetWorkflowCommand } from './get-workflow.command';
import { toResponseWorkflowDto } from '../../mappers/notification-template-mapper';
import { BuildStepDataUsecase } from '../build-step-data/build-step-data.usecase';
import { BuildStepDataCommand } from '../build-step-data/build-step-data.command';
import { NotificationStepEntity } from '@novu/dal';

@Injectable()
export class GetWorkflowUseCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class SyncToEnvironmentUseCase {
externalId: string
): Promise<WorkflowResponseDto | undefined> {
try {
return this.getWorkflowUseCase.execute(
return await this.getWorkflowUseCase.execute(
GetWorkflowCommand.create({
user: { ...command.user, environmentId: command.targetEnvironmentId },
workflowIdOrInternalId: externalId,
Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/app/workflows-v2/workflow.controller.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,11 @@ describe('Workflow Controller E2E API Testing', () => {
describe('Promote Workflow Permutations', () => {
it('should promote by creating a new workflow in production environment with the same properties', async () => {
// Create a workflow in the development environment
const devWorkflow = await createWorkflowAndValidate('-promote-workflow');
let devWorkflow = await createWorkflowAndValidate('-promote-workflow');
await workflowsClient.patchWorkflowStepData(devWorkflow._id, devWorkflow.steps[0]._id, {
controlValues: { vinyl: 'vinyl', color: 'red', band: 'beatles' },
});
devWorkflow = await getWorkflowRest(devWorkflow._id);

// Switch to production environment and get its ID
const devEnvironmentId = session.environment._id;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/dto/workflows/step.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export type PatchStepDataDto = {
controlValues?: Record<string, unknown>;
};

// remove all these useless step dtos
export type StepDto = {
name: string;
type: StepTypeEnum;
Expand Down

0 comments on commit 01e4a62

Please sign in to comment.