diff --git a/databox/api/src/Api/Model/Output/ShareAlternateUrlOutput.php b/databox/api/src/Api/Model/Output/ShareAlternateUrlOutput.php index ed131834c..1cdb0fc5e 100644 --- a/databox/api/src/Api/Model/Output/ShareAlternateUrlOutput.php +++ b/databox/api/src/Api/Model/Output/ShareAlternateUrlOutput.php @@ -11,8 +11,7 @@ public function __construct( private string $name, private string $url, private ?string $type, - ) - { + ) { } #[Groups([Share::GROUP_READ])] diff --git a/databox/api/src/Api/Provider/ShareReadProvider.php b/databox/api/src/Api/Provider/ShareReadProvider.php index 78d1ace22..76949645b 100644 --- a/databox/api/src/Api/Provider/ShareReadProvider.php +++ b/databox/api/src/Api/Provider/ShareReadProvider.php @@ -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(), ); } diff --git a/databox/api/src/Api/Provider/ShareRenditionProvider.php b/databox/api/src/Api/Provider/ShareRenditionProvider.php index ee2401bad..f56c1447d 100644 --- a/databox/api/src/Api/Provider/ShareRenditionProvider.php +++ b/databox/api/src/Api/Provider/ShareRenditionProvider.php @@ -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)); } diff --git a/databox/api/src/Controller/Admin/AssetDataTemplateCrudController.php b/databox/api/src/Controller/Admin/AssetDataTemplateCrudController.php index 426faeb7b..b89aa1d4a 100644 --- a/databox/api/src/Controller/Admin/AssetDataTemplateCrudController.php +++ b/databox/api/src/Controller/Admin/AssetDataTemplateCrudController.php @@ -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; diff --git a/databox/api/tests/Search/CollectionSearchTest.php b/databox/api/tests/Search/CollectionSearchTest.php index b06665936..c5831267e 100644 --- a/databox/api/tests/Search/CollectionSearchTest.php +++ b/databox/api/tests/Search/CollectionSearchTest.php @@ -15,6 +15,7 @@ private static function releaseIndex(): void self::forceNewEntitiesToBeIndexed(); self::waitForESIndex('collection'); } + public function testSearchRootWithCollectionsInNonPublicWorkspaceAsAnonymousUser(): void { $A = $this->createCollection([ @@ -23,7 +24,7 @@ public function testSearchRootWithCollectionsInNonPublicWorkspaceAsAnonymousUser $this->createCollection([ 'title' => 'B', 'parent' => $A, - 'public'=> true, + 'public' => true, ]); self::releaseIndex(); @@ -77,7 +78,7 @@ public function testSearchRootWithOnePublicSubCollectionInPublicWorkspaceAsAnony $this->createCollection([ 'title' => 'B', 'parent' => $A, - 'public'=> true, + 'public' => true, 'workspace' => $workspace, ]); self::releaseIndex(); @@ -93,7 +94,6 @@ public function testSearchRootWithOnePublicSubCollectionInPublicWorkspaceAsAnony $this->assertSame('B', $data[0]['title']); } - public function testSearchRootWithTwoPublicSubCollectionsInPublicWorkspaceAsAnonymousUser(): void { $workspace = $this->createWorkspace([ @@ -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(); diff --git a/databox/client/src/api/workspace.ts b/databox/client/src/api/workspace.ts index 234d88352..0ddf47d41 100644 --- a/databox/client/src/api/workspace.ts +++ b/databox/client/src/api/workspace.ts @@ -1,6 +1,6 @@ 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 { const res = await apiClient.get(`/workspaces/${id}`); @@ -8,7 +8,9 @@ export async function getWorkspace(id: string): Promise { return res.data; } -export async function getWorkspaces(): Promise> { +export async function getWorkspaces(): Promise< + ApiCollectionResponse +> { const res = await apiClient.get('/workspaces'); return getHydraCollection(res.data); diff --git a/databox/client/src/components/AttributeEntity/CreateAttributeEntityDialog.tsx b/databox/client/src/components/AttributeEntity/CreateAttributeEntityDialog.tsx index 195bd1a81..083c3dbf7 100644 --- a/databox/client/src/components/AttributeEntity/CreateAttributeEntityDialog.tsx +++ b/databox/client/src/components/AttributeEntity/CreateAttributeEntityDialog.tsx @@ -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 { diff --git a/databox/client/src/components/Basket/BasketsPanel.tsx b/databox/client/src/components/Basket/BasketsPanel.tsx index 647b6b433..7f7b77c3a 100644 --- a/databox/client/src/components/Basket/BasketsPanel.tsx +++ b/databox/client/src/components/Basket/BasketsPanel.tsx @@ -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; diff --git a/databox/client/src/components/Dialog/Asset/OperationsAsset.tsx b/databox/client/src/components/Dialog/Asset/OperationsAsset.tsx index e22cb539a..573a561ad 100644 --- a/databox/client/src/components/Dialog/Asset/OperationsAsset.tsx +++ b/databox/client/src/components/Dialog/Asset/OperationsAsset.tsx @@ -64,7 +64,8 @@ export default function OperationsAsset({ } label={t('collection.info.absolute_path', `Absolute Path`)} - value={ - data.absoluteTitle - } + value={data.absoluteTitle} /> diff --git a/databox/client/src/components/Dialog/Tabbed/FormTab.tsx b/databox/client/src/components/Dialog/Tabbed/FormTab.tsx index 1f78244fe..1e37e9e27 100644 --- a/databox/client/src/components/Dialog/Tabbed/FormTab.tsx +++ b/databox/client/src/components/Dialog/Tabbed/FormTab.tsx @@ -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; diff --git a/databox/client/src/components/Form/CollectionTreeWidget.tsx b/databox/client/src/components/Form/CollectionTreeWidget.tsx index 7782b323a..7637c6d79 100644 --- a/databox/client/src/components/Form/CollectionTreeWidget.tsx +++ b/databox/client/src/components/Form/CollectionTreeWidget.tsx @@ -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 = { label?: ReactNode; diff --git a/databox/client/src/components/Integration/Phrasea/Expose/CreatePublicationDialog.tsx b/databox/client/src/components/Integration/Phrasea/Expose/CreatePublicationDialog.tsx index f2ed88b55..0ed989544 100644 --- a/databox/client/src/components/Integration/Phrasea/Expose/CreatePublicationDialog.tsx +++ b/databox/client/src/components/Integration/Phrasea/Expose/CreatePublicationDialog.tsx @@ -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'; diff --git a/databox/client/src/components/Media/Asset/Actions/AssetViewActions.tsx b/databox/client/src/components/Media/Asset/Actions/AssetViewActions.tsx index 877b150a6..6deb2b2a6 100644 --- a/databox/client/src/components/Media/Asset/Actions/AssetViewActions.tsx +++ b/databox/client/src/components/Media/Asset/Actions/AssetViewActions.tsx @@ -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 ( <> * + *': { @@ -91,9 +98,11 @@ export default function AssetViewActions({asset, file}: Props) { '' )} {can.share ? ( - ) : ( diff --git a/databox/client/src/components/Media/Asset/Actions/SaveFileAsRenditionDialog.tsx b/databox/client/src/components/Media/Asset/Actions/SaveFileAsRenditionDialog.tsx index 5da59569b..4086bf7ad 100644 --- a/databox/client/src/components/Media/Asset/Actions/SaveFileAsRenditionDialog.tsx +++ b/databox/client/src/components/Media/Asset/Actions/SaveFileAsRenditionDialog.tsx @@ -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; diff --git a/databox/client/src/components/Media/Collection/CollectionMoveSection.tsx b/databox/client/src/components/Media/Collection/CollectionMoveSection.tsx index 5dc26c289..fe9c4647c 100644 --- a/databox/client/src/components/Media/Collection/CollectionMoveSection.tsx +++ b/databox/client/src/components/Media/Collection/CollectionMoveSection.tsx @@ -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; diff --git a/databox/client/src/components/Media/Collection/CollectionTree/CollectionTreeItem.tsx b/databox/client/src/components/Media/Collection/CollectionTree/CollectionTreeItem.tsx index 3b0326cdb..08903416a 100644 --- a/databox/client/src/components/Media/Collection/CollectionTree/CollectionTreeItem.tsx +++ b/databox/client/src/components/Media/Collection/CollectionTree/CollectionTreeItem.tsx @@ -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 = { collection: CollectionOptionalWorkspace; @@ -91,16 +96,18 @@ export function CollectionTreeItem({ sx={{ml: 1}} onClick={onCreateNewCollection} > - + )} } > {/*Wrapping all to avoid collapse in node */} - {pager.expanding || hasTree || (allowNew && hasNewCollectionPath) ? ( + {pager.expanding || + hasTree || + (allowNew && hasNewCollectionPath) ? ( <> - {pager.expanding ? : null} + {pager.expanding ? : null} {allowNew && hasNewCollectionPath ? ( = { value?: IsMulti extends true ? Collection[] : Collection; @@ -40,7 +40,9 @@ export function CollectionsTreeView({ 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(); @@ -115,14 +117,14 @@ export function CollectionsTreeView({ 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 + ), }; }); }, @@ -134,7 +136,7 @@ export function CollectionsTreeView({ }; if (loading) { - return ; + return ; } return ( @@ -155,8 +157,8 @@ export function CollectionsTreeView({ color: 'inherit', }, })} - defaultCollapseIcon={} - defaultExpandIcon={} + defaultCollapseIcon={} + defaultExpandIcon={} expanded={expanded} selected={selected as any} onNodeToggle={handleToggle} diff --git a/databox/client/src/components/Media/Collection/CollectionTree/TreeItemLoader.tsx b/databox/client/src/components/Media/Collection/CollectionTree/TreeItemLoader.tsx index 621e76de9..9cc2c64dd 100644 --- a/databox/client/src/components/Media/Collection/CollectionTree/TreeItemLoader.tsx +++ b/databox/client/src/components/Media/Collection/CollectionTree/TreeItemLoader.tsx @@ -1,27 +1,34 @@ -import {CircularProgress, Typography} from "@mui/material"; -import {TreeItem} from "@mui/x-tree-view"; -import React from "react"; +import {CircularProgress, Typography} from '@mui/material'; +import {TreeItem} from '@mui/x-tree-view'; +import React from 'react'; import {useTranslation} from 'react-i18next'; type Props = {}; function TreeItemLoader({}: Props) { const {t} = useTranslation(); - return - - {t('common.loading', 'Loading…')} - } - /> + return ( + + + {t('common.loading', 'Loading…')} + + } + /> + ); } export default React.memo(TreeItemLoader, () => true); diff --git a/databox/client/src/components/Media/Collection/CollectionTree/WorkspaceTreeItem.tsx b/databox/client/src/components/Media/Collection/CollectionTree/WorkspaceTreeItem.tsx index 84bad09c5..c8f9bd2c3 100644 --- a/databox/client/src/components/Media/Collection/CollectionTree/WorkspaceTreeItem.tsx +++ b/databox/client/src/components/Media/Collection/CollectionTree/WorkspaceTreeItem.tsx @@ -1,11 +1,14 @@ -import {Box, Typography} from "@mui/material"; -import {CollectionTreeItem} from "./CollectionTreeItem.tsx"; -import {TreeItem} from "@mui/x-tree-view"; -import React from "react"; -import {Workspace} from "../../../../types.ts"; -import {CommonTreeItemProps, treeViewPathSeparator} from "./collectionTree.ts"; -import {CollectionPager, useCollectionStore} from "../../../../store/collectionStore.ts"; -import TreeItemLoader from "./TreeItemLoader.tsx"; +import {Box, Typography} from '@mui/material'; +import {CollectionTreeItem} from './CollectionTreeItem.tsx'; +import {TreeItem} from '@mui/x-tree-view'; +import React from 'react'; +import {Workspace} from '../../../../types.ts'; +import {CommonTreeItemProps, treeViewPathSeparator} from './collectionTree.ts'; +import { + CollectionPager, + useCollectionStore, +} from '../../../../store/collectionStore.ts'; +import TreeItemLoader from './TreeItemLoader.tsx'; type Props = { workspace: Workspace; @@ -36,51 +39,53 @@ export default function WorkspaceTreeItem({ } } - return <> - - - + + - {workspace.name} - - - - - } - disabled={ - disabledBranches && - disabledBranches.some(b => nodeId.startsWith(b)) - } - > - {pager.expanding ? : null} - {pager.items.map(c => ( - - ))} - - + + {workspace.name} + + + + + } + disabled={ + disabledBranches && + disabledBranches.some(b => nodeId.startsWith(b)) + } + > + {pager.expanding ? : null} + {pager.items.map(c => ( + + ))} + + + ); } diff --git a/databox/client/src/components/Media/Collection/CollectionTree/collectionTree.ts b/databox/client/src/components/Media/Collection/CollectionTree/collectionTree.ts index f16609686..6bebe1284 100644 --- a/databox/client/src/components/Media/Collection/CollectionTree/collectionTree.ts +++ b/databox/client/src/components/Media/Collection/CollectionTree/collectionTree.ts @@ -1,5 +1,5 @@ -import {CollectionOptionalWorkspace} from "../../../../types.ts"; -import {nodeNewPrefix} from "../EditableTree.tsx"; +import {CollectionOptionalWorkspace} from '../../../../types.ts'; +import {nodeNewPrefix} from '../EditableTree.tsx'; const nodeSeparator = '|'; @@ -29,14 +29,13 @@ export type CommonTreeItemProps = { setExpanded: SetExpanded; } & CommonTreeProps; - export type CommonTreeProps = { multiple?: IsMulti; disabledBranches?: string[]; allowNew?: boolean; disabled?: boolean | undefined; isSelectable?: IsSelectable; -} +}; export type CollectionId = string; diff --git a/databox/client/src/components/Media/Collection/EditableTree.tsx b/databox/client/src/components/Media/Collection/EditableTree.tsx index f9d11e0d9..0e79b2ac4 100644 --- a/databox/client/src/components/Media/Collection/EditableTree.tsx +++ b/databox/client/src/components/Media/Collection/EditableTree.tsx @@ -8,7 +8,11 @@ import DeleteIcon from '@mui/icons-material/Delete'; import CreateNewFolderIcon from '@mui/icons-material/CreateNewFolder'; import {KeyboardCode} from '@dnd-kit/core'; import {alpha} from '@mui/material/styles'; -import {NewCollectionNodeState, SetExpanded, UpdateCollectionPath} from "./CollectionTree/collectionTree.ts"; +import { + NewCollectionNodeState, + SetExpanded, + UpdateCollectionPath, +} from './CollectionTree/collectionTree.ts'; type Props = { offset: number; diff --git a/databox/client/src/components/Media/CollectionsPanel.tsx b/databox/client/src/components/Media/CollectionsPanel.tsx index ad875a0fc..1e0c13cfa 100644 --- a/databox/client/src/components/Media/CollectionsPanel.tsx +++ b/databox/client/src/components/Media/CollectionsPanel.tsx @@ -5,7 +5,7 @@ import WorkspaceMenuItem, { } from './WorkspaceMenuItem'; import {alpha, Box, CircularProgress} from '@mui/material'; import {collectionItemClassName} from './CollectionMenuItem'; -import {useWorkspaceStore} from "../../store/workspaceStore.ts"; +import {useWorkspaceStore} from '../../store/workspaceStore.ts'; import useEffectOnce from '@alchemy/react-hooks/src/useEffectOnce'; import {FlexRow} from '@alchemy/phrasea-ui'; @@ -61,16 +61,22 @@ function CollectionsPanel({}: Props) { }, })} > - {loading ? - - : <> - {workspaces?.map(w => ( - - ))} - } + {loading ? ( + + + + ) : ( + <> + {workspaces?.map(w => ( + + ))} + + )} ); } diff --git a/databox/client/src/components/Media/LeftPanel.tsx b/databox/client/src/components/Media/LeftPanel.tsx index e2e4fa567..bdf5e3c95 100644 --- a/databox/client/src/components/Media/LeftPanel.tsx +++ b/databox/client/src/components/Media/LeftPanel.tsx @@ -21,7 +21,7 @@ function a11yProps(name: TabEnum) { }; } -function TabPanel(props: { index: string } & TabPanelProps) { +function TabPanel(props: {index: string} & TabPanelProps) { const {children, value, index} = props; return ( @@ -68,14 +68,18 @@ export default function LeftPanel() { ) : null} - + - {treeLoadedOnce.current || tab === TabEnum.tree ? : ''} + {treeLoadedOnce.current || tab === TabEnum.tree ? ( + + ) : ( + '' + )} {isAuthenticated() ? ( - + ) : null} diff --git a/databox/client/src/components/Media/Search/SearchFilters.tsx b/databox/client/src/components/Media/Search/SearchFilters.tsx index 19254dc2e..8fdb000ee 100644 --- a/databox/client/src/components/Media/Search/SearchFilters.tsx +++ b/databox/client/src/components/Media/Search/SearchFilters.tsx @@ -54,21 +54,34 @@ function formatFilterTitle( return t('filter.between', { defaultValue: '{{title}} between {{from}} and {{to}}', title, - from: extractLabelValueFromKey(value[0], type, DateFormats.Long).label, - to: extractLabelValueFromKey(value[1], type, DateFormats.Long).label, + from: extractLabelValueFromKey( + value[0], + type, + DateFormats.Long + ).label, + to: extractLabelValueFromKey( + value[1], + type, + DateFormats.Long + ).label, }); } else if (value[0]) { return t('filter.after', { defaultValue: '{{title}} after {{from}}', title, - from: extractLabelValueFromKey(value[0], type, DateFormats.Long).label, + from: extractLabelValueFromKey( + value[0], + type, + DateFormats.Long + ).label, }); } return t('filter.before', { defaultValue: '{{title}} before {{to}}', title, - to: extractLabelValueFromKey(value[1], type, DateFormats.Long).label, + to: extractLabelValueFromKey(value[1], type, DateFormats.Long) + .label, }); } } @@ -94,20 +107,23 @@ function formatFilterLabel( .join(', '); case FacetType.DateRange: if (value[0] && value[1]) { - - return `${ - extractLabelValueFromKey(value[0], type, DateFormats.Short) - .label - } - ${ - extractLabelValueFromKey(value[1], type, DateFormats.Short) - .label - }`; + return `${ + extractLabelValueFromKey(value[0], type, DateFormats.Short) + .label + } - ${ + extractLabelValueFromKey(value[1], type, DateFormats.Short) + .label + }`; } else if (value[0]) { - return `>= ${extractLabelValueFromKey(value[0], type, DateFormats.Short) - .label}`; + return `>= ${ + extractLabelValueFromKey(value[0], type, DateFormats.Short) + .label + }`; } else { - return `<= ${extractLabelValueFromKey(value[1], type, DateFormats.Short) - .label}`; + return `<= ${ + extractLabelValueFromKey(value[1], type, DateFormats.Short) + .label + }`; } } } diff --git a/databox/client/src/components/Media/WorkspaceMenuItem.tsx b/databox/client/src/components/Media/WorkspaceMenuItem.tsx index 5a3b4381f..657d9e6f4 100644 --- a/databox/client/src/components/Media/WorkspaceMenuItem.tsx +++ b/databox/client/src/components/Media/WorkspaceMenuItem.tsx @@ -60,8 +60,9 @@ export default function WorkspaceMenuItem({data}: WorkspaceMenuItemProps) { e.stopPropagation(); expand(); - if (undefined === pager.total - || e.detail > 1 // is double click + if ( + undefined === pager.total || + e.detail > 1 // is double click ) { loadRoot(id); } @@ -125,7 +126,10 @@ export default function WorkspaceMenuItem({data}: WorkspaceMenuItemProps) { aria-label="expand-toggle" > {pager.expanding ? ( - + ) : !expanded ? ( ) : ( diff --git a/databox/client/src/components/Share/CreateShareDialog.tsx b/databox/client/src/components/Share/CreateShareDialog.tsx index f19953342..b1010dccb 100644 --- a/databox/client/src/components/Share/CreateShareDialog.tsx +++ b/databox/client/src/components/Share/CreateShareDialog.tsx @@ -3,15 +3,11 @@ import {Asset, Share} from '../../types.ts'; import {FormFieldErrors, FormRow} from '@alchemy/react-form'; import {TextField} from '@mui/material'; import FormDialog from '../Dialog/FormDialog.tsx'; -import { - StackedModalProps, - useModals, - useFormPrompt, -} from '@alchemy/navigation'; +import {StackedModalProps, useModals, useFormPrompt} from '@alchemy/navigation'; import {createAssetShare} from '../../api/asset.ts'; import {useFormSubmit} from '../../../../../lib/js/api'; import RemoteErrors from '../Form/RemoteErrors.tsx'; -import {normalizeDate} from "../../lib/date.ts"; +import {normalizeDate} from '../../lib/date.ts'; type Props = { asset: Asset; diff --git a/databox/client/src/components/Share/EmbedDialog.tsx b/databox/client/src/components/Share/EmbedDialog.tsx index 2b033e75c..143c1f686 100644 --- a/databox/client/src/components/Share/EmbedDialog.tsx +++ b/databox/client/src/components/Share/EmbedDialog.tsx @@ -1,12 +1,12 @@ -import {Box, Button, IconButton, TextField} from "@mui/material"; -import {AppDialog} from "@alchemy/phrasea-ui"; -import {StackedModalProps, useModals} from "@alchemy/navigation"; -import {useTranslation} from "react-i18next"; -import React from "react"; -import CloseIcon from "@mui/icons-material/Close"; +import {Box, Button, IconButton, TextField} from '@mui/material'; +import {AppDialog} from '@alchemy/phrasea-ui'; +import {StackedModalProps, useModals} from '@alchemy/navigation'; +import {useTranslation} from 'react-i18next'; +import React from 'react'; +import CloseIcon from '@mui/icons-material/Close'; import RestartAltIcon from '@mui/icons-material/RestartAlt'; -import CopyToClipboard from "../../lib/CopyToClipboard.tsx"; -import ContentCopyIcon from "@mui/icons-material/ContentCopy"; +import CopyToClipboard from '../../lib/CopyToClipboard.tsx'; +import ContentCopyIcon from '@mui/icons-material/ContentCopy'; export type EmbedProps = { url: string; @@ -27,8 +27,8 @@ export default function EmbedDialog({ const handleFocus = (event: React.FocusEvent) => event.currentTarget.select(); - const defaultCode = isImage ? - `${title}` + const defaultCode = isImage + ? `${title}` : ``; const [code, setCode] = React.useState(defaultCode); @@ -45,25 +45,21 @@ export default function EmbedDialog({ maxWidth={'md'} actions={({onClose}) => ( <> - - )} > - + - ({ - position: 'absolute', - bottom: theme.spacing(1), - right: theme.spacing(1), - })}> + ({ + position: 'absolute', + bottom: theme.spacing(1), + right: theme.spacing(1), + })} + > {({copy}) => ( -
- +
- ); + ); } diff --git a/databox/client/src/components/Share/SelectShareAlternateUrl.tsx b/databox/client/src/components/Share/SelectShareAlternateUrl.tsx index 4b114bbc9..cd476d4b3 100644 --- a/databox/client/src/components/Share/SelectShareAlternateUrl.tsx +++ b/databox/client/src/components/Share/SelectShareAlternateUrl.tsx @@ -1,8 +1,8 @@ -import React from "react"; +import React from 'react'; import {useTranslation} from 'react-i18next'; -import {Button, Menu, MenuItem} from "@mui/material"; -import {ShareAlternateUrl} from "../../types.ts"; -import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; +import {Button, Menu, MenuItem} from '@mui/material'; +import {ShareAlternateUrl} from '../../types.ts'; +import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; type Props = { onSelect: (value: string | undefined) => void; @@ -25,44 +25,39 @@ export default function SelectShareAlternateUrl({ setAnchorEl(null); }; - const select: Props['onSelect'] = (value) => { + const select: Props['onSelect'] = value => { onSelect(value); handleClose(); - } + }; const defaultLabel = t('share.item.rendition.asset', 'Asset'); - return <> - - - select(undefined)} - selected={!value} + return ( + <> + + + select(undefined)} selected={!value}> + {defaultLabel} - ))} - - + {alternateUrls.map(a => ( + select(a.name)} + selected={a.name === value} + > + {a.name} + + ))} + + + ); } diff --git a/databox/client/src/components/Share/ShareAssetDialog.tsx b/databox/client/src/components/Share/ShareAssetDialog.tsx index 3c77c6589..80cd3d214 100644 --- a/databox/client/src/components/Share/ShareAssetDialog.tsx +++ b/databox/client/src/components/Share/ShareAssetDialog.tsx @@ -29,9 +29,9 @@ import CopiableTextField from '../Ui/CopiableTextField.tsx'; import {toast} from 'react-toastify'; import ShareItem from './ShareItem.tsx'; import {StackedModalProps, useModals} from '@alchemy/navigation'; -import {getShareTitle, UrlActions} from "./UrlActions.tsx"; -import {getShareUrl} from "./shareUtils.ts"; -import ShareSocials from "./ShareSocials.tsx"; +import {getShareTitle, UrlActions} from './UrlActions.tsx'; +import {getShareUrl} from './shareUtils.ts'; +import ShareSocials from './ShareSocials.tsx'; type Props = { asset: Asset; @@ -192,9 +192,7 @@ export default function ShareAssetDialog({asset, open, modalIndex}: Props) { } + actions={} />
(); + const [selectedAlternate, setSelectedAlternate] = React.useState< + string | undefined + >(); const shareTitle = getShareTitle(share); - const alternateUrl = selectedAlternate ? share.alternateUrls.find(a => a.name === selectedAlternate) : undefined; + const alternateUrl = selectedAlternate + ? share.alternateUrls.find(a => a.name === selectedAlternate) + : undefined; const shareUrl = alternateUrl?.url ?? getShareUrl(share); return ( @@ -47,10 +51,7 @@ export default function ShareItem({share, revoking, onRevoke}: Props) { '' )} - + {t( 'share.item.createdAt', 'Created at {{date}}', @@ -66,17 +67,18 @@ export default function ShareItem({share, revoking, onRevoke}: Props) { - -
} - actions={} + startAdornment={ +
+ +
+ } + actions={} />
@@ -90,7 +92,7 @@ export default function ShareItem({share, revoking, onRevoke}: Props) { mr: 1, }} > - + {t( 'share.item.startsAt', @@ -113,7 +115,7 @@ export default function ShareItem({share, revoking, onRevoke}: Props) { mr: 1, }} > - + {t( 'share.item.expiresAt', @@ -132,7 +134,11 @@ export default function ShareItem({share, revoking, onRevoke}: Props) {
@@ -148,7 +154,7 @@ export default function ShareItem({share, revoking, onRevoke}: Props) { ml: 2, }} color={'error'} - startIcon={} + startIcon={} loading={revoking} disabled={revoking} onClick={() => onRevoke(share.id)} diff --git a/databox/client/src/components/Share/ShareSocials.tsx b/databox/client/src/components/Share/ShareSocials.tsx index 479d71a9b..978d29209 100644 --- a/databox/client/src/components/Share/ShareSocials.tsx +++ b/databox/client/src/components/Share/ShareSocials.tsx @@ -21,12 +21,12 @@ import { WorkplaceIcon, WorkplaceShareButton, XIcon, -} from "react-share"; -import {Box, IconButton} from "@mui/material"; +} from 'react-share'; +import {Box, IconButton} from '@mui/material'; import {useTranslation} from 'react-i18next'; -import EmbedDialog, {EmbedProps} from "./EmbedDialog.tsx"; -import CodeIcon from "@mui/icons-material/Code"; -import {useModals} from "@alchemy/navigation"; +import EmbedDialog, {EmbedProps} from './EmbedDialog.tsx'; +import CodeIcon from '@mui/icons-material/Code'; +import {useModals} from '@alchemy/navigation'; type Props = EmbedProps; @@ -36,104 +36,136 @@ export default function ShareSocials(props: Props) { const iconSize = 32; const {t} = useTranslation(); - return <> - ({ - mt: theme.spacing(1), - display: 'flex', - flexWrap: 'wrap', - alignItems: 'center', - direction: 'row', - gap: theme.spacing(1), - 'button svg': { - display: 'block', - } - })} - > - { - openModal(EmbedDialog, props); - }} + return ( + <> + ({ + 'mt': theme.spacing(1), + 'display': 'flex', + 'flexWrap': 'wrap', + 'alignItems': 'center', + 'direction': 'row', + 'gap': theme.spacing(1), + 'button svg': { + display: 'block', + }, + })} > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + { + openModal(EmbedDialog, props); + }} + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + ); } diff --git a/databox/client/src/components/Share/UrlActions.tsx b/databox/client/src/components/Share/UrlActions.tsx index 1d838a01b..2a8625adf 100644 --- a/databox/client/src/components/Share/UrlActions.tsx +++ b/databox/client/src/components/Share/UrlActions.tsx @@ -1,7 +1,7 @@ -import {FlexRow} from "../../../../../lib/js/phrasea-ui"; -import {IconButton} from "@mui/material"; -import OpenInNewIcon from "@mui/icons-material/OpenInNew"; -import {Share} from "../../types.ts"; +import {FlexRow} from '../../../../../lib/js/phrasea-ui'; +import {IconButton} from '@mui/material'; +import OpenInNewIcon from '@mui/icons-material/OpenInNew'; +import {Share} from '../../types.ts'; type Props = { url: string; @@ -10,11 +10,8 @@ type Props = { export function UrlActions({url}: Props) { return ( - - + + ); diff --git a/databox/client/src/components/Share/shareUtils.ts b/databox/client/src/components/Share/shareUtils.ts index 76a0d1479..4613f0886 100644 --- a/databox/client/src/components/Share/shareUtils.ts +++ b/databox/client/src/components/Share/shareUtils.ts @@ -1,6 +1,6 @@ -import {Share} from "../../types.ts"; -import {routes} from "../../routes.ts"; -import {getPath} from "@alchemy/navigation"; +import {Share} from '../../types.ts'; +import {routes} from '../../routes.ts'; +import {getPath} from '@alchemy/navigation'; export function getShareUrl(s: Share) { return getPath( @@ -14,4 +14,3 @@ export function getShareUrl(s: Share) { } ); } - diff --git a/databox/client/src/components/Ui/CopiableTextField.tsx b/databox/client/src/components/Ui/CopiableTextField.tsx index cb027d5d7..4e51c968c 100644 --- a/databox/client/src/components/Ui/CopiableTextField.tsx +++ b/databox/client/src/components/Ui/CopiableTextField.tsx @@ -15,7 +15,12 @@ type Props = { value: string; } & Omit; -export default function CopiableTextField({value, actions, startAdornment, ...props}: Props) { +export default function CopiableTextField({ + value, + actions, + startAdornment, + ...props +}: Props) { const handleFocus = (event: React.FocusEvent) => event.currentTarget.select(); @@ -26,9 +31,11 @@ export default function CopiableTextField({value, actions, startAdornment, ...pr onFocus={handleFocus} InputProps={{ readOnly: true, - startAdornment: startAdornment ? - {startAdornment} - : undefined, + startAdornment: startAdornment ? ( + + {startAdornment} + + ) : undefined, endAdornment: ( diff --git a/databox/client/src/components/Upload/UploadForm.tsx b/databox/client/src/components/Upload/UploadForm.tsx index c5730d1fb..51f272098 100644 --- a/databox/client/src/components/Upload/UploadForm.tsx +++ b/databox/client/src/components/Upload/UploadForm.tsx @@ -23,7 +23,7 @@ import FullPageLoader from '../Ui/FullPageLoader'; import {useFormPrompt} from '@alchemy/navigation'; import {UseFormSubmitReturn} from '@alchemy/api'; import {WorkspaceContext} from '../../context/WorkspaceContext.tsx'; -import {Collection} from "../Media/Collection/CollectionTree/collectionTree.ts"; +import {Collection} from '../Media/Collection/CollectionTree/collectionTree.ts'; export type UploadData = { destination: Collection; diff --git a/databox/client/src/components/Upload/UploadModal.tsx b/databox/client/src/components/Upload/UploadModal.tsx index bf0ff3db4..3849d35c0 100644 --- a/databox/client/src/components/Upload/UploadModal.tsx +++ b/databox/client/src/components/Upload/UploadModal.tsx @@ -19,16 +19,12 @@ import { postAssetDataTemplate, putAssetDataTemplate, } from '../../api/templates'; -import { - StackedModalProps, - useModals, - useFormPrompt, -} from '@alchemy/navigation'; +import {StackedModalProps, useModals, useFormPrompt} from '@alchemy/navigation'; import {Privacy} from '../../api/privacy'; import {Asset} from '../../types'; import {getAttributeList} from '../Media/Asset/Attribute/AttributeListData.ts'; import type {TFunction} from '@alchemy/i18n'; -import {CollectionId} from "../Media/Collection/CollectionTree/collectionTree.ts"; +import {CollectionId} from '../Media/Collection/CollectionTree/collectionTree.ts'; type FileWrapper = { id: string; diff --git a/databox/client/src/components/User/Preferences/UserPreferencesProvider.tsx b/databox/client/src/components/User/Preferences/UserPreferencesProvider.tsx index b7da48b63..3b0a848d2 100644 --- a/databox/client/src/components/User/Preferences/UserPreferencesProvider.tsx +++ b/databox/client/src/components/User/Preferences/UserPreferencesProvider.tsx @@ -1,7 +1,8 @@ import React, {PropsWithChildren} from 'react'; import { TUserPreferencesContext, - UpdatePreferenceHandler, UpdatePreferenceHandlerArg, + UpdatePreferenceHandler, + UpdatePreferenceHandlerArg, UserPreferences, UserPreferencesContext, } from './UserPreferencesContext'; @@ -12,12 +13,14 @@ import {useAuth} from '@alchemy/react-auth'; import {ThemeEditorProvider} from '@alchemy/theme-editor'; import {Classes} from '../../../classes.ts'; import {scrollbarWidth} from '../../../constants.ts'; -import {FullPageLoader} from "@alchemy/phrasea-ui"; +import {FullPageLoader} from '@alchemy/phrasea-ui'; import {useTranslation} from 'react-i18next'; -import {useMutation, useQuery} from "@tanstack/react-query"; -import {queryClient} from "../../../lib/query.ts"; +import {useMutation, useQuery} from '@tanstack/react-query'; +import {queryClient} from '../../../lib/query.ts'; -type UpdatePrefVariables = { +type UpdatePrefVariables< + T extends keyof UserPreferences = keyof UserPreferences, +> = { name: T; handler: UpdatePreferenceHandlerArg; }; @@ -63,7 +66,7 @@ export default function UserPreferencesProvider({children}: Props) { name, handler, }: UpdatePrefVariables): Promise => { - return queryClient.setQueryData(queryKey, (prev) => { + return queryClient.setQueryData(queryKey, prev => { const newPrefs = {...(prev ?? {})} as UserPreferences; if (typeof handler === 'function') { @@ -84,8 +87,12 @@ export default function UserPreferencesProvider({children}: Props) { })!; }; - const updatePreference = useMutation>({ - mutationFn + const updatePreference = useMutation< + UserPreferences, + {}, + UpdatePrefVariables + >({ + mutationFn, }); const value = React.useMemo(() => { @@ -107,7 +114,7 @@ export default function UserPreferencesProvider({children}: Props) { preferences.theme ?? 'default' )} > - + ({ '*': { @@ -136,10 +143,17 @@ export default function UserPreferencesProvider({children}: Props) { })} /> - {!isLoading ? children : } + {!isLoading ? ( + children + ) : ( + + )} ); diff --git a/databox/client/src/lib/date.ts b/databox/client/src/lib/date.ts index c96ea78b8..13bd5bef2 100644 --- a/databox/client/src/lib/date.ts +++ b/databox/client/src/lib/date.ts @@ -1,5 +1,6 @@ - -export function normalizeDate(date: string | null | undefined): string | null | undefined { +export function normalizeDate( + date: string | null | undefined +): string | null | undefined { if (date) { return new Date(date).toISOString(); } diff --git a/databox/client/src/lib/upload/uploader.ts b/databox/client/src/lib/upload/uploader.ts index 951f8703a..196fd4b9d 100644 --- a/databox/client/src/lib/upload/uploader.ts +++ b/databox/client/src/lib/upload/uploader.ts @@ -10,8 +10,8 @@ import {v4 as uuidv4} from 'uuid'; import { CollectionId, NewCollectionPath, - treeViewPathSeparator -} from "../../components/Media/Collection/CollectionTree/collectionTree.ts"; + treeViewPathSeparator, +} from '../../components/Media/Collection/CollectionTree/collectionTree.ts'; type InputFile = { title?: string; diff --git a/databox/client/src/store/collectionStore.ts b/databox/client/src/store/collectionStore.ts index 1ee05868d..476685b91 100644 --- a/databox/client/src/store/collectionStore.ts +++ b/databox/client/src/store/collectionStore.ts @@ -1,6 +1,11 @@ import {create, StoreApi} from 'zustand'; import {Collection} from '../types'; -import {collectionChildrenLimit, CollectionOptions, collectionSecondLimit, getCollections,} from '../api/collection'; +import { + collectionChildrenLimit, + CollectionOptions, + collectionSecondLimit, + getCollections, +} from '../api/collection'; export type CollectionPager = { items: CollectionExtended[]; @@ -22,7 +27,11 @@ type State = { tree: Record; updateCollection: (collection: Collection) => void; partialUpdateCollection: (id: string, updates: Partial) => void; - load: (workspaceId: string, parentId?: string, force?: boolean) => Promise; + load: ( + workspaceId: string, + parentId?: string, + force?: boolean + ) => Promise; loadMore: (workspaceId: string, parentId?: string) => Promise; addCollection: ( collection: Collection, @@ -72,12 +81,14 @@ export const useCollectionStore = create((set, getState) => ({ const jc = state.justCreated[pagerId] ?? false; if (jc) { - Object.keys(jc as Record).forEach(cId => { - if (!items.some(c => c.id === cId)) { - items.push(jc[cId]); - ++data.total; + Object.keys(jc as Record).forEach( + cId => { + if (!items.some(c => c.id === cId)) { + items.push(jc[cId]); + ++data.total; + } } - }); + ); } tree[pagerId] = { @@ -404,11 +415,16 @@ export function getNextPage(pager: CollectionPager): number | undefined { } } -const createPagerExpandingSetter = (pagerId: string, parentId: string | undefined) => { +const createPagerExpandingSetter = ( + pagerId: string, + parentId: string | undefined +) => { return (state: State) => { const tree = {...state.tree}; - const parentCollection = parentId ? state.collections[parentId] : undefined; + const parentCollection = parentId + ? state.collections[parentId] + : undefined; tree[pagerId] = { ...(tree[pagerId] ?? { @@ -455,7 +471,7 @@ function addJustCreated( const newStore = {...store}; newStore[parentId] = { ...(newStore[parentId] ?? {}), - } + }; newStore[parentId][collection.id] = collection; setTimeout(() => { @@ -465,12 +481,12 @@ function addJustCreated( if (s[parentId]) { s[parentId] = { ...(s[parentId] ?? {}), - } - delete s[parentId][collection.id] + }; + delete s[parentId][collection.id]; } return s; - }) + }); }, 10000); return store; diff --git a/databox/client/src/store/workspaceStore.ts b/databox/client/src/store/workspaceStore.ts index 16944f10b..b9c5b6410 100644 --- a/databox/client/src/store/workspaceStore.ts +++ b/databox/client/src/store/workspaceStore.ts @@ -1,6 +1,6 @@ import {create} from 'zustand'; import {Workspace} from '../types'; -import {getWorkspaces} from "../api/workspace.ts"; +import {getWorkspaces} from '../api/workspace.ts'; type State = { tree: Record; @@ -61,7 +61,7 @@ export const useWorkspaceStore = create((set, getState) => ({ const tree = {...state.tree}; tree[id] = { - ...tree[id] ?? {}, + ...(tree[id] ?? {}), ...updates, }; diff --git a/databox/client/src/types.ts b/databox/client/src/types.ts index 8af6f53b5..4e9342bb2 100644 --- a/databox/client/src/types.ts +++ b/databox/client/src/types.ts @@ -33,7 +33,7 @@ export type ShareAlternateUrl = { name: string; url: string; type: string | undefined; -} +}; export type Share = { id: string; diff --git a/lib/php/admin-bundle/Field/YamlField.php b/lib/php/admin-bundle/Field/YamlField.php index 3e67c7522..e0a3d1c39 100644 --- a/lib/php/admin-bundle/Field/YamlField.php +++ b/lib/php/admin-bundle/Field/YamlField.php @@ -3,8 +3,8 @@ namespace Alchemy\AdminBundle\Field; use Alchemy\AdminBundle\Form\YamlType; -use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait; use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface; +use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait; final class YamlField implements FieldInterface { diff --git a/lib/php/admin-bundle/Form/JsonType.php b/lib/php/admin-bundle/Form/JsonType.php index 74c5a3d1a..753908859 100644 --- a/lib/php/admin-bundle/Form/JsonType.php +++ b/lib/php/admin-bundle/Form/JsonType.php @@ -26,8 +26,8 @@ public function transform(mixed $value) public function reverseTransform(mixed $value) { - if ($value !== null && json_validate($value) === false) { - return ['input-error' => 'Invalid JSON: ' . json_last_error_msg()]; + if (null !== $value && false === json_validate($value)) { + return ['input-error' => 'Invalid JSON: '.json_last_error_msg()]; } return json_decode($value, true, 512, JSON_THROW_ON_ERROR); @@ -36,7 +36,7 @@ public function reverseTransform(mixed $value) public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'attr'=> [ + 'attr' => [ 'rows' => 10, 'style' => 'font-family: "Courier New"', ], @@ -48,9 +48,9 @@ function (mixed $data, ExecutionContextInterface $context) { ->buildViolation($data['input-error']) ->addViolation(); } - } - ) - ] + } + ), + ], ]); } diff --git a/lib/php/admin-bundle/Form/YamlType.php b/lib/php/admin-bundle/Form/YamlType.php index 19690cb7b..38ccee929 100644 --- a/lib/php/admin-bundle/Form/YamlType.php +++ b/lib/php/admin-bundle/Form/YamlType.php @@ -4,20 +4,20 @@ namespace Alchemy\AdminBundle\Form; -use Symfony\Component\Yaml\Yaml; use Symfony\Component\Form\AbstractType; -use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Validator\Constraints as Assert; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Validator\Context\ExecutionContextInterface; +use Symfony\Component\Yaml\Exception\ParseException; +use Symfony\Component\Yaml\Yaml; -class YamlType extends AbstractType +class YamlType extends AbstractType { public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'attr'=> [ + 'attr' => [ 'rows' => 10, 'style' => 'font-family: "Courier New"', ], @@ -31,9 +31,9 @@ function (mixed $data, ExecutionContextInterface $context) { ->buildViolation(sprintf('YAML error: %s', $e->getMessage())) ->addViolation(); } - } - ) - ] + } + ), + ], ]); }