♻️(frontend) adapt frontend with new access types
We don't get the accesses anymore from the backeend, instead we get the number of accesses. We remove the list of owners in the doc header because we don't have easily this informations anymore and we will have to do a bigger refacto.
This commit is contained in:
@@ -65,9 +65,6 @@ test.describe('Doc Header', () => {
|
|||||||
await expect(
|
await expect(
|
||||||
card.getByText('Created at 09/01/2021, 11:00 AM'),
|
card.getByText('Created at 09/01/2021, 11:00 AM'),
|
||||||
).toBeVisible();
|
).toBeVisible();
|
||||||
await expect(
|
|
||||||
card.getByText('Owners: Super Owner / super2@owner.com'),
|
|
||||||
).toBeVisible();
|
|
||||||
await expect(card.getByText('Your role: Owner')).toBeVisible();
|
await expect(card.getByText('Your role: Owner')).toBeVisible();
|
||||||
await expect(page.getByRole('button', { name: 'Share' })).toBeVisible();
|
await expect(page.getByRole('button', { name: 'Share' })).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -4,12 +4,7 @@ import { css } from 'styled-components';
|
|||||||
|
|
||||||
import { Box, Card, StyledLink, Text } from '@/components';
|
import { Box, Card, StyledLink, Text } from '@/components';
|
||||||
import { useCunninghamTheme } from '@/cunningham';
|
import { useCunninghamTheme } from '@/cunningham';
|
||||||
import {
|
import { Doc, currentDocRole, useTrans } from '@/features/docs/doc-management';
|
||||||
Doc,
|
|
||||||
Role,
|
|
||||||
currentDocRole,
|
|
||||||
useTrans,
|
|
||||||
} from '@/features/docs/doc-management';
|
|
||||||
import { Versions } from '@/features/docs/doc-versioning';
|
import { Versions } from '@/features/docs/doc-versioning';
|
||||||
import { useDate } from '@/hook';
|
import { useDate } from '@/hook';
|
||||||
import { useResponsiveStore } from '@/stores';
|
import { useResponsiveStore } from '@/stores';
|
||||||
@@ -100,21 +95,6 @@ export const DocHeader = ({ doc, versionId }: DocHeaderProps) => {
|
|||||||
<Text $size="s" $display="inline">
|
<Text $size="s" $display="inline">
|
||||||
{t('Created at')} <strong>{formatDate(doc.created_at)}</strong>
|
{t('Created at')} <strong>{formatDate(doc.created_at)}</strong>
|
||||||
</Text>
|
</Text>
|
||||||
<Text $size="s" $display="inline" $elipsis $maxWidth="60vw">
|
|
||||||
{t('Owners:')}{' '}
|
|
||||||
<strong>
|
|
||||||
{doc.accesses
|
|
||||||
.filter(
|
|
||||||
(access) => access.role === Role.OWNER && access.user.email,
|
|
||||||
)
|
|
||||||
.map((access, index, accesses) => (
|
|
||||||
<Fragment key={`access-${index}`}>
|
|
||||||
{access.user.full_name || access.user.email}{' '}
|
|
||||||
{index < accesses.length - 1 ? ' / ' : ''}
|
|
||||||
</Fragment>
|
|
||||||
))}
|
|
||||||
</strong>
|
|
||||||
</Text>
|
|
||||||
</Box>
|
</Box>
|
||||||
<Text $size="s" $display="inline">
|
<Text $size="s" $display="inline">
|
||||||
{t('Your role:')}{' '}
|
{t('Your role:')}{' '}
|
||||||
|
|||||||
@@ -38,9 +38,11 @@ export interface Doc {
|
|||||||
id: string;
|
id: string;
|
||||||
title: string;
|
title: string;
|
||||||
content: Base64;
|
content: Base64;
|
||||||
|
creator: string;
|
||||||
|
is_favorite: boolean;
|
||||||
link_reach: LinkReach;
|
link_reach: LinkReach;
|
||||||
link_role: LinkRole;
|
link_role: LinkRole;
|
||||||
accesses: Access[];
|
nb_accesses: number;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
abilities: {
|
abilities: {
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ export const DocsGrid = () => {
|
|||||||
renderCell: ({ row }) => {
|
renderCell: ({ row }) => {
|
||||||
return (
|
return (
|
||||||
<StyledLink href={`/docs/${row.id}`}>
|
<StyledLink href={`/docs/${row.id}`}>
|
||||||
<Text $weight="bold">{row.accesses.length}</Text>
|
<Text $weight="bold">{row.nb_accesses}</Text>
|
||||||
</StyledLink>
|
</StyledLink>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import { WorkboxPlugin } from 'workbox-core';
|
import { WorkboxPlugin } from 'workbox-core';
|
||||||
|
|
||||||
import { Doc, DocsResponse } from '@/features/docs/doc-management';
|
import { Doc, DocsResponse } from '@/features/docs/doc-management';
|
||||||
import {
|
import { LinkReach, LinkRole } from '@/features/docs/doc-management/types';
|
||||||
LinkReach,
|
|
||||||
LinkRole,
|
|
||||||
Role,
|
|
||||||
} from '@/features/docs/doc-management/types';
|
|
||||||
|
|
||||||
import { DBRequest, DocsDB } from './DocsDB';
|
import { DBRequest, DocsDB } from './DocsDB';
|
||||||
import { RequestSerializer } from './RequestSerializer';
|
import { RequestSerializer } from './RequestSerializer';
|
||||||
@@ -192,6 +188,9 @@ export class ApiPlugin implements WorkboxPlugin {
|
|||||||
id: uuid,
|
id: uuid,
|
||||||
content: '',
|
content: '',
|
||||||
created_at: new Date().toISOString(),
|
created_at: new Date().toISOString(),
|
||||||
|
creator: 'dummy-id',
|
||||||
|
is_favorite: false,
|
||||||
|
nb_accesses: 1,
|
||||||
updated_at: new Date().toISOString(),
|
updated_at: new Date().toISOString(),
|
||||||
abilities: {
|
abilities: {
|
||||||
accesses_manage: true,
|
accesses_manage: true,
|
||||||
@@ -206,26 +205,6 @@ export class ApiPlugin implements WorkboxPlugin {
|
|||||||
versions_list: true,
|
versions_list: true,
|
||||||
versions_retrieve: true,
|
versions_retrieve: true,
|
||||||
},
|
},
|
||||||
accesses: [
|
|
||||||
{
|
|
||||||
id: 'dummy-id',
|
|
||||||
role: Role.OWNER,
|
|
||||||
team: '',
|
|
||||||
user: {
|
|
||||||
id: 'dummy-id',
|
|
||||||
email: 'dummy-email',
|
|
||||||
full_name: 'dummy-full-name',
|
|
||||||
short_name: 'dummy-short-name',
|
|
||||||
},
|
|
||||||
abilities: {
|
|
||||||
destroy: false,
|
|
||||||
partial_update: false,
|
|
||||||
retrieve: true,
|
|
||||||
set_role_to: [],
|
|
||||||
update: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
link_reach: LinkReach.RESTRICTED,
|
link_reach: LinkReach.RESTRICTED,
|
||||||
link_role: LinkRole.READER,
|
link_role: LinkRole.READER,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user