Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
feat(delete-work-item): add internal user level feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
divyanshiGupta committed Nov 1, 2018
1 parent fe4d073 commit a5d228e
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<span *ngIf="allowDelete | async"
id="wi-delete-icon"
class="pficon-delete pointer"
placement="right"
tooltip="Delete work item"
(click)="deleteWorkItem($event)">
</span>
<f8-feature-toggle featureName="Planner.deleteWorkItem" [userLevel]="internal"></f8-feature-toggle>
<ng-template #internal>
<span *ngIf="allowDelete | async"
id="wi-delete-icon"
class="pficon-delete pointer"
placement="right"
tooltip="Delete work item"
(click)="deleteWorkItem($event)">
</span>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ export class DeleteWorkitemComponent {
private permissionQuery: PermissionQuery
) {}

deleteWorkItem(event: MouseEvent) {
deleteWorkItem(event: MouseEvent): void {
let note = 'Are you sure you want to delete this work item?';
if (this.workitem.hasChildren) {
note = 'This work item has children. ' + note;
}
this.modalService.openModal('Delete Work Item', note, 'Delete', 'deleteWorkItem')
.pipe(
first()
).subscribe(actionKey => {
).subscribe((actionKey: string) => {
if (actionKey === 'deleteWorkItem') {
this.onDelete.emit();
this.store.dispatch(new Delete(this.workitem));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { TooltipConfig, TooltipModule } from 'ngx-bootstrap/tooltip';
import { FeatureFlagModule } from 'ngx-feature-flag';
import { ModalService } from '../../services/modal.service';
import { DeleteWorkitemComponent } from './delete-work-item.component';

@NgModule({
imports: [CommonModule, TooltipModule],
imports: [CommonModule, TooltipModule, FeatureFlagModule],
declarations: [DeleteWorkitemComponent],
exports: [DeleteWorkitemComponent],
providers: [ModalService, TooltipConfig]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ <h4>Please wait, we are loading your data.</h4>
</div>

<work-item-preview-panel #quickPreview
(onOpen)="isQuickPreviewOpen = true"
(onClose)="isQuickPreviewOpen = false"
[context]="'query'">
</work-item-preview-panel>

Expand Down Expand Up @@ -107,6 +109,7 @@ <h4>Please wait, we are loading your data.</h4>
[context]="'query'"
(onQuickPreview)="onPreview($event)"
(onChildExploration)="onChildExploration($event)"
(onDelete)="isQuickPreviewOpen ? closePreview() : ''"
[class.f8-wi__table-config]="c.prop === 'label' || c.prop === 'assignees'"
[class.planner-hack-title-truncate]="c.prop === 'title'">
</work-item-cell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class PlannerQueryComponent implements OnInit, OnDestroy, AfterViewChecke
// This variable stores the number of items
// Scroll is already checked for
private scrollCheckedFor: number = 0;
private isQuickPreviewOpen: boolean;

constructor(
private cookieService: CookieService,
Expand Down Expand Up @@ -136,6 +137,10 @@ export class PlannerQueryComponent implements OnInit, OnDestroy, AfterViewChecke
this.quickPreview.open(workItem);
}

closePreview(): void {
this.quickPreview.close();
}

setDataTableColumns() {
// Cookie for datatableColumn config
if (!this.cookieService.getCookie(datatableColumn.length).status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
<f8-delete-workitem
*ngIf="context === 'query'"
class="margin-left-10 padding-v-5"
[workitem]="row">
[workitem]="row"
(onDelete)="onDelete.emit()">
</f8-delete-workitem>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class WorkItemCellComponent {
@Output() readonly onQuickPreview = new EventEmitter();
@Output() readonly clickLabel = new EventEmitter();
@Output() readonly onChildExploration = new EventEmitter();
@Output() readonly onDelete = new EventEmitter();


onDetail(Event: MouseEvent, id: string) {
Expand Down
44 changes: 22 additions & 22 deletions src/app/effects/work-item.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,26 +411,26 @@ export class WorkItemEffects {
})
);

@Effect() deleteWorkItem$: Observable<Action> = this.actions$
.pipe(
util.filterTypeWithSpace(WorkItemActions.DELETE, this.store.pipe(select(state => state.planner))),
map(([action, state]) => {
return {
payload: action.payload,
state: state
};
}),
switchMap((wp) => {
const workitem = this.workItemMapper.toServiceModel(wp.payload);
return this.workItemService.delete(workitem)
.pipe(
map(() => {
return new WorkItemActions.DeleteSuccess(wp.payload);
}),
catchError(err => this.errHandler.handleError<Action>(
err, `Problem in Deleting work item.`, new WorkItemActions.DeleteError()
))
);
})
);
@Effect() deleteWorkItem$: Observable<Action> = this.actions$
.pipe(
util.filterTypeWithSpace(WorkItemActions.DELETE, this.store.pipe(select(state => state.planner))),
map(([action, state]) => {
return {
payload: action.payload,
state: state
};
}),
switchMap((wp) => {
const workitem = this.workItemMapper.toServiceModel(wp.payload);
return this.workItemService.delete(workitem)
.pipe(
map(() => {
return new WorkItemActions.DeleteSuccess(wp.payload);
}),
catchError(err => this.errHandler.handleError<Action>(
err, `Problem in Deleting work item.`, new WorkItemActions.DeleteError()
))
);
})
);
}
3 changes: 2 additions & 1 deletion src/app/services/work-item.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
Comment
} from '../models/comment';

import { HttpErrorResponse } from '@angular/common/http';
import { AreaModel } from '../models/area.model';
import { Link } from '../models/link';
import { LinkTypeService } from '../models/link-type';
Expand Down Expand Up @@ -261,7 +262,7 @@ export class WorkItemService {
let endpoint = workitem.links.self;
return this.httpClientService.delete(endpoint)
.pipe(
catchError((error: Error | any) => {
catchError((error: Error | HttpErrorResponse) => {
this.notifyError('Deleting workitem failed.', error);
return throwError(new Error(error.message));
})
Expand Down
2 changes: 1 addition & 1 deletion src/tests/specs/iteration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('Iteration test', () => {
await planner.resetState();
});

xit('should create a new iteration', async () => {
it('should create a new iteration', async () => {
let newIteration = 'new Iteration';
await planner.sidePanel.createNewIteration();
await planner.iteration.addNewIteration(newIteration, null, true);
Expand Down

0 comments on commit a5d228e

Please sign in to comment.