Skip to content

Commit

Permalink
Merged in bugfix/SHIBUI-1806 (pull request #476)
Browse files Browse the repository at this point in the history
Fixed dashboard resolvers list
  • Loading branch information
rmathis committed Apr 21, 2021
2 parents 070883f + 7c8b90e commit 97fcfbf
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ <h2 class="mb-4" [ngSwitch]="type$ | async">
[isEnabled]="isEnabled$ | async"
[version]="model$ | async"
[isCurrent]="true">
<button class="btn btn-outline btn-sm btn-danger align-self-start" (click)="deleteResolver(id)" *ngSwitchCase="'resolver'">
<translate-i18n key="action.delete">Delete</translate-i18n>
<i class="fa fa-trash ml-2"></i>
</button>
<div *ngSwitchCase="'resolver'"
class="align-self-start"
[ngbPopover]="(isEnabled$ | async) ? 'A metadata source must be disabled before it can be deleted.' : null"
[openDelay]="300" placement="left" triggers="mouseenter:mouseleave">
<button class="btn btn-outline btn-sm btn-danger align-self-start" (click)="deleteResolver(id, enabled)"
[disabled]="(isEnabled$ | async)">
<translate-i18n key="action.delete">Delete</translate-i18n>
<i class="fa fa-trash ml-2"></i>
</button>
</div>
</metadata-header>
<div class="px-3 my-3 d-flex justify-content-between" id="navigation">
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@
</span>
</ng-container>
</td>
<td class="text-right">
<td class="text-right" [ngbPopover]="resolver.enabled ? 'A metadata source must be disabled before it can be deleted.' : null"
[openDelay]="300" triggers="mouseenter:mouseleave" placement="left">
<button class="btn btn-outline btn-sm btn-danger" (click)="delete.emit({
entity: resolver,
draft: resolver.isDraft()
})">
})"
[disabled]="resolver.enabled">
<span class="sr-only">Delete</span>
<i class="fa fa-trash"></i>
</button>
Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/metadata/manager/manager.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HttpClientModule } from '@angular/common/http';
import { RouterModule } from '@angular/router';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule } from '@angular/forms';
import { NgbPaginationModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { NgbPaginationModule, NgbModalModule, NgbPopoverModule } from '@ng-bootstrap/ng-bootstrap';
import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
Expand Down Expand Up @@ -39,6 +39,7 @@ import { ResolversListComponent } from './component/resolvers-list.component';
RouterModule,
NgbModalModule,
NgbDropdownModule,
NgbPopoverModule,
HttpClientModule,
SharedModule,
I18nModule,
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/metadata/resolver/action/draft.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class RemoveDraftRequest implements Action {
export class RemoveDraftSuccess implements Action {
readonly type = DraftActionTypes.REMOVE_DRAFT_SUCCESS;

constructor(public payload: MetadataResolver) { }
constructor(public payload: string) { }
}

export class RemoveDraftFail implements Action {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,14 @@ export class DraftCollectionEffects {
let val = hasEntityId ? provider.entityId : provider.id;
return this.draftService.find(val, prop).pipe(
switchMap(selected => this.draftService.remove(selected)),
map(p => new actions.RemoveDraftSuccess(p))
map(p => new actions.RemoveDraftSuccess(val))
);
})
);
@Effect()
removeDraftSuccessReload$ = this.actions$.pipe(
ofType<actions.RemoveDraftRequest>(DraftActionTypes.REMOVE_DRAFT),
map(getPayload),
map(provider => new actions.LoadDraftRequest())
ofType<actions.RemoveDraftSuccess>(DraftActionTypes.REMOVE_DRAFT_SUCCESS),
map(action => new actions.LoadDraftRequest())
);

constructor(
Expand Down
5 changes: 3 additions & 2 deletions ui/src/app/metadata/resolver/reducer/draft.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export const initialState: DraftState = adapter.getInitialState({

export function reducer(state = initialState, action: DraftActionsUnion): DraftState {
switch (action.type) {

case DraftActionTypes.LOAD_DRAFT_SUCCESS: {
return adapter.addMany(action.payload, {
return adapter.setAll(action.payload, {
...state,
selectedDraftId: state.selectedDraftId,
});
Expand All @@ -29,7 +30,7 @@ export function reducer(state = initialState, action: DraftActionsUnion): DraftS
}

case DraftActionTypes.REMOVE_DRAFT_SUCCESS: {
return adapter.removeOne(action.payload.id, state);
return adapter.removeOne(action.payload, state);
}

case DraftActionTypes.SELECT_SUCCESS: {
Expand Down

0 comments on commit 97fcfbf

Please sign in to comment.