Skip to content

Commit

Permalink
#2762 guard add users button on team details view (#3736)
Browse files Browse the repository at this point in the history
* automate-ui: misc small changes

Signed-off-by: Stephan Renatus <srenatus@chef.io>

* automate-ui/user-table: expose {get,create}PermissionsPaths, use in team-details

Signed-off-by: Stephan Renatus <srenatus@chef.io>

* automate-ui/team-add-users: add no-access blank page

Signed-off-by: Stephan Renatus <srenatus@chef.io>

* Full page render

Leverage the existing full-page rendering.
1. Setting the confirm button text to empty suppresses the lower buttons.
2. Use the same close handler to return to team details on exit.
3. A bit of a kludge: using the `heading` attribute to trigger the full page settings.

Signed-off-by: michael sorens <msorens@chef.io>

* automate-ui/authorized.component: remove overrideVisible

Signed-off-by: Stephan Renatus <srenatus@chef.io>

* teams.proto: fix and amend example payloads

Signed-off-by: Stephan Renatus <srenatus@chef.io>

* teams.proto: fix and amend example payloads [regen]

Signed-off-by: Stephan Renatus <srenatus@chef.io>

* automate-ui/team-details: update specs

Signed-off-by: Stephan Renatus <srenatus@chef.io>

* Add line breaks for consistency and clarity

Signed-off-by: michael sorens <msorens@chef.io>

* Unit test fixes identified by wallaby

It is occasionally "more correct" than the standard test runner

Signed-off-by: michael sorens <msorens@chef.io>

* Delete those defamatory falsehoods

Signed-off-by: michael sorens <msorens@chef.io>

* user-table: guard "add some users to get started"

The message to be shown when the user cannot add users is TBD.

Signed-off-by: Stephan Renatus <srenatus@chef.io>

* user-table: change "no create perms" message

Signed-off-by: Stephan Renatus <srenatus@chef.io>

* project-details: remove whitespace

Signed-off-by: Stephan Renatus <srenatus@chef.io>

* Make app-user-table ignorant of its consumers

Let the body of the `<app-user-table>` provide the text
of a "no-users-present-and-no-permissions-to-add-them" message.

Signed-off-by: michael sorens <msorens@chef.io>

Co-authored-by: michael sorens <msorens@chef.io>
  • Loading branch information
srenatus and msorens committed May 29, 2020
1 parent 0efe530 commit 22e5d7d
Show file tree
Hide file tree
Showing 19 changed files with 242 additions and 150 deletions.
77 changes: 39 additions & 38 deletions components/automate-gateway/api/iam/v2/request/teams.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions components/automate-gateway/api/iam/v2/request/teams.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ message CreateTeamReq {
json_schema: {
required: ["id", "name"]
},
example: { value: '{"id": "test-id", "name": "My Test Team", "projects": ["project1", "project2"]}'}
example: { value: '{"id": "my-team-id", "name": "My Test Team", "projects": ["project1", "project2"]}' }
};
string id = 1;
string name = 2;
Expand All @@ -33,7 +33,7 @@ message UpdateTeamReq {
json_schema: {
required: ["id", "name"]
},
example: { value: '{"name": "My Test Team", "projects": ["project1", "project2"]}'}
example: { value: '{"id": "my-team-id", "name": "My Test Team", "projects": ["project1", "project2"]}' }
};
string id = 1;
string name = 2;
Expand All @@ -44,7 +44,8 @@ message DeleteTeamReq {
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_schema) = {
json_schema: {
required: ["id"]
}
},
example: { value: '{"id": "operators"}' }
};
string id = 1;
}
Expand All @@ -54,7 +55,7 @@ message AddTeamMembersReq {
json_schema: {
required: ["id", "membership_ids"]
},
example: { value: '{"membership_ids": ["527ed96f-2ecb-4f8f-abd7-0bf6511459ac", "353a62d4-85fa-4423-b12a-f6608a562ae9"]}'}
example: { value: '{"id": "admins", "membership_ids": ["527ed96f-2ecb-4f8f-abd7-0bf6511459ac", "353a62d4-85fa-4423-b12a-f6608a562ae9"]}' }
};
string id = 1;
repeated string membership_ids = 2;
Expand All @@ -74,7 +75,7 @@ message RemoveTeamMembersReq {
json_schema: {
required: ["id", "membership_ids"]
},
example: { value: '{"membership_ids": ["527ed96f-2ecb-4f8f-abd7-0bf6511459ac", "353a62d4-85fa-4423-b12a-f6608a562ae9"]}'}
example: { value: '{"id": "admins", "membership_ids": ["527ed96f-2ecb-4f8f-abd7-0bf6511459ac", "353a62d4-85fa-4423-b12a-f6608a562ae9"]}' }
};
string id = 1;
repeated string membership_ids = 2;
Expand All @@ -84,7 +85,8 @@ message GetTeamsForMemberReq {
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_schema) = {
json_schema: {
required: ["membership_id"]
}
},
example: { value: '{"membership_id": "527ed96f-2ecb-4f8f-abd7-0bf6511459ac"}' }
};
string membership_id = 1;
}
Expand Down
5 changes: 4 additions & 1 deletion components/automate-gateway/api/iam/v2/teams.swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion components/automate-gateway/api/iam_v2_teams.pb.swagger.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ describe('AuthorizedComponent', () => {

function genCheck(path?: string, method?: string, paramList?: string | string[]): Check {
const methods = ['get', 'put', 'post', 'delete', 'patch'];
return <Check>[
return [
path || `/${faker.lorem.word()}/${faker.lorem.word()}/${faker.lorem.word()}`,
method || faker.random.arrayElement(methods),
paramList || []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type Check = [string, string] | [string, string, string | string[]];

@Component({
selector: 'app-authorized',
template: '<ng-content *ngIf="visible || overrideVisible"></ng-content>'
template: '<ng-content *ngIf="visible"></ng-content>'
})
export class AuthorizedComponent implements OnInit, OnDestroy {

Expand All @@ -41,11 +41,6 @@ export class AuthorizedComponent implements OnInit, OnDestroy {
// Include the bare `not` attribute in your HTML element to negate the check.
@Input() not?: boolean;

// If you wish to override the permissions check and set content to visible anyway.
// Defaults to false. Useful when trying to generalize components that contain
// this component.
@Input() overrideVisible = false;

// if you wish to output visible
@Output() isAuthorized: EventEmitter<boolean> = new EventEmitter();

Expand Down Expand Up @@ -103,14 +98,14 @@ export class AuthorizedComponent implements OnInit, OnDestroy {

private convertToObject(input: Check[]): CheckObj[] {
return input.map(
([endpoint, verb, paramList]: Check) =>
<CheckObj>{ endpoint, verb, paramList });
([endpoint, verb, paramList]: Check): CheckObj =>
({ endpoint, verb, paramList }));
}

private downcaseVerb(input: CheckObj[]): CheckObj[] {
return input.map(
({ endpoint, verb, paramList }: CheckObj) =>
<CheckObj>{ endpoint, verb: verb.toLowerCase(), paramList }
({ endpoint, verb, paramList }: CheckObj): CheckObj =>
({ endpoint, verb: verb.toLowerCase(), paramList })
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('CreateObjectModalComponent', () => {
MockComponent({ selector: 'app-resource-dropdown',
inputs: ['resources', 'resourcesUpdated', 'objectNounPlural'] }),
MockComponent({ selector: 'app-projects-dropdown',
inputs: ['projects', 'projectsUpdated'] })
inputs: ['projects', 'projectsUpdated', 'checkedProjectIDs'] })
],
imports: [
ReactiveFormsModule,
Expand Down
4 changes: 1 addition & 3 deletions components/automate-ui/src/app/helpers/auth/authorized.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ export class AuthorizedChecker {
filter(perms => !isEmpty(perms)),
filter(() => !isEmpty(this.allOf) || !isEmpty(this.anyOf)),
filter(perms => this.permsPopulated(perms)),
rxjsMap(perms => {
return this.evalPerms(perms);
}));
rxjsMap(perms => this.evalPerms(perms)));
}

public setPermissions(allOf: CheckObj[], anyOf: CheckObj[]): void {
Expand Down
Loading

0 comments on commit 22e5d7d

Please sign in to comment.