diff --git a/apps/sensenet/src/components/content/Explore.tsx b/apps/sensenet/src/components/content/Explore.tsx index da596f37b..78dd8f518 100644 --- a/apps/sensenet/src/components/content/Explore.tsx +++ b/apps/sensenet/src/components/content/Explore.tsx @@ -23,7 +23,7 @@ import { DocumentViewer } from '../document-viewer' import { EditBinary } from '../edit/edit-binary' import { FullScreenLoader } from '../full-screen-loader' import TreeWithData from '../tree/tree-with-data' -import { BrowseView, EditView, NewView, PermissionView, VersionView } from '../view-controls' +import { BrowseView, EditView, ImageView, NewView, PermissionView, VersionView } from '../view-controls' import WopiPage from '../wopi-page' const useStyles = makeStyles((theme: Theme) => { @@ -152,6 +152,8 @@ export function Explore({ return case 'setpermissions': return + case 'image': + return case 'preview': return case 'edit-binary': diff --git a/apps/sensenet/src/components/view-controls/image-view.tsx b/apps/sensenet/src/components/view-controls/image-view.tsx new file mode 100644 index 000000000..513c6a04e --- /dev/null +++ b/apps/sensenet/src/components/view-controls/image-view.tsx @@ -0,0 +1,110 @@ +/** + * @module ViewControls + */ +import { Button, createStyles, makeStyles } from '@material-ui/core' +import { GenericContent } from '@sensenet/default-content-types' +import { useRepository } from '@sensenet/hooks-react' +import React, { ReactElement, useEffect, useState } from 'react' +import { useHistory, useRouteMatch } from 'react-router-dom' +import { useGlobalStyles } from '../../globalStyles' +import { useLocalization } from '../../hooks' +import { navigateToAction } from '../../services' + +const useStyles = makeStyles(() => { + return createStyles({ + imageViewContainer: { + width: 'auto', + overflow: 'auto', + margin: '0 24px', + }, + titleContainer: { + display: 'flex', + justifyContent: 'space-between', + marginTop: '30px', + marginBottom: '20px', + alignItems: 'center', + }, + title: { + fontSize: '20px', + paddingRight: '10px', + whiteSpace: 'nowrap', + overflow: 'hidden', + textOverflow: 'ellipsis', + }, + contentName: { + fontWeight: 500, + }, + imageContainer: { + width: '90%', + display: 'flex', + flexDirection: 'column', + flexWrap: 'nowrap', + alignItems: 'flex-start', + }, + image: { + maxWidth: '100%', + }, + buttonWrapper: { + padding: '20px 0', + width: '90%', + display: 'flex', + flexDirection: 'column', + flexWrap: 'nowrap', + alignItems: 'flex-end', + }, + }) +}) + +export interface ImageViewProps { + renderIcon?: (name: string) => ReactElement + handleCancel?: () => void + contentPath: string +} + +export const ImageView: React.FC = (props) => { + const repository = useRepository() + const formLocalization = useLocalization().forms + const globalClasses = useGlobalStyles() + const classes = useStyles() + const { contentPath } = props + const [currentContent, setCurrentContent] = useState() + const history = useHistory() + const routeMatch = useRouteMatch<{ browseType: string; action?: string }>() + + useEffect(() => { + async function getCurrentContent() { + const result = await repository.load({ + idOrPath: props.contentPath, + }) + setCurrentContent(result.d) + } + getCurrentContent() + }, [props.contentPath, repository]) + + return ( +
+
+
+ + {currentContent?.DisplayName} + +
+
+
+ +
+
+ +
+
+ ) +} diff --git a/apps/sensenet/src/components/view-controls/index.ts b/apps/sensenet/src/components/view-controls/index.ts index 9735bd083..f2311af8c 100644 --- a/apps/sensenet/src/components/view-controls/index.ts +++ b/apps/sensenet/src/components/view-controls/index.ts @@ -1,5 +1,6 @@ export * from './browse-view' export * from './edit-view' +export * from './image-view' export * from './new-view' export * from './permission-view' export * from './version-view' diff --git a/apps/sensenet/src/services/content-context-service.ts b/apps/sensenet/src/services/content-context-service.ts index 7971483f0..733966e4e 100644 --- a/apps/sensenet/src/services/content-context-service.ts +++ b/apps/sensenet/src/services/content-context-service.ts @@ -181,6 +181,10 @@ export function getPrimaryActionUrl({ return getUrlForContent({ content, uiSettings, location, action: 'edit-binary', snRoute, removePath }) } + if (content.Type === 'Image' || repository.schemas.isContentFromType(content, 'Image')) { + return getUrlForContent({ content, uiSettings, location, action: 'image', snRoute, removePath }) + } + if ( (content as any).Binary && (content as any).Binary.__mediaresource.content_type !== 'application/x-javascript' &&