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

Improve paginated/pagination action naming #3218

Merged
merged 1 commit into from
Nov 20, 2018
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
25 changes: 12 additions & 13 deletions src/frontend/app/store/actions/pagination.actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Action } from '@ngrx/store';

import { createEntityRelationPaginationKey } from '../helpers/entity-relations/entity-relations.types';
import { PaginationAction, PaginationClientFilter, PaginationParam } from '../types/pagination.types';
import { BasePaginatedAction, PaginationClientFilter, PaginationParam } from '../types/pagination.types';

export const CLEAR_PAGINATION_OF_TYPE = '[Pagination] Clear all pages of type';
export const CLEAR_PAGINATION_OF_ENTITY = '[Pagination] Clear pagination of entity';
Expand Down Expand Up @@ -36,13 +35,13 @@ export class ClearPaginationOfEntity implements Action {
type = CLEAR_PAGINATION_OF_ENTITY;
}

export class ResetPagination implements PaginationAction {
export class ResetPagination implements BasePaginatedAction {
constructor(public entityKey: string, public paginationKey: string) {
}
type = RESET_PAGINATION;
}

export class CreatePagination implements PaginationAction {
export class CreatePagination implements BasePaginatedAction {
/**
* @param entityKey
* @param paginationKey
Expand All @@ -54,13 +53,13 @@ export class CreatePagination implements PaginationAction {
}


export class ClearPages implements PaginationAction {
export class ClearPages implements BasePaginatedAction {
constructor(public entityKey: string, public paginationKey: string) {
}
type = CLEAR_PAGES;
}

export class SetPage implements PaginationAction {
export class SetPage implements BasePaginatedAction {
constructor(
public entityKey: string,
public paginationKey: string,
Expand All @@ -71,7 +70,7 @@ export class SetPage implements PaginationAction {
type = SET_PAGE;
}

export class SetResultCount implements PaginationAction {
export class SetResultCount implements BasePaginatedAction {
constructor(
public entityKey: string,
public paginationKey: string,
Expand All @@ -81,7 +80,7 @@ export class SetResultCount implements PaginationAction {
type = SET_RESULT_COUNT;
}

export class SetClientPageSize implements PaginationAction {
export class SetClientPageSize implements BasePaginatedAction {
constructor(
public entityKey: string,
public paginationKey: string,
Expand All @@ -91,7 +90,7 @@ export class SetClientPageSize implements PaginationAction {
type = SET_CLIENT_PAGE_SIZE;
}

export class SetClientPage implements PaginationAction {
export class SetClientPage implements BasePaginatedAction {
constructor(
public entityKey: string,
public paginationKey: string,
Expand All @@ -101,7 +100,7 @@ export class SetClientPage implements PaginationAction {
type = SET_CLIENT_PAGE;
}

export class SetClientFilter implements PaginationAction {
export class SetClientFilter implements BasePaginatedAction {
constructor(
public entityKey: string,
public paginationKey: string,
Expand All @@ -111,7 +110,7 @@ export class SetClientFilter implements PaginationAction {
type = SET_CLIENT_FILTER;
}

export class SetParams implements PaginationAction {
export class SetParams implements BasePaginatedAction {
constructor(
public entityKey: string,
public paginationKey: string,
Expand All @@ -135,7 +134,7 @@ export class SetInitialParams implements SetParams {
type = SET_INITIAL_PARAMS;
}

export class AddParams implements PaginationAction {
export class AddParams implements BasePaginatedAction {
constructor(
public entityKey: string,
public paginationKey: string,
Expand All @@ -146,7 +145,7 @@ export class AddParams implements PaginationAction {
type = ADD_PARAMS;
}

export class RemoveParams implements PaginationAction {
export class RemoveParams implements BasePaginatedAction {
constructor(
public entityKey: string,
public paginationKey: string,
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/app/store/actions/service-broker.actions.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { RequestOptions, URLSearchParams } from '@angular/http';

import { entityFactory, serviceBrokerSchemaKey } from '../helpers/entity-factory';
import { PaginationAction } from '../types/pagination.types';
import { PaginatedAction } from '../types/pagination.types';
import { CFStartAction, IRequestAction } from '../types/request.types';
import { getActions } from './action.helper';

export class GetServiceBrokers extends CFStartAction implements PaginationAction {
export class GetServiceBrokers extends CFStartAction implements PaginatedAction {
constructor(
public endpointGuid: string,
public paginationKey: string,
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/app/store/actions/service-instances.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
spaceSchemaKey,
} from '../helpers/entity-factory';
import { createEntityRelationKey, EntityInlineParentAction } from '../helpers/entity-relations/entity-relations.types';
import { PaginationAction } from '../types/pagination.types';
import { PaginatedAction } from '../types/pagination.types';
import { CFStartAction, ICFAction } from '../types/request.types';
import { getActions } from './action.helper';

Expand All @@ -29,7 +29,7 @@ export const getServiceInstanceRelations = [
];

export class GetServiceInstances
extends CFStartAction implements PaginationAction, EntityInlineParentAction {
extends CFStartAction implements PaginatedAction, EntityInlineParentAction {
constructor(
public endpointGuid: string,
public paginationKey: string,
Expand Down Expand Up @@ -139,7 +139,7 @@ export class UpdateServiceInstance extends CreateServiceInstance {
}

export class ListServiceBindingsForInstance
extends CFStartAction implements PaginationAction, EntityInlineParentAction {
extends CFStartAction implements PaginatedAction, EntityInlineParentAction {
constructor(
public endpointGuid: string,
public serviceInstanceGuid: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
spaceSchemaKey,
} from '../helpers/entity-factory';
import { createEntityRelationKey } from '../helpers/entity-relations/entity-relations.types';
import { PaginationAction } from '../types/pagination.types';
import { PaginatedAction } from '../types/pagination.types';
import { CFStartAction } from '../types/request.types';
import { getActions } from './action.helper';

export class GetServicePlanVisibilities extends CFStartAction implements PaginationAction {
export class GetServicePlanVisibilities extends CFStartAction implements PaginatedAction {
constructor(
public endpointGuid: string,
public paginationKey: string,
Expand Down
13 changes: 6 additions & 7 deletions src/frontend/app/store/actions/service-plan.actions.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { RequestOptions, URLSearchParams } from '@angular/http';

import {
applicationSchemaKey,
entityFactory,
organizationSchemaKey,
servicePlanSchemaKey,
servicePlanVisibilitySchemaKey,
spaceSchemaKey,
serviceInstancesSchemaKey,
serviceBindingSchemaKey,
applicationSchemaKey,
serviceInstancesSchemaKey,
servicePlanSchemaKey,
serviceSchemaKey,
spaceSchemaKey,
} from '../helpers/entity-factory';
import { createEntityRelationKey } from '../helpers/entity-relations/entity-relations.types';
import { PaginationAction } from '../types/pagination.types';
import { PaginatedAction } from '../types/pagination.types';
import { CFStartAction } from '../types/request.types';
import { getActions } from './action.helper';

export class GetServicePlanServiceInstances extends CFStartAction implements PaginationAction {
export class GetServicePlanServiceInstances extends CFStartAction implements PaginatedAction {
constructor(
public servicePlanGuid: string,
public endpointGuid: string,
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/app/store/actions/service.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { RequestOptions, URLSearchParams } from '@angular/http';

import { entityFactory, servicePlanSchemaKey, serviceSchemaKey } from '../helpers/entity-factory';
import { createEntityRelationKey, EntityInlineParentAction } from '../helpers/entity-relations/entity-relations.types';
import { PaginationAction } from '../types/pagination.types';
import { PaginatedAction } from '../types/pagination.types';
import { CFStartAction } from '../types/request.types';
import { getActions } from './action.helper';

export class GetAllServices extends CFStartAction implements PaginationAction, EntityInlineParentAction {
export class GetAllServices extends CFStartAction implements PaginatedAction, EntityInlineParentAction {
constructor(
public paginationKey: string,
public endpointGuid: string = null,
Expand Down Expand Up @@ -53,7 +53,7 @@ export class GetService extends CFStartAction implements EntityInlineParentActio
options: RequestOptions;
}

export class GetServicePlansForService extends CFStartAction implements PaginationAction {
export class GetServicePlansForService extends CFStartAction implements PaginatedAction {
constructor(
public serviceGuid: string,
public endpointGuid: string,
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/app/store/actions/space.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
EntityInlineChildAction,
EntityInlineParentAction,
} from '../helpers/entity-relations/entity-relations.types';
import { PaginatedAction, PaginationAction, QParam } from '../types/pagination.types';
import { PaginatedAction, QParam } from '../types/pagination.types';
import { CFStartAction, ICFAction } from '../types/request.types';
import { getActions } from './action.helper';
import { GetAllOrgUsers } from './organization.actions';
Expand Down Expand Up @@ -217,7 +217,7 @@ export class GetAllSpaceUsers extends GetAllOrgUsers {
}


export class GetAllServicesForSpace extends CFStartAction implements PaginationAction, EntityInlineParentAction {
export class GetAllServicesForSpace extends CFStartAction implements PaginatedAction, EntityInlineParentAction {
constructor(
public paginationKey: string,
public endpointGuid: string = null,
Expand Down Expand Up @@ -248,7 +248,7 @@ export class GetAllServicesForSpace extends CFStartAction implements PaginationA


export class GetServiceInstancesForSpace
extends CFStartAction implements PaginationAction, EntityInlineParentAction, EntityInlineChildAction {
extends CFStartAction implements PaginatedAction, EntityInlineParentAction, EntityInlineChildAction {
constructor(
public spaceGuid: string,
public endpointGuid: string,
Expand Down
1 change: 0 additions & 1 deletion src/frontend/app/store/actions/system.actions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Action } from '@ngrx/store';

import { PaginationAction } from '../types/pagination.types';
import { SystemInfo } from '../types/system.types';
import { GetAllEndpoints } from './endpoint.actions';

Expand Down
6 changes: 3 additions & 3 deletions src/frontend/app/store/helpers/store-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { first, map, pairwise, skipWhile } from 'rxjs/operators';
import { AppState } from '../app-state';
import { ActionState } from '../reducers/api-request-reducer/types';
import { selectPaginationState } from '../selectors/pagination.selectors';
import { PaginationAction, PaginationEntityState } from '../types/pagination.types';
import { BasePaginatedAction, PaginationEntityState } from '../types/pagination.types';


export const fetchPaginationStateFromAction = (store: Store<AppState>, action: PaginationAction) =>
export const fetchPaginationStateFromAction = (store: Store<AppState>, action: BasePaginatedAction) =>
store.select(selectPaginationState(action.entityKey, action.paginationKey));

/**
* Using the given action wait until the associated pagination section changes from busy to not busy
*/
export const createPaginationCompleteWatcher = (store: Store<AppState>, action: PaginationAction): Observable<boolean> =>
export const createPaginationCompleteWatcher = (store: Store<AppState>, action: BasePaginatedAction): Observable<boolean> =>
fetchPaginationStateFromAction(store, action).pipe(
map((paginationState: PaginationEntityState) => {
const pageRequest: ActionState =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { RequestAction } from '../../types/request.types';
import { State } from '@ngrx/store';
import { AppState } from '../../app-state';
import { PaginationAction, PaginationEntityState } from '../../types/pagination.types';
import { PaginationEntityState } from '../../types/pagination.types';

export function paginationPageBusy(state: PaginationEntityState, action): PaginationEntityState {
const { busy, apiAction, error } = action;
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/app/store/types/pagination.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ export class PaginationEntityState {
seed?: string;
}

export interface PaginationAction extends Action {
export interface BasePaginatedAction extends Action {
entityKey: string;
paginationKey: string;
}

export interface PaginatedAction extends PaginationAction, IRequestAction {
export interface PaginatedAction extends BasePaginatedAction, IRequestAction {
actions: string[];
flattenPagination?: boolean;
initialParams?: PaginationParam;
Expand Down