From 21eb3a26d87fb37344945783d503bf706fba9057 Mon Sep 17 00:00:00 2001 From: Palak Bhojani Date: Thu, 3 Jan 2019 14:39:49 -0800 Subject: [PATCH] Update MembersList to include role column --- http/cur_swagger.yml | 25 ++++- ui/src/api/api.ts | 96 ++++++++++++++----- ui/src/organizations/apis/index.ts | 13 ++- .../organizations/components/MemberList.tsx | 12 ++- ui/src/organizations/components/Members.tsx | 6 +- .../containers/OrganizationView.tsx | 4 +- 6 files changed, 119 insertions(+), 37 deletions(-) diff --git a/http/cur_swagger.yml b/http/cur_swagger.yml index 7376015eec5..1188376673c 100644 --- a/http/cur_swagger.yml +++ b/http/cur_swagger.yml @@ -2398,7 +2398,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Users" + $ref: "#/components/schemas/ResourceOwners" default: description: unexpected error content: @@ -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: diff --git a/ui/src/api/api.ts b/ui/src/api/api.ts index c76cea703df..4f5bbd476d4 100644 --- a/ui/src/api/api.ts +++ b/ui/src/api/api.ts @@ -1447,10 +1447,10 @@ export interface Logs { export interface Macro { /** * - * @type {UserLinks} + * @type {ResourceOwnersLinks} * @memberof Macro */ - links?: UserLinks; + links?: ResourceOwnersLinks; /** * * @type {string} @@ -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} + * @memberof ResourceOwners + */ + users?: Array; +} + +/** + * + * @export + * @interface ResourceOwnersLinks + */ +export interface ResourceOwnersLinks { + /** + * + * @type {string} + * @memberof ResourceOwnersLinks + */ + self?: string; +} + /** * * @export @@ -2550,10 +2612,10 @@ export interface SourceLinks { export interface Sources { /** * - * @type {UserLinks} + * @type {ResourceOwnersLinks} * @memberof Sources */ - links?: UserLinks; + links?: ResourceOwnersLinks; /** * * @type {Array} @@ -4590,10 +4652,10 @@ export interface User { status?: User.StatusEnum; /** * - * @type {UserLinks} + * @type {ResourceOwnersLinks} * @memberof User */ - links?: UserLinks; + links?: ResourceOwnersLinks; } /** @@ -4611,20 +4673,6 @@ export namespace User { } } -/** - * - * @export - * @interface UserLinks - */ -export interface UserLinks { - /** - * - * @type {string} - * @memberof UserLinks - */ - self?: string; -} - /** * * @export @@ -4633,10 +4681,10 @@ export interface UserLinks { export interface Users { /** * - * @type {UserLinks} + * @type {ResourceOwnersLinks} * @memberof Users */ - links?: UserLinks; + links?: ResourceOwnersLinks; /** * * @type {Array} @@ -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 { + orgsOrgIDMembersGet(orgID: string, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { 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}) @@ -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 { + orgsOrgIDMembersGet(orgID: string, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise { 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}) diff --git a/ui/src/organizations/apis/index.ts b/ui/src/organizations/apis/index.ts index 23733fb0a94..a98b4b34071 100644 --- a/ui/src/organizations/apis/index.ts +++ b/ui/src/organizations/apis/index.ts @@ -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 @@ -44,7 +51,9 @@ export const updateOrg = async (org: Organization): Promise => { } // Members -export const getMembers = async (org: Organization): Promise => { +export const getMembers = async ( + org: Organization +): Promise => { try { const {data} = await orgsAPI.orgsOrgIDMembersGet(org.id) diff --git a/ui/src/organizations/components/MemberList.tsx b/ui/src/organizations/components/MemberList.tsx index 2f92a27a80a..a6c3f8f46d0 100644 --- a/ui/src/organizations/components/MemberList.tsx +++ b/ui/src/organizations/components/MemberList.tsx @@ -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 } @@ -17,10 +17,11 @@ export default class MemberList extends PureComponent { return ( - - + + + - + {this.rows} @@ -31,6 +32,7 @@ export default class MemberList extends PureComponent { return this.props.members.map(member => ( {member.name} + {member.role} DELETE )) diff --git a/ui/src/organizations/components/Members.tsx b/ui/src/organizations/components/Members.tsx index de611a5cd53..e5ad5df8337 100644 --- a/ui/src/organizations/components/Members.tsx +++ b/ui/src/organizations/components/Members.tsx @@ -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 { @@ -29,7 +29,7 @@ export default class Members extends PureComponent { const {searchTerm} = this.state return ( - + list={members} searchKeys={['name']} searchTerm={searchTerm} diff --git a/ui/src/organizations/containers/OrganizationView.tsx b/ui/src/organizations/containers/OrganizationView.tsx index c20e34efe1d..d97e57ce6e8 100644 --- a/ui/src/organizations/containers/OrganizationView.tsx +++ b/ui/src/organizations/containers/OrganizationView.tsx @@ -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' @@ -71,7 +71,7 @@ class OrganizationView extends PureComponent { url="members_tab" title="Members" > - + organization={org} fetcher={getMembers} >