Skip to content

Commit

Permalink
Merge pull request #2219 from influxdata/feat/org-members-role-column
Browse files Browse the repository at this point in the history
Update MembersList to include role column
  • Loading branch information
Palakp41 authored Jan 4, 2019
2 parents 7562c9a + 21eb3a2 commit ac7e9df
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 37 deletions.
25 changes: 24 additions & 1 deletion http/cur_swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2398,7 +2398,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/Users"
$ref: "#/components/schemas/ResourceOwners"
default:
description: unexpected error
content:
Expand Down Expand Up @@ -3922,6 +3922,29 @@ components:
type: string
format: uri
required: [name, organization, flux]
ResourceOwner:
allOf:
- $ref: "#/components/schemas/User"
- type: object
properties:
role:
type: string
default: owner
enum:
- owner
ResourceOwners:
type: object
properties:
links:
type: object
properties:
self:
type: string
format: uri
users:
type: array
items:
$ref: "#/components/schemas/ResourceOwner"
User:
properties:
id:
Expand Down
96 changes: 72 additions & 24 deletions ui/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1447,10 +1447,10 @@ export interface Logs {
export interface Macro {
/**
*
* @type {UserLinks}
* @type {ResourceOwnersLinks}
* @memberof Macro
*/
links?: UserLinks;
links?: ResourceOwnersLinks;
/**
*
* @type {string}
Expand Down Expand Up @@ -2188,6 +2188,68 @@ export interface RenamableField {
visible?: boolean;
}

/**
*
* @export
* @interface ResourceOwner
*/
export interface ResourceOwner extends User {
/**
*
* @type {string}
* @memberof ResourceOwner
*/
role?: ResourceOwner.RoleEnum;
}

/**
* @export
* @namespace ResourceOwner
*/
export namespace ResourceOwner {
/**
* @export
* @enum {string}
*/
export enum RoleEnum {
Owner = 'owner'
}
}

/**
*
* @export
* @interface ResourceOwners
*/
export interface ResourceOwners {
/**
*
* @type {ResourceOwnersLinks}
* @memberof ResourceOwners
*/
links?: ResourceOwnersLinks;
/**
*
* @type {Array<ResourceOwner>}
* @memberof ResourceOwners
*/
users?: Array<ResourceOwner>;
}

/**
*
* @export
* @interface ResourceOwnersLinks
*/
export interface ResourceOwnersLinks {
/**
*
* @type {string}
* @memberof ResourceOwnersLinks
*/
self?: string;
}

/**
*
* @export
Expand Down Expand Up @@ -2550,10 +2612,10 @@ export interface SourceLinks {
export interface Sources {
/**
*
* @type {UserLinks}
* @type {ResourceOwnersLinks}
* @memberof Sources
*/
links?: UserLinks;
links?: ResourceOwnersLinks;
/**
*
* @type {Array<Source>}
Expand Down Expand Up @@ -4590,10 +4652,10 @@ export interface User {
status?: User.StatusEnum;
/**
*
* @type {UserLinks}
* @type {ResourceOwnersLinks}
* @memberof User
*/
links?: UserLinks;
links?: ResourceOwnersLinks;
}

/**
Expand All @@ -4611,20 +4673,6 @@ export namespace User {
}
}

/**
*
* @export
* @interface UserLinks
*/
export interface UserLinks {
/**
*
* @type {string}
* @memberof UserLinks
*/
self?: string;
}

/**
*
* @export
Expand All @@ -4633,10 +4681,10 @@ export interface UserLinks {
export interface Users {
/**
*
* @type {UserLinks}
* @type {ResourceOwnersLinks}
* @memberof Users
*/
links?: UserLinks;
links?: ResourceOwnersLinks;
/**
*
* @type {Array<User>}
Expand Down Expand Up @@ -8932,7 +8980,7 @@ export const OrganizationsApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
orgsOrgIDMembersGet(orgID: string, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise<Users> {
orgsOrgIDMembersGet(orgID: string, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise<ResourceOwners> {
const localVarAxiosArgs = OrganizationsApiAxiosParamCreator(configuration).orgsOrgIDMembersGet(orgID, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = Object.assign(localVarAxiosArgs.options, {url: basePath + localVarAxiosArgs.url})
Expand Down Expand Up @@ -14569,7 +14617,7 @@ export const UsersApiFp = function(configuration?: Configuration) {
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
orgsOrgIDMembersGet(orgID: string, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise<Users> {
orgsOrgIDMembersGet(orgID: string, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise<ResourceOwners> {
const localVarAxiosArgs = UsersApiAxiosParamCreator(configuration).orgsOrgIDMembersGet(orgID, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = Object.assign(localVarAxiosArgs.options, {url: basePath + localVarAxiosArgs.url})
Expand Down
13 changes: 11 additions & 2 deletions ui/src/organizations/apis/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import {orgsAPI, bucketsAPI, dashboardsAPI, taskAPI} from 'src/utils/api'

// Types
import {Bucket, Dashboard, Task, Organization, User, Label} from 'src/api'
import {
Bucket,
Dashboard,
Task,
Organization,
ResourceOwner,
Label,
} from 'src/api'

// CRUD APIs for Organizations and Organization resources
// i.e. Organization Members, Buckets, Dashboards etc
Expand Down Expand Up @@ -44,7 +51,9 @@ export const updateOrg = async (org: Organization): Promise<Organization> => {
}

// Members
export const getMembers = async (org: Organization): Promise<User[]> => {
export const getMembers = async (
org: Organization
): Promise<ResourceOwner[]> => {
try {
const {data} = await orgsAPI.orgsOrgIDMembersGet(org.id)

Expand Down
12 changes: 7 additions & 5 deletions ui/src/organizations/components/MemberList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import React, {PureComponent} from 'react'
import {IndexList} from 'src/clockface'

// Types
import {User} from 'src/api'
import {ResourceOwner} from 'src/api'

interface Props {
members: User[]
members: ResourceOwner[]
emptyState: JSX.Element
}

Expand All @@ -17,10 +17,11 @@ export default class MemberList extends PureComponent<Props> {
return (
<IndexList>
<IndexList.Header>
<IndexList.HeaderCell columnName="Name" width="75%" />
<IndexList.HeaderCell width="25%" />
<IndexList.HeaderCell columnName="Username" width="25%" />
<IndexList.HeaderCell columnName="Role" width="25%" />
<IndexList.HeaderCell width="50%" />
</IndexList.Header>
<IndexList.Body columnCount={2} emptyState={this.props.emptyState}>
<IndexList.Body columnCount={3} emptyState={this.props.emptyState}>
{this.rows}
</IndexList.Body>
</IndexList>
Expand All @@ -31,6 +32,7 @@ export default class MemberList extends PureComponent<Props> {
return this.props.members.map(member => (
<IndexList.Row key={member.id}>
<IndexList.Cell>{member.name}</IndexList.Cell>
<IndexList.Cell>{member.role}</IndexList.Cell>
<IndexList.Cell revealOnHover={true}>DELETE</IndexList.Cell>
</IndexList.Row>
))
Expand Down
6 changes: 3 additions & 3 deletions ui/src/organizations/components/Members.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import MemberList from 'src/organizations/components/MemberList'
import FilterList from 'src/shared/components/Filter'

// Types
import {User} from 'src/api'
import {ResourceOwner} from 'src/api'

interface Props {
members: User[]
members: ResourceOwner[]
}

interface State {
Expand All @@ -29,7 +29,7 @@ export default class Members extends PureComponent<Props, State> {
const {searchTerm} = this.state

return (
<FilterList<User>
<FilterList<ResourceOwner>
list={members}
searchKeys={['name']}
searchTerm={searchTerm}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/organizations/containers/OrganizationView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import GetOrgResources from 'src/organizations/components/GetOrgResources'

// Types
import {AppState, Dashboard} from 'src/types/v2'
import {User, Bucket, Organization, Task, Label} from 'src/api'
import {ResourceOwner, Bucket, Organization, Task, Label} from 'src/api'

// Decorators
import {ErrorHandling} from 'src/shared/decorators/errors'
Expand Down Expand Up @@ -71,7 +71,7 @@ class OrganizationView extends PureComponent<Props> {
url="members_tab"
title="Members"
>
<GetOrgResources<User[]>
<GetOrgResources<ResourceOwner[]>
organization={org}
fetcher={getMembers}
>
Expand Down

0 comments on commit ac7e9df

Please sign in to comment.