Skip to content

Commit

Permalink
Fix: show sdk table title column (#362)
Browse files Browse the repository at this point in the history
* chore: update sdk version

* fix: show team and project title in the table

* chore: add check for permissions in project team invite

* chore: update apsara version

* chore: bump sdk version
  • Loading branch information
rsbh authored Sep 25, 2023
1 parent 8837fb3 commit c655b86
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 196 deletions.
5 changes: 5 additions & 0 deletions sdks/js/.changeset/calm-zebras-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@raystack/frontier': patch
---

Fix table title column
22 changes: 21 additions & 1 deletion sdks/js/packages/core/client/V1Beta1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ import {
V1Beta1ListPoliciesResponse,
V1Beta1ListPreferencesResponse,
V1Beta1ListProjectAdminsResponse,
V1Beta1ListProjectGroupsResponse,
V1Beta1ListProjectPreferencesResponse,
V1Beta1ListProjectResourcesResponse,
V1Beta1ListProjectServiceUsersResponse,
Expand Down Expand Up @@ -1588,6 +1589,7 @@ export class V1Beta1<SecurityDataType = unknown> extends HttpClient<SecurityData
orgId: string,
query?: {
state?: string;
scopes?: string[];
},
params: RequestParams = {}
) =>
Expand Down Expand Up @@ -2041,6 +2043,23 @@ export class V1Beta1<SecurityDataType = unknown> extends HttpClient<SecurityData
format: 'json',
...params
});
/**
* @description Returns a collection of groups of a project.
*
* @tags Project
* @name FrontierServiceListProjectGroups
* @summary List project groups
* @request GET:/v1beta1/projects/{id}/groups
* @secure
*/
frontierServiceListProjectGroups = (id: string, params: RequestParams = {}) =>
this.request<V1Beta1ListProjectGroupsResponse, RpcStatus>({
path: `/v1beta1/projects/${id}/groups`,
method: 'GET',
secure: true,
format: 'json',
...params
});
/**
* @description List a project preferences by ID.
*
Expand Down Expand Up @@ -2083,7 +2102,7 @@ export class V1Beta1<SecurityDataType = unknown> extends HttpClient<SecurityData
...params
});
/**
* @description Returns a collection of users of a project. Filter by user permissions is supported.
* @description Returns a collection of users of a project.
*
* @tags Project
* @name FrontierServiceListProjectServiceUsers
Expand Down Expand Up @@ -2304,6 +2323,7 @@ export class V1Beta1<SecurityDataType = unknown> extends HttpClient<SecurityData
frontierServiceListRoles = (
query?: {
state?: string;
scopes?: string[];
},
params: RequestParams = {}
) =>
Expand Down
7 changes: 7 additions & 0 deletions sdks/js/packages/core/client/data-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ export interface V1Beta1ListCurrentUserGroupsResponseAccessPair {

export interface V1Beta1ListCurrentUserInvitationsResponse {
invitations?: V1Beta1Invitation[];
orgs?: V1Beta1Organization[];
}

export interface V1Beta1ListCurrentUserPreferencesResponse {
Expand Down Expand Up @@ -663,6 +664,10 @@ export interface V1Beta1ListProjectAdminsResponse {
users?: V1Beta1User[];
}

export interface V1Beta1ListProjectGroupsResponse {
groups?: V1Beta1Group[];
}

export interface V1Beta1ListProjectPreferencesResponse {
preferences?: V1Beta1Preference[];
}
Expand Down Expand Up @@ -1098,13 +1103,15 @@ export interface V1Beta1Role {
updatedAt?: string;
orgId?: string;
state?: string;
scopes?: string[];
}

export interface V1Beta1RoleRequestBody {
name?: string;
permissions?: string[];
metadata?: object;
title?: string;
scopes?: string[];
}

export interface V1Beta1SecretCredential {
Expand Down
2 changes: 1 addition & 1 deletion sdks/js/packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
},
"dependencies": {
"@hookform/resolvers": "^3.3.1",
"@raystack/apsara": "0.11.1",
"@raystack/apsara": "0.11.2",
"@tanstack/react-router": "0.0.1-beta.174",
"axios": "^1.5.0",
"class-variance-authority": "^0.7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { Button, DataTable, EmptyState, Flex } from '@raystack/apsara';
import { useNavigate, useParams } from '@tanstack/react-router';
import { V1Beta1User } from '~/src';
import { columns } from './member.columns';
import { PERMISSIONS, shouldShowComponent } from '~/utils';
import { usePermissions } from '~/react/hooks/usePermissions';
import { useMemo } from 'react';

export type MembersProps = {
members?: V1Beta1User[];
Expand All @@ -11,6 +14,25 @@ export const Members = ({ members }: MembersProps) => {
const navigate = useNavigate({ from: '/projects/$projectId' });
const { projectId } = useParams({ from: '/projects/$projectId' });

const resource = `app/project:${projectId}`;
const listOfPermissionsToCheck = [
{
permission: PERMISSIONS.UpdatePermission,
resource
}
];

const { permissions } = usePermissions(listOfPermissionsToCheck, !!projectId);

const { canUpdateProject } = useMemo(() => {
return {
canUpdateProject: shouldShowComponent(
permissions,
`${PERMISSIONS.UpdatePermission}::${resource}`
)
};
}, [permissions, resource]);

const tableStyle = members?.length
? { width: '100%' }
: { width: '100%', height: '100%' };
Expand All @@ -33,18 +55,20 @@ export const Members = ({ members }: MembersProps) => {
size="medium"
/>
</Flex>
<Button
variant="primary"
style={{ width: 'fit-content' }}
onClick={() =>
navigate({
to: '/projects/$projectId/invite',
params: { projectId: projectId }
})
}
>
Add Team
</Button>
{canUpdateProject ? (
<Button
variant="primary"
style={{ width: 'fit-content' }}
onClick={() =>
navigate({
to: '/projects/$projectId/invite',
params: { projectId: projectId }
})
}
>
Add Team
</Button>
) : null}
</Flex>
</DataTable.Toolbar>
</DataTable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const getColumns: (
isLoading?: boolean
) => ColumnDef<V1Beta1Project, any>[] = (userAccessOnProject, isLoading) => [
{
accessorKey: 'name',
header: 'Title',
accessorKey: 'title',
cell: isLoading
? () => <Skeleton />
: ({ row, getValue }) => {
Expand All @@ -37,12 +38,14 @@ export const getColumns: (
}
},
{
header: 'Privacy',
accessorKey: 'privacy',
cell: isLoading
? () => <Skeleton />
: info => <Text>{info.getValue() ?? 'Public'}</Text>
},
{
header: 'Members',
accessorKey: 'members',
cell: isLoading
? () => <Skeleton />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const getColumns: (
) => ColumnDef<V1Beta1Group, any>[] = (userAccessOnTeam, isLoading) => [
{
header: 'Title',
accessorKey: 'name',
accessorKey: 'title',
cell: isLoading
? () => <Skeleton />
: ({ row, getValue }) => (
Expand Down
Loading

0 comments on commit c655b86

Please sign in to comment.