Skip to content

Commit

Permalink
cs pass
Browse files Browse the repository at this point in the history
  • Loading branch information
4rthem committed Oct 22, 2024
1 parent 1fb05e6 commit 10e4327
Show file tree
Hide file tree
Showing 46 changed files with 575 additions and 474 deletions.
3 changes: 1 addition & 2 deletions databox/api/src/Api/Model/Output/ShareAlternateUrlOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public function __construct(
private string $name,
private string $url,
private ?string $type,
)
{
) {
}

#[Groups([Share::GROUP_READ])]
Expand Down
8 changes: 4 additions & 4 deletions databox/api/src/Api/Provider/ShareReadProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public function provideShare(Share $item): Share
$item->alternateUrls[] = new ShareAlternateUrlOutput(
$definition->getName(),
$this->urlGenerator->generate('share_public_rendition', [
'id' => $item->getId(),
'rendition' => $definition->getId(),
'token' => $item->getToken(),
], UrlGeneratorInterface::ABS_URL),
'id' => $item->getId(),
'rendition' => $definition->getId(),
'token' => $item->getToken(),
], UrlGeneratorInterface::ABS_URL),
$rendition->getFile()->getType(),
);
}
Expand Down
1 change: 0 additions & 1 deletion databox/api/src/Api/Provider/ShareRenditionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
'createdAt' => 'DESC',
]);


if (null !== $file = $rendition?->getFile()) {
return new RedirectResponse($this->fileUrlResolver->resolveUrl($file));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField;
use EasyCorp\Bundle\EasyAdminBundle\Field\CollectionField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use EasyCorp\Bundle\EasyAdminBundle\Filter\DateTimeFilter;
Expand Down
10 changes: 5 additions & 5 deletions databox/api/tests/Search/CollectionSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ private static function releaseIndex(): void
self::forceNewEntitiesToBeIndexed();
self::waitForESIndex('collection');
}

public function testSearchRootWithCollectionsInNonPublicWorkspaceAsAnonymousUser(): void
{
$A = $this->createCollection([
Expand All @@ -23,7 +24,7 @@ public function testSearchRootWithCollectionsInNonPublicWorkspaceAsAnonymousUser
$this->createCollection([
'title' => 'B',
'parent' => $A,
'public'=> true,
'public' => true,
]);
self::releaseIndex();

Expand Down Expand Up @@ -77,7 +78,7 @@ public function testSearchRootWithOnePublicSubCollectionInPublicWorkspaceAsAnony
$this->createCollection([
'title' => 'B',
'parent' => $A,
'public'=> true,
'public' => true,
'workspace' => $workspace,
]);
self::releaseIndex();
Expand All @@ -93,7 +94,6 @@ public function testSearchRootWithOnePublicSubCollectionInPublicWorkspaceAsAnony
$this->assertSame('B', $data[0]['title']);
}


public function testSearchRootWithTwoPublicSubCollectionsInPublicWorkspaceAsAnonymousUser(): void
{
$workspace = $this->createWorkspace([
Expand All @@ -102,13 +102,13 @@ public function testSearchRootWithTwoPublicSubCollectionsInPublicWorkspaceAsAnon
]);
$A = $this->createCollection([
'title' => 'A',
'public'=> true,
'public' => true,
'workspace' => $workspace,
]);
$this->createCollection([
'title' => 'B',
'parent' => $A,
'public'=> true,
'public' => true,
'workspace' => $workspace,
]);
self::releaseIndex();
Expand Down
6 changes: 4 additions & 2 deletions databox/client/src/api/workspace.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import apiClient from './api-client';
import {Workspace} from '../types';
import {ApiCollectionResponse, getHydraCollection} from "./hydra.ts";
import {ApiCollectionResponse, getHydraCollection} from './hydra.ts';

export async function getWorkspace(id: string): Promise<Workspace> {
const res = await apiClient.get(`/workspaces/${id}`);

return res.data;
}

export async function getWorkspaces(): Promise<ApiCollectionResponse<Workspace>> {
export async function getWorkspaces(): Promise<
ApiCollectionResponse<Workspace>
> {
const res = await apiClient.get('/workspaces');

return getHydraCollection(res.data);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {AttributeEntity, Workspace} from '../../types.ts';
import {useTranslation} from 'react-i18next';
import {AppDialog} from '@alchemy/phrasea-ui';
import {
StackedModalProps,
useFormPrompt,
useModals,
} from '@alchemy/navigation';
import {StackedModalProps, useFormPrompt, useModals} from '@alchemy/navigation';
import {Button, TextField} from '@mui/material';
import {LoadingButton} from '@mui/lab';
import {
Expand Down
2 changes: 1 addition & 1 deletion databox/client/src/components/Basket/BasketsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {useContextMenu} from '../../hooks/useContextMenu.ts';
import ContextMenu from '../Ui/ContextMenu.tsx';
import DeleteIcon from '@mui/icons-material/Delete';
import EditIcon from '@mui/icons-material/Edit';
import useEffectOnce from "@alchemy/react-hooks/src/useEffectOnce";
import useEffectOnce from '@alchemy/react-hooks/src/useEffectOnce';

type Props = {
selected?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export default function OperationsAsset({
<Trans
i18nKey={'asset_collections.reference_collection'}
values={{
collection: data.referenceCollection.absoluteTitle,
collection:
data.referenceCollection.absoluteTitle,
workspace: data.workspace.name,
}}
components={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import EventIcon from '@mui/icons-material/Event';
import InfoRow from '../Info/InfoRow';
import PersonIcon from '@mui/icons-material/Person';
import {useTranslation} from 'react-i18next';
import FolderIcon from "@mui/icons-material/Folder";
import BusinessIcon from "@mui/icons-material/Business";
import FolderIcon from '@mui/icons-material/Folder';
import BusinessIcon from '@mui/icons-material/Business';

type Props = {
id: string;
Expand Down Expand Up @@ -55,9 +55,7 @@ export default function InfoCollection({data, onClose, minHeight}: Props) {
<InfoRow
icon={<FolderIcon />}
label={t('collection.info.absolute_path', `Absolute Path`)}
value={
data.absoluteTitle
}
value={data.absoluteTitle}
/>
</MenuList>
</ContentTab>
Expand Down
4 changes: 1 addition & 3 deletions databox/client/src/components/Dialog/Tabbed/FormTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import {LoadingButton} from '@mui/lab';
import SaveIcon from '@mui/icons-material/Save';
import RemoteErrors from '../../Form/RemoteErrors';
import {useTranslation} from 'react-i18next';
import {
useFormPrompt,
} from '@alchemy/navigation';
import {useFormPrompt} from '@alchemy/navigation';

type Props = PropsWithChildren<{
loading: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from '../Media/Collection/CollectionTree/CollectionsTreeView.tsx';
import {FormControl, FormLabel} from '@mui/material';
import {RegisterOptions} from 'react-hook-form';
import {IsSelectable} from "../Media/Collection/CollectionTree/collectionTree.ts";
import {IsSelectable} from '../Media/Collection/CollectionTree/collectionTree.ts';

type Props<TFieldValues extends FieldValues, IsMulti extends boolean> = {
label?: ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import RemoteErrors from '../../../Form/RemoteErrors';
import {FormFieldErrors, FormRow} from '@alchemy/react-form';
import {useTranslation} from 'react-i18next';
import {useFormSubmit} from '@alchemy/api';
import {
StackedModalProps,
useModals,
useFormPrompt,
} from '@alchemy/navigation';
import {StackedModalProps, useModals, useFormPrompt} from '@alchemy/navigation';
import {Basket, IntegrationData} from '../../../../types.ts';
import {runIntegrationAction} from '../../../../api/integrations.ts';
import {SwitchWidget} from '@alchemy/react-form';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,22 @@ type Props = {
export default function AssetViewActions({asset, file}: Props) {
const {t} = useTranslation();
const closeModal = useCloseModal();
const {onDelete, onDownload, onEdit, onEditAttr, onShare, onSubstituteFile, can} =
useAssetActions({asset, onDelete: closeModal});
const {
onDelete,
onDownload,
onEdit,
onEditAttr,
onShare,
onSubstituteFile,
can,
} = useAssetActions({asset, onDelete: closeModal});

return (
<>
<Box
sx={{
zIndex: 1,
position:'relative',
'zIndex': 1,
'position': 'relative',
'display': 'inline-block',
'ml': 2,
'> * + *': {
Expand Down Expand Up @@ -91,9 +98,11 @@ export default function AssetViewActions({asset, file}: Props) {
''
)}
{can.share ? (
<Button variant={'contained'}
onClick={() => onShare()}
startIcon={<ShareIcon />}>
<Button
variant={'contained'}
onClick={() => onShare()}
startIcon={<ShareIcon />}
>
{t('asset_actions.share', 'Share')}
</Button>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ import RenditionDefinitionSelect from '../../../Form/RenditionDefinitionSelect';
import {useTranslation} from 'react-i18next';
import {postRendition} from '../../../../api/rendition';
import {useFormSubmit} from '@alchemy/api';
import {
useModals,
StackedModalProps,
useFormPrompt,
} from '@alchemy/navigation';
import {useModals, StackedModalProps, useFormPrompt} from '@alchemy/navigation';

type FormData = {
definition: string | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import {useState} from 'react';
import {Collection} from '../../../types';
import {useTranslation} from 'react-i18next';
import {Typography} from '@mui/material';
import {
CollectionsTreeView,
} from './CollectionTree/CollectionsTreeView.tsx';
import {CollectionsTreeView} from './CollectionTree/CollectionsTreeView.tsx';
import {clearWorkspaceCache, moveCollection} from '../../../api/collection';
import {toast} from 'react-toastify';
import {LoadingButton} from '@mui/lab';
import DriveFileMoveIcon from '@mui/icons-material/DriveFileMove';
import {treeViewPathSeparator} from "./CollectionTree/collectionTree.ts";
import {treeViewPathSeparator} from './CollectionTree/collectionTree.ts';

type Props = {
collection: Collection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import React, {useCallback} from "react";
import {CollectionPager, useCollectionStore} from "../../../../store/collectionStore.ts";
import EditableCollectionTree, {defaultNewCollectionName} from "../EditableTree.tsx";
import {TreeItem} from "@mui/x-tree-view";
import {IconButton, Stack} from "@mui/material";
import CreateNewFolderIcon from "@mui/icons-material/CreateNewFolder";
import {CollectionOptionalWorkspace} from "../../../../types.ts";
import {CommonTreeItemProps, treeViewPathSeparator} from "./collectionTree.ts";
import TreeItemLoader from "./TreeItemLoader.tsx";
import React, {useCallback} from 'react';
import {
CollectionPager,
useCollectionStore,
} from '../../../../store/collectionStore.ts';
import EditableCollectionTree, {
defaultNewCollectionName,
} from '../EditableTree.tsx';
import {TreeItem} from '@mui/x-tree-view';
import {IconButton, Stack} from '@mui/material';
import CreateNewFolderIcon from '@mui/icons-material/CreateNewFolder';
import {CollectionOptionalWorkspace} from '../../../../types.ts';
import {CommonTreeItemProps, treeViewPathSeparator} from './collectionTree.ts';
import TreeItemLoader from './TreeItemLoader.tsx';

type Props<IsMulti extends boolean = false> = {
collection: CollectionOptionalWorkspace;
Expand Down Expand Up @@ -91,16 +96,18 @@ export function CollectionTreeItem<IsMulti extends boolean = false>({
sx={{ml: 1}}
onClick={onCreateNewCollection}
>
<CreateNewFolderIcon/>
<CreateNewFolderIcon />
</IconButton>
)}
</Stack>
}
>
{/*Wrapping all to avoid collapse in node */}
{pager.expanding || hasTree || (allowNew && hasNewCollectionPath) ? (
{pager.expanding ||
hasTree ||
(allowNew && hasNewCollectionPath) ? (
<>
{pager.expanding ? <TreeItemLoader/> : null}
{pager.expanding ? <TreeItemLoader /> : null}
{allowNew && hasNewCollectionPath ? (
<EditableCollectionTree
nodes={newCollectionPath!.nodes}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import React, {useCallback, useState} from 'react';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
import {TreeView} from '@mui/x-tree-view';
import {CircularProgress,} from '@mui/material';
import {CircularProgress} from '@mui/material';
import useEffectOnce from '@alchemy/react-hooks/src/useEffectOnce';
import {useWorkspaceStore} from "../../../../store/workspaceStore.ts";
import {useWorkspaceStore} from '../../../../store/workspaceStore.ts';
import {
Collection,
CommonTreeProps,
NewCollectionPathState,
normalizeNodeId,
SetNewCollectionPath,
treeViewPathSeparator,
UpdateCollectionPath
} from "./collectionTree.ts";
import WorkspaceTreeItem from "./WorkspaceTreeItem.tsx";
UpdateCollectionPath,
} from './collectionTree.ts';
import WorkspaceTreeItem from './WorkspaceTreeItem.tsx';

type Props<IsMulti extends boolean = false> = {
value?: IsMulti extends true ? Collection[] : Collection;
Expand All @@ -40,7 +40,9 @@ export function CollectionsTreeView<IsMulti extends boolean = false>({
const loadWorkspaces = useWorkspaceStore(state => state.load);
const loading = useWorkspaceStore(state => state.loading);
const allWorkspaces = useWorkspaceStore(state => state.workspaces);
const workspaces = workspaceId ? allWorkspaces.filter(w => w.id === workspaceId) : allWorkspaces;
const workspaces = workspaceId
? allWorkspaces.filter(w => w.id === workspaceId)
: allWorkspaces;

useEffectOnce(() => {
loadWorkspaces();
Expand Down Expand Up @@ -115,14 +117,14 @@ export function CollectionsTreeView<IsMulti extends boolean = false>({
id === null
? prev!.nodes.slice(0, index)
: prev!.nodes.map((p, i) =>
i === index
? {
id: id!,
value: value!,
editing: editing!,
}
: p
),
i === index
? {
id: id!,
value: value!,
editing: editing!,
}
: p
),
};
});
},
Expand All @@ -134,7 +136,7 @@ export function CollectionsTreeView<IsMulti extends boolean = false>({
};

if (loading) {
return <CircularProgress size={50}/>;
return <CircularProgress size={50} />;
}

return (
Expand All @@ -155,8 +157,8 @@ export function CollectionsTreeView<IsMulti extends boolean = false>({
color: 'inherit',
},
})}
defaultCollapseIcon={<ExpandMoreIcon/>}
defaultExpandIcon={<ChevronRightIcon/>}
defaultCollapseIcon={<ExpandMoreIcon />}
defaultExpandIcon={<ChevronRightIcon />}
expanded={expanded}
selected={selected as any}
onNodeToggle={handleToggle}
Expand Down
Loading

0 comments on commit 10e4327

Please sign in to comment.