1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

Feat/grouping fixes (#1146)

* Grouping fix grid not showing user names

* Remove deprecated access endpoints

* Manual prettier

* Revert user role update
This commit is contained in:
sjaanus 2022-07-25 10:14:02 +00:00 committed by GitHub
parent d9822bead0
commit e95825a000
5 changed files with 19 additions and 40 deletions

1
frontend/.gitignore vendored
View File

@ -49,6 +49,7 @@ build
.DS_Store .DS_Store
cypress/downloads/*
cypress/videos/* cypress/videos/*
cypress/downloads/* cypress/downloads/*
cypress/screenshots/* cypress/screenshots/*

View File

@ -1,4 +1,4 @@
import { FormEvent, useEffect, useMemo, useState } from 'react'; import React, { FormEvent, useEffect, useMemo, useState } from 'react';
import { import {
Autocomplete, Autocomplete,
Button, Button,

View File

@ -32,6 +32,7 @@ import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import { IUser } from 'interfaces/user'; import { IUser } from 'interfaces/user';
import { IGroup } from 'interfaces/group'; import { IGroup } from 'interfaces/group';
import { LinkCell } from 'component/common/Table/cells/LinkCell/LinkCell'; import { LinkCell } from 'component/common/Table/cells/LinkCell/LinkCell';
import { mapGroupUsers } from '../../../../hooks/api/getters/useGroup/useGroup';
const StyledAvatar = styled(Avatar)(({ theme }) => ({ const StyledAvatar = styled(Avatar)(({ theme }) => ({
width: theme.spacing(4), width: theme.spacing(4),
@ -339,7 +340,6 @@ export const ProjectAccessTable: VFC = () => {
setRemoveOpen(false); setRemoveOpen(false);
setSelectedRow(undefined); setSelectedRow(undefined);
}; };
return ( return (
<PageContent <PageContent
header={ header={

View File

@ -112,23 +112,6 @@ const useProjectApi = () => {
} }
}; };
const addUserToRole = async (
projectId: string,
roleId: number,
userId: number
) => {
const path = `api/admin/projects/${projectId}/users/${userId}/roles/${roleId}`;
const req = createRequest(path, { method: 'POST' });
try {
const res = await makeRequest(req.caller, req.id);
return res;
} catch (e) {
throw e;
}
};
const addAccessToProject = async ( const addAccessToProject = async (
projectId: string, projectId: string,
roleId: number, roleId: number,
@ -226,7 +209,6 @@ const useProjectApi = () => {
deleteProject, deleteProject,
addEnvironmentToProject, addEnvironmentToProject,
removeEnvironmentFromProject, removeEnvironmentFromProject,
addUserToRole,
addAccessToProject, addAccessToProject,
removeUserFromRole, removeUserFromRole,
removeGroupFromRole, removeGroupFromRole,

View File

@ -1,10 +1,12 @@
import useSWR, { mutate, SWRConfiguration } from 'swr'; import useSWR, { mutate, SWRConfiguration } from 'swr';
import { useState, useEffect } from 'react'; import { useState, useEffect, useMemo } from 'react';
import { formatApiPath } from 'utils/formatPath'; import { formatApiPath } from 'utils/formatPath';
import handleErrorResponses from '../httpErrorResponseHandler'; import handleErrorResponses from '../httpErrorResponseHandler';
import { IProjectRole } from 'interfaces/role'; import { IProjectRole } from 'interfaces/role';
import { IGroup } from 'interfaces/group'; import { IGroup } from 'interfaces/group';
import { IUser } from 'interfaces/user'; import { IUser } from 'interfaces/user';
import { useGroups } from '../useGroups/useGroups';
import { mapGroupUsers } from '../useGroup/useGroup';
export enum ENTITY_TYPE { export enum ENTITY_TYPE {
USER = 'USERS', USER = 'USERS',
@ -45,11 +47,7 @@ const useProjectAccess = (
const CACHE_KEY = `api/admin/projects/${projectId}/users`; const CACHE_KEY = `api/admin/projects/${projectId}/users`;
const { data, error } = useSWR<IProjectAccessOutput>( const { data, error } = useSWR(CACHE_KEY, fetcher, options);
CACHE_KEY,
fetcher,
options
);
const [loading, setLoading] = useState(!error && !data); const [loading, setLoading] = useState(!error && !data);
@ -61,21 +59,19 @@ const useProjectAccess = (
setLoading(!error && !data); setLoading(!error && !data);
}, [data, error]); }, [data, error]);
// TODO: Remove this and replace `mockData` back for `data` @79. This mocks what a group looks like when returned along with the access. let access: IProjectAccessOutput = data
// const { groups } = useGroups(); ? {
// const mockData = useMemo( roles: data.roles,
// () => ({ users: data.users,
// ...data, groups:
// groups: groups?.map(group => ({ data?.groups.map((group: any) => ({
// ...group, ...group,
// roleId: 4, users: mapGroupUsers(group.users ?? []),
// })) as IProjectAccessGroup[], })) ?? [],
// }), }
// [data, groups] : { roles: [], users: [], groups: [] };
// );
return { return {
access: data ? data : { roles: [], users: [], groups: [] }, access: access,
error, error,
loading, loading,
refetchProjectAccess, refetchProjectAccess,