diff --git a/modules/ui/src/app/components/list-item/list-item.component.html b/modules/ui/src/app/components/list-item/list-item.component.html
index 2e01cce09..1daddf93f 100644
--- a/modules/ui/src/app/components/list-item/list-item.component.html
+++ b/modules/ui/src/app/components/list-item/list-item.component.html
@@ -13,9 +13,13 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
+
Discard
diff --git a/modules/ui/src/app/pages/risk-assessment/profile-form/profile-form.component.ts b/modules/ui/src/app/pages/risk-assessment/profile-form/profile-form.component.ts
index 539e5d724..32eaf0407 100644
--- a/modules/ui/src/app/pages/risk-assessment/profile-form/profile-form.component.ts
+++ b/modules/ui/src/app/pages/risk-assessment/profile-form/profile-form.component.ts
@@ -157,6 +157,13 @@ export class ProfileFormComponent implements OnInit, AfterViewInit {
);
}
+ get isDiscardDisabled(): boolean {
+ return (
+ (this.profileHasNoChanges() || this.profileForm.pristine) &&
+ !this.copyProfile
+ );
+ }
+
profileHasNoChanges() {
const oldProfile = this.profile;
const newProfile = oldProfile
@@ -384,6 +391,11 @@ export class ProfileFormComponent implements OnInit, AfterViewInit {
}
this.changeProfile = true;
this.store.updateSelectedProfile(profile);
+ } else {
+ if (this.copyProfile?.name !== this.profile?.name) {
+ this.copyProfile = null;
+ this.cd.detectChanges();
+ }
}
});
}
diff --git a/modules/ui/src/app/pages/risk-assessment/profile-item/profile-item.component.scss b/modules/ui/src/app/pages/risk-assessment/profile-item/profile-item.component.scss
index 509ef9d2c..732bdfef2 100644
--- a/modules/ui/src/app/pages/risk-assessment/profile-item/profile-item.component.scss
+++ b/modules/ui/src/app/pages/risk-assessment/profile-item/profile-item.component.scss
@@ -61,6 +61,12 @@ $profile-item-container-gap: 8px;
color: colors.$grey-800;
}
+:host-context(.no-actions-menu) {
+ .profile-item-info .profile-item-name {
+ max-width: 260px;
+ }
+}
+
.profile-item-info {
cursor: pointer;
display: grid;
diff --git a/modules/ui/src/app/pages/risk-assessment/risk-assessment.component.spec.ts b/modules/ui/src/app/pages/risk-assessment/risk-assessment.component.spec.ts
index 98a1bf5dd..84ea51995 100644
--- a/modules/ui/src/app/pages/risk-assessment/risk-assessment.component.spec.ts
+++ b/modules/ui/src/app/pages/risk-assessment/risk-assessment.component.spec.ts
@@ -255,25 +255,6 @@ describe('RiskAssessmentComponent', () => {
).toHaveBeenCalledWith(null);
expect(component.isOpenProfileForm).toBeFalse();
}));
-
- it('should remove copy and close form when unsaved copy is deleted', fakeAsync(() => {
- spyOn(component.dialog, 'open').and.returnValue({
- afterClosed: () => of(true),
- } as MatDialogRef);
- component.isCopyProfile = true;
- component.deleteProfile(
- DRAFT_COPY_PROFILE_MOCK,
- [DRAFT_COPY_PROFILE_MOCK, PROFILE_MOCK],
- DRAFT_COPY_PROFILE_MOCK
- );
- tick();
-
- expect(mockRiskAssessmentStore.removeProfile).toHaveBeenCalled();
- expect(
- mockRiskAssessmentStore.updateSelectedProfile
- ).toHaveBeenCalledWith(null);
- expect(component.isOpenProfileForm).toBeFalse();
- }));
});
describe('#openForm', () => {
diff --git a/modules/ui/src/app/pages/risk-assessment/risk-assessment.component.ts b/modules/ui/src/app/pages/risk-assessment/risk-assessment.component.ts
index 29ee99808..125066609 100644
--- a/modules/ui/src/app/pages/risk-assessment/risk-assessment.component.ts
+++ b/modules/ui/src/app/pages/risk-assessment/risk-assessment.component.ts
@@ -189,26 +189,15 @@ export class RiskAssessmentComponent
.pipe(takeUntil(this.destroy$))
.subscribe(deleteProfile => {
if (deleteProfile) {
- if (
- profile &&
- profile.status === ProfileStatus.DRAFT &&
- !profile.created
- ) {
- this.deleteCopy(profile, profiles);
- this.closeFormAfterDelete(profile.name, selectedProfile);
- this.focusAddButton();
- return;
- } else {
- this.store.deleteProfile({
- name: profileName,
- onDelete: (idx = 0) => {
- this.closeFormAfterDelete(profileName, selectedProfile);
- timer(100).subscribe(() => {
- this.setFocus(idx);
- });
- },
- });
- }
+ this.store.deleteProfile({
+ name: profileName,
+ onDelete: (idx = 0) => {
+ this.closeFormAfterDelete(profileName, selectedProfile);
+ timer(100).subscribe(() => {
+ this.setFocus(idx);
+ });
+ },
+ });
} else {
this.store.setFocusOnSelectedProfile();
}
@@ -298,11 +287,12 @@ export class RiskAssessmentComponent
actions(actions: EntityAction[]) {
return (profile: Profile) => {
- // expired profiles or unsaved copy of profile can only be removed
- if (
- profile.status === ProfileStatus.EXPIRED ||
- (profile.status === ProfileStatus.DRAFT && !profile.created)
- ) {
+ // unsaved copy of profile can't have any action
+ if (profile.status === ProfileStatus.DRAFT && !profile.created) {
+ return [];
+ }
+ // expired profiles can only be removed
+ if (profile.status === ProfileStatus.EXPIRED) {
return [{ action: ProfileAction.Delete, icon: 'delete' }];
}
return actions;