Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Show Success/Failure Message Toast After Task/User Story Generation/Regeneration #64

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/whole-dancers-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"specif-ai": patch
---

Introduce success & failure toast messages for Task/User Story generation/regeneration
12 changes: 12 additions & 0 deletions ui/src/app/constants/app.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ export const TOASTER_MESSAGES = {
FAILURE: (entityType: string, entityId: string) =>
TOASTER_MESSAGES_DEFAULT_TEMPLATE.FAILURE(entityType, 'copy', entityId),
},
GENERATE: {
SUCCESS: (entityType: string, isRegenerate = false) =>
TOASTER_MESSAGES_DEFAULT_TEMPLATE.SUCCESS(
entityType,
isRegenerate ? 'regenerated' : 'generated',
),
FAILURE: (entityType: string, isRegenerate = false) =>
TOASTER_MESSAGES_DEFAULT_TEMPLATE.FAILURE(
entityType,
isRegenerate ? 'regenerate' : 'generate',
),
},
},
};

Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/pages/tasks/task-list/task-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h2 class="text-md font-semibold text-gray-600">Tasks</h2>
theme="secondary"
size="sm"
rounded="lg"
(click)="addExtraContext()"
(click)="addExtraContext(taskList.length > 0)"
/>
</ng-container>

Expand Down Expand Up @@ -87,6 +87,7 @@ <h2 class="text-md font-semibold text-gray-600">Tasks</h2>
[isIconButton]="true"
icon="heroDocumentDuplicate"
(click)="copyTaskContent($event, task)"
matTooltip="Copy"
/>
</div>
</app-list-item>
Expand Down
23 changes: 17 additions & 6 deletions ui/src/app/pages/tasks/task-list/task-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { MatDialog } from '@angular/material/dialog';
import { ProjectsState } from '../../../store/projects/projects.state';
import { AsyncPipe, NgForOf, NgIf } from '@angular/common';
import { ButtonComponent } from '../../../components/core/button/button.component';
import { MatTooltipModule } from '@angular/material/tooltip';
import { NgIconComponent } from '@ng-icons/core';
import { ListItemComponent } from '../../../components/core/list-item/list-item.component';
import { BadgeComponent } from '../../../components/core/badge/badge.component';
Expand All @@ -46,6 +47,7 @@ import { BehaviorSubject } from 'rxjs';
ListItemComponent,
BadgeComponent,
SearchInputComponent,
MatTooltipModule,
],
})
export class TaskListComponent implements OnInit, OnDestroy {
Expand Down Expand Up @@ -145,7 +147,7 @@ export class TaskListComponent implements OnInit, OnDestroy {
});
}

addExtraContext() {
addExtraContext(regenerate: boolean = false) {
const dialogText = {
title: 'Generate User Story Tasks',
description:
Expand All @@ -159,18 +161,18 @@ export class TaskListComponent implements OnInit, OnDestroy {
});

dialogRef.componentInstance.generate.subscribe((emittedValue) => {
this.refineUserStoryIntoTasks(emittedValue);
this.refineUserStoryIntoTasks(regenerate, emittedValue);
});
}

refineUserStoryIntoTasks(extraContext: string) {
refineUserStoryIntoTasks(regenerate: boolean = false, extraContext: string) {
let request: ITaskRequest = {
appId: this.config.projectId,
reqId: this.config.newFileName.split('-')[0],
featureId: this.selectedUserStory.id,
name: this.selectedUserStory.name,
description: this.selectedUserStory.description,
regenerate: true,
regenerate: regenerate,
technicalDetails: this.metadata.technicalDetails || '',
extraContext: extraContext,
};
Expand All @@ -184,17 +186,23 @@ export class TaskListComponent implements OnInit, OnDestroy {
tasks: tasksResponse,
};
this.userStories = updatedUserStories;
this.updateWithUserStories(updatedUserStories[this.config.i]);
this.updateWithUserStories(
updatedUserStories[this.config.i],
regenerate,
);
},
error: (error) => {
console.error('There was an error!', error);
this.loadingService.setLoading(false);
this.toastService.showError(
TOASTER_MESSAGES.ENTITY.GENERATE.FAILURE(this.entityType, regenerate),
);
},
});
this.dialog.closeAll();
}

updateWithUserStories(userStories: IUserStory) {
updateWithUserStories(userStories: IUserStory, regenerate: boolean = false) {
this.store.dispatch(
new EditUserStory(
`${this.config.folderName}/${this.config.newFileName}`,
Expand All @@ -204,6 +212,9 @@ export class TaskListComponent implements OnInit, OnDestroy {
setTimeout(() => {
this.getLatestUserStories();
this.loadingService.setLoading(false);
this.toastService.showSuccess(
TOASTER_MESSAGES.ENTITY.GENERATE.SUCCESS(this.entityType, regenerate),
);
}, 2000);
}

Expand Down
17 changes: 6 additions & 11 deletions ui/src/app/pages/user-stories/user-stories.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,14 @@ <h2 class="text-md font-semibold text-gray-600">User Stories</h2>

<div class="flex items-center justify-between gap-3">
<app-button
*ngIf="userStories.length === 0"
buttonContent="Generate User Stories"
[buttonContent]="
userStories.length === 0
? 'Generate User Stories'
: 'Regenerate User Stories'
"
theme="secondary"
size="sm"
(click)="addMoreContext(true)"
rounded="lg"
/>
<app-button
*ngIf="userStories.length > 0"
buttonContent="Regenerate User Stories"
theme="secondary"
size="sm"
(click)="addMoreContext(true)"
(click)="addMoreContext(userStories.length > 0)"
rounded="lg"
/>
<app-button
Expand Down
19 changes: 15 additions & 4 deletions ui/src/app/pages/user-stories/user-stories.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ import { NgIconComponent } from '@ng-icons/core';
import { ListItemComponent } from '../../components/core/list-item/list-item.component';
import { BadgeComponent } from '../../components/core/badge/badge.component';
import { ConfirmationDialogComponent } from 'src/app/components/confirmation-dialog/confirmation-dialog.component';
import { CONFIRMATION_DIALOG, TOASTER_MESSAGES } from '../../constants/app.constants';
import {
CONFIRMATION_DIALOG,
TOASTER_MESSAGES,
} from '../../constants/app.constants';
import { SearchInputComponent } from '../../components/core/search-input/search-input.component';
import { SearchService } from '../../services/search/search.service';
import { BehaviorSubject } from 'rxjs';
Expand Down Expand Up @@ -268,12 +271,14 @@ export class UserStoriesComponent implements OnInit {
next: (response) => {
this.userStories = response;
this.generateTasks(regenerate).then(() => {
this.updateWithUserStories(this.userStories);
this.updateWithUserStories(this.userStories, regenerate);
});
},
error: (error) => {
this.loadingService.setLoading(false);
console.error('Error fetching user stories:', error);
this.toast.showError(
TOASTER_MESSAGES.ENTITY.GENERATE.FAILURE(this.entityType, regenerate),
);
},
});
this.dialog.closeAll();
Expand Down Expand Up @@ -308,7 +313,10 @@ export class UserStoriesComponent implements OnInit {
return Promise.all(requests);
}

updateWithUserStories(userStories: IUserStory[]) {
updateWithUserStories(
userStories: IUserStory[],
regenerate: boolean = false,
) {
this.store.dispatch(
new CreateFile(
`${this.navigation.folderName}`,
Expand All @@ -320,6 +328,9 @@ export class UserStoriesComponent implements OnInit {
setTimeout(() => {
this.getLatestUserStories();
this.loadingService.setLoading(false);
this.toast.showSuccess(
TOASTER_MESSAGES.ENTITY.GENERATE.SUCCESS(this.entityType, regenerate),
);
}, 2000);
}

Expand Down