mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
Merge branch 'main' into task/constraint_card_adjustmnets
This commit is contained in:
commit
e59d516aae
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "unleash-frontend",
|
"name": "unleash-frontend",
|
||||||
"description": "unleash your features",
|
"description": "unleash your features",
|
||||||
"version": "4.14.0-beta.5",
|
"version": "4.14.0-beta.6",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"unleash",
|
"unleash",
|
||||||
"feature toggle",
|
"feature toggle",
|
||||||
|
@ -27,6 +27,7 @@ import { useUsers } from 'hooks/api/getters/useUsers/useUsers';
|
|||||||
import { useGroups } from 'hooks/api/getters/useGroups/useGroups';
|
import { useGroups } from 'hooks/api/getters/useGroups/useGroups';
|
||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
import { ProjectRoleDescription } from './ProjectRoleDescription/ProjectRoleDescription';
|
import { ProjectRoleDescription } from './ProjectRoleDescription/ProjectRoleDescription';
|
||||||
|
import { useAccess } from '../../../../hooks/api/getters/useAccess/useAccess';
|
||||||
|
|
||||||
const StyledForm = styled('form')(() => ({
|
const StyledForm = styled('form')(() => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -109,8 +110,7 @@ export const ProjectAccessAssign = ({
|
|||||||
const { refetchProjectAccess } = useProjectAccess(projectId);
|
const { refetchProjectAccess } = useProjectAccess(projectId);
|
||||||
const { addAccessToProject, changeUserRole, changeGroupRole, loading } =
|
const { addAccessToProject, changeUserRole, changeGroupRole, loading } =
|
||||||
useProjectApi();
|
useProjectApi();
|
||||||
const { users = [] } = useUsers();
|
const { users, groups } = useAccess();
|
||||||
const { groups = [] } = useGroups();
|
|
||||||
const edit = Boolean(selected);
|
const edit = Boolean(selected);
|
||||||
|
|
||||||
const { setToastData, setToastApiError } = useToast();
|
const { setToastData, setToastApiError } = useToast();
|
||||||
@ -148,7 +148,7 @@ export const ProjectAccessAssign = ({
|
|||||||
group.id === id && type === ENTITY_TYPE.GROUP
|
group.id === id && type === ENTITY_TYPE.GROUP
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.map(group => ({
|
.map((group: IGroup) => ({
|
||||||
id: group.id,
|
id: group.id,
|
||||||
entity: group,
|
entity: group,
|
||||||
type: ENTITY_TYPE.GROUP,
|
type: ENTITY_TYPE.GROUP,
|
||||||
@ -249,7 +249,7 @@ export const ProjectAccessAssign = ({
|
|||||||
show={
|
show={
|
||||||
<StyledGroupOption>
|
<StyledGroupOption>
|
||||||
<span>{optionGroup?.name}</span>
|
<span>{optionGroup?.name}</span>
|
||||||
<span>{optionGroup?.users.length} users</span>
|
<span>{optionGroup?.userCount} users</span>
|
||||||
</StyledGroupOption>
|
</StyledGroupOption>
|
||||||
}
|
}
|
||||||
elseShow={
|
elseShow={
|
||||||
|
28
frontend/src/hooks/api/getters/useAccess/useAccess.ts
Normal file
28
frontend/src/hooks/api/getters/useAccess/useAccess.ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import useSWR from 'swr';
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
import { formatApiPath } from 'utils/formatPath';
|
||||||
|
import handleErrorResponses from '../httpErrorResponseHandler';
|
||||||
|
|
||||||
|
export const useAccess = () => {
|
||||||
|
const { data, error, mutate } = useSWR(
|
||||||
|
formatApiPath(`api/admin/user-admin/access`),
|
||||||
|
fetcher
|
||||||
|
);
|
||||||
|
|
||||||
|
return useMemo(
|
||||||
|
() => ({
|
||||||
|
users: data?.users ?? [],
|
||||||
|
groups: data?.groups ?? [],
|
||||||
|
loading: !error && !data,
|
||||||
|
refetch: () => mutate(),
|
||||||
|
error,
|
||||||
|
}),
|
||||||
|
[data, error, mutate]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetcher = (path: string) => {
|
||||||
|
return fetch(path)
|
||||||
|
.then(handleErrorResponses('Access'))
|
||||||
|
.then(res => res.json());
|
||||||
|
};
|
@ -13,6 +13,7 @@ export interface IGroup {
|
|||||||
users: IGroupUser[];
|
users: IGroupUser[];
|
||||||
projects: string[];
|
projects: string[];
|
||||||
addedAt?: string;
|
addedAt?: string;
|
||||||
|
userCount?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IGroupUser extends IUser {
|
export interface IGroupUser extends IUser {
|
||||||
|
Loading…
Reference in New Issue
Block a user