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

Don't validate individual org users requests #2651

Merged
merged 3 commits into from
Jul 6, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 8 additions & 8 deletions src/frontend/app/shared/data-services/cf-user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { ActiveRouteCfOrgSpace } from './../../features/cloud-foundry/cf-page.ty
export class CfUserService {
private allUsers$: Observable<PaginationObservables<APIResource<CfUser>>>;

public static createPaginationAction(endpointGuid: string, isAdmin: boolean): PaginatedAction {
public static createPaginationAction(endpointGuid: string, isAdmin: boolean): GetAllUsersAsAdmin | GetAllUsersAsNonAdmin {
return isAdmin ? new GetAllUsersAsAdmin(endpointGuid) : new GetAllUsersAsNonAdmin(endpointGuid);
}

Expand Down Expand Up @@ -113,10 +113,10 @@ export class CfUserService {
this.parseOrgRole(user, orgGuids, [org], res);
} else {
// Discover user's roles for each org via each of the 4 org role types
this.parseOrgRole(user, orgGuids, user.organizations, res);
this.parseOrgRole(user, orgGuids, user.audited_organizations, res);
this.parseOrgRole(user, orgGuids, user.billing_managed_organizations, res);
this.parseOrgRole(user, orgGuids, user.managed_organizations, res);
this.parseOrgRole(user, orgGuids, user.organizations || [], res);
this.parseOrgRole(user, orgGuids, user.audited_organizations || [], res);
this.parseOrgRole(user, orgGuids, user.billing_managed_organizations || [], res);
this.parseOrgRole(user, orgGuids, user.managed_organizations || [], res);
}
return res;
}
Expand Down Expand Up @@ -152,9 +152,9 @@ export class CfUserService {
this.parseSpaceRole(user, spaceGuids, spaces, res);
} else {
// User might have unique spaces in any of the space role collections, so loop through each
this.parseSpaceRole(user, spaceGuids, user.spaces, res);
this.parseSpaceRole(user, spaceGuids, user.audited_spaces, res);
this.parseSpaceRole(user, spaceGuids, user.managed_spaces, res);
this.parseSpaceRole(user, spaceGuids, user.spaces || [], res);
this.parseSpaceRole(user, spaceGuids, user.audited_spaces || [], res);
this.parseSpaceRole(user, spaceGuids, user.managed_spaces || [], res);
}
return res;
}
Expand Down
1 change: 1 addition & 0 deletions src/frontend/app/store/actions/organization.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,5 @@ export class GetAllOrgUsers extends CFStartAction implements PaginatedAction, En
'order-direction-field': 'username',
};
flattenPagination = true;
skipValidation = false;
}
14 changes: 7 additions & 7 deletions src/frontend/app/store/actions/space.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ export class GetAllSpaceUsers extends GetAllOrgUsers {
this.options.url = `spaces/${guid}/user_roles`;
}
actions = getActions('Spaces', 'List all user roles');
initialParams = {
page: 1,
'results-per-page': 100,
'order-direction': 'desc',
'order-direction-field': 'username',
};
flattenPagination = true;
// initialParams = {
// page: 1,
// 'results-per-page': 100,
// 'order-direction': 'desc',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented out code

// 'order-direction-field': 'username',
// };
// flattenPagination = true;
}


Expand Down
3 changes: 2 additions & 1 deletion src/frontend/app/store/actions/users.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ const createGetAllUsersInitialParams = () => ({
'order-direction-field': 'username',
});

export class GetAllUsersAsNonAdmin implements PaginatedAction {
export class GetAllUsersAsNonAdmin implements PaginatedAction, EntityInlineParentAction {
type = GET_CF_USERS_BY_ORG;
paginationKey: string;
actions: string[] = [];
entity = [entityFactory(cfUserSchemaKey)];
entityKey = cfUserSchemaKey;
constructor(
public cfGuid: string,
Expand Down
5 changes: 4 additions & 1 deletion src/frontend/app/store/effects/request.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ export class RequestEffect {
withLatestFrom(this.store.select(getPaginationState)),
first(),
map(([allEntities, allPagination]) => {
return validateEntityRelations({
return apiAction.skipValidation ? {
started: false,
completed: Promise.resolve([])
} : validateEntityRelations({
cfGuid: validateAction.action.endpointGuid,
store: this.store,
allEntities,
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/app/store/effects/users.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ export class UsersEffects {
action.includeRelations,
action.populateMissing
);
// We're not interested if each set of users associated with an org is valid. Leave that up to whoever dispatched the action
// to validate.
getUsersAction.skipValidation = true;
// Create a way to monitor fetch users success
const monitor = createPaginationCompleteWatcher(this.store, getUsersAction);
this.store.dispatch(getUsersAction);
Expand Down
1 change: 1 addition & 0 deletions src/frontend/app/store/types/pagination.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface PaginatedAction extends PaginationAction, IRequestAction {
},
method?: RequestMethod | string | null
};
skipValidation?: boolean;
}

export interface PaginationEntityTypeState {
Expand Down
1 change: 1 addition & 0 deletions src/frontend/app/store/types/request.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export class UpdateCfAction extends RequestUpdateAction implements IUpdateReques
export interface ICFAction extends IRequestAction {
options: RequestOptions;
actions: string[];
skipValidation?: boolean;
}

export class APISuccessOrFailedAction<T = any> implements Action {
Expand Down