Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/2052-tree-…
Browse files Browse the repository at this point in the history
…displayname-name-switcher
  • Loading branch information
hashtagnulla committed Jun 5, 2024
2 parents ddf072c + 923a4d4 commit d68b065
Show file tree
Hide file tree
Showing 21 changed files with 315 additions and 61 deletions.
44 changes: 22 additions & 22 deletions apps/sensenet/src/application-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export const PATHS = {
content: { appPath: '/content/:browseType/:action?', snPath: '/Root/Content' },
contentTemplates: { appPath: '/content-templates/:browseType/:action?', snPath: '/Root/ContentTemplates' },
custom: { appPath: '/custom/:browseType/:path/:action?' },
configuration: { appPath: '/settings/configuration/:action?', snPath: '/Root/System/Settings' },
localization: { appPath: '/settings/localization/:action?', snPath: '/Root/Localization' },
webhooks: { appPath: '/settings/webhooks/:action?', snPath: '/Root/System/WebHooks' },
settings: { appPath: '/settings/:submenu?' },
apiKeys: { appPath: '/settings/apikeys' },
configuration: { appPath: '/system/settings/:action?', snPath: '/Root/System/Settings' },
localization: { appPath: '/system/localization/:action?', snPath: '/Root/Localization' },
webhooks: { appPath: '/system/webhooks/:action?', snPath: '/Root/System/WebHooks' },
settings: { appPath: '/system/:submenu?' },
apiKeys: { appPath: '/system/apikeys' },
} as const

type SettingsItemType = 'stats' | 'apikeys' | 'webhooks' | 'adminui'
Expand All @@ -30,28 +30,28 @@ type RoutesWithContentBrowser = keyof Pick<
type RoutesWithActionParam = keyof Pick<typeof PATHS, 'savedQueries' | 'localization' | 'configuration' | 'webhooks'>

type Options =
| { path: (typeof PATHS)['events']['appPath']; params?: { eventGuid: string; [index: string]: string } }
| { path: (typeof PATHS)['events']['appPath']; params?: { eventGuid: string;[index: string]: string } }
| {
path: (typeof PATHS)[RoutesWithContentBrowser]['appPath']
params: { browseType: (typeof BrowseType)[number]; action?: string; [index: string]: string | undefined }
}
path: (typeof PATHS)[RoutesWithContentBrowser]['appPath']
params: { browseType: (typeof BrowseType)[number]; action?: string;[index: string]: string | undefined }
}
| {
path: (typeof PATHS)['custom']['appPath']
params: {
browseType: (typeof BrowseType)[number]
path: string
action?: string
[index: string]: string | undefined
}
path: (typeof PATHS)['custom']['appPath']
params: {
browseType: (typeof BrowseType)[number]
path: string
action?: string
[index: string]: string | undefined
}
}
| {
path: (typeof PATHS)[RoutesWithActionParam]['appPath']
params?: { action: string; [index: string]: string }
}
path: (typeof PATHS)[RoutesWithActionParam]['appPath']
params?: { action: string;[index: string]: string }
}
| {
path: (typeof PATHS)['settings']['appPath']
params?: { submenu: SettingsItemType; [index: string]: string | SettingsItemType }
}
path: (typeof PATHS)['settings']['appPath']
params?: { submenu: SettingsItemType;[index: string]: string | SettingsItemType }
}

export const resolvePathParams = ({ path, params }: Options) => {
let currentPath: string = path
Expand Down
3 changes: 3 additions & 0 deletions apps/sensenet/src/components/react-control-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export const reactControlMapper = (repository: Repository) => {
return FieldControls.WebhookPayload
case 'sn:HtmlEditor':
return FieldControls.HtmlEditor
case 'sn:RichText':
case 'sn:TipTapEditor':
return FieldControls.RichTextEditor
default:
}

Expand Down
8 changes: 4 additions & 4 deletions apps/sensenet/src/components/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export const Settings: React.FunctionComponent = () => {

const settingsItems = [
{
name: 'configuration',
displayName: localizationDrawer.titles.Configuration,
name: 'settings',
displayName: localizationDrawer.titles.Settings,
url: resolvePathParams({ path: PATHS.configuration.appPath }),
},
{
Expand Down Expand Up @@ -83,7 +83,7 @@ export const Settings: React.FunctionComponent = () => {
switch (routeMatch.params.submenu) {
case 'localization':
return <ContentComponent disableColumnSettings rootPath={PATHS.localization.snPath} />
case 'configuration':
case 'settings':
return <SetupComponent />
case 'adminui':
return <PersonalSettingsEditor />
Expand Down Expand Up @@ -117,7 +117,7 @@ export const Settings: React.FunctionComponent = () => {
return (
<div className={clsx(globalClasses.contentWrapper, classes.settingsWrapper)} style={{ paddingLeft: 0 }}>
<div className={clsx(globalClasses.contentTitle, globalClasses.centeredVertical)}>
<span style={{ fontSize: '20px' }}>{localizationDrawer.titles.Settings}</span>
<span style={{ fontSize: '20px' }}>{localizationDrawer.titles.System}</span>
</div>
<div className={classes.settingsContainer}>
<div className={classes.settingsDrawer}>
Expand Down
2 changes: 1 addition & 1 deletion apps/sensenet/src/components/settings/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const Setup = () => {
return (
<div className={globalClasses.contentWrapper} style={{ paddingLeft: 0 }} data-test="settings-container">
<div className={clsx(globalClasses.contentTitle, globalClasses.centeredVertical)} style={{ display: 'grid' }}>
<span style={{ fontSize: '20px' }}>{localizationDrawerTitles.Configuration}</span>
<span style={{ fontSize: '20px' }}>{localizationDrawerTitles.Settings}</span>
</div>
{renderContent()}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export const PermissionView: React.FC<PermissionViewProps> = (props) => {
<ListItemText
primary={
<div>
{inheritedEntry.identity.displayName}
{inheritedEntry.identity.displayName} ({inheritedEntry.identity.path})
<Link
data-test={`inherited-${inheritedEntry.identity.displayName
?.replace(/\s+/g, '-')
Expand Down Expand Up @@ -383,7 +383,7 @@ export const PermissionView: React.FC<PermissionViewProps> = (props) => {
<ListItemText
primary={
<div className={globalClasses.centeredVertical}>
{setOnThisEntry.identity.displayName}
{setOnThisEntry.identity.displayName} ({setOnThisEntry.identity.path})
{!setOnThisEntry.propagates && (
<Tooltip title={localization.permissionEditor.localOnly} placement="top">
<DesktopMac className={classes.localOnlyIcon} />
Expand Down
52 changes: 26 additions & 26 deletions apps/sensenet/src/hooks/use-drawer-items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const useDrawerItems = () => {
systemItem: true,
},
{
itemType: 'Settings',
itemType: 'System',
systemItem: true,
},
],
Expand Down Expand Up @@ -131,7 +131,7 @@ export const useDrawerItems = () => {
return <Widgets />
case 'CustomContent':
return item.settings?.icon ? <Icon item={{ ContentTypeName: item.settings.icon }} /> : <Folder />
case 'Settings':
case 'System':
return <Build />
// no default
}
Expand Down Expand Up @@ -174,7 +174,7 @@ export const useDrawerItems = () => {
path: (item as CustomContentDrawerItem).settings?.appPath || '',
},
})
case 'Settings':
case 'System':
return resolvePathParams({ path: PATHS.settings.appPath, params: { submenu: 'stats' } })
default:
return '/'
Expand All @@ -194,32 +194,32 @@ export const useDrawerItems = () => {
return drawerItem
}

;[...settings.drawer.items, ...builtInDrawerItems]
.filterAsync(async (item) => {
if (!item.permissions?.length) {
return true
}
;[...settings.drawer.items, ...builtInDrawerItems]
.filterAsync(async (item) => {
if (!item.permissions?.length) {
return true
}

try {
for (const permission of item.permissions) {
const actions = await repo.getActions({ idOrPath: permission.path })
const actionIndex = actions.d.results.findIndex((action) => action.Name === permission.action)
if (actionIndex === -1 || actions.d.results[actionIndex].Forbidden) {
return false
try {
for (const permission of item.permissions) {
const actions = await repo.getActions({ idOrPath: permission.path })
const actionIndex = actions.d.results.findIndex((action) => action.Name === permission.action)
if (actionIndex === -1 || actions.d.results[actionIndex].Forbidden) {
return false
}
}
} catch (error) {
logger.debug({
message: error.message,
data: {
error,
},
})
return false
}
} catch (error) {
logger.debug({
message: error.message,
data: {
error,
},
})
return false
}
return true
})
.then((items) => setDrawerItems(items.map(getItemFromSettings)))
return true
})
.then((items) => setDrawerItems(items.map(getItemFromSettings)))
}, [
localization.descriptions,
localization.titles,
Expand Down
2 changes: 2 additions & 0 deletions apps/sensenet/src/localization/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const values = {
Settings: 'Settings',
Configuration: 'Configuration',
Stats: 'Stats',
System: 'System',
ApiAndSecurity: 'Api and Security',
Webhooks: 'Webhooks',
AdminUiCustomization: 'Admin-ui customization',
Expand All @@ -143,6 +144,7 @@ const values = {
UsersAndGroups: 'Manage users and groups, roles and identities',
CustomContent: 'Explore and manage your content from the configured path',
Settings: 'Configure the sensenet system',
System: 'Configure the sensenet system',
ContentTemplates: 'Manage content templates',
},
personalSettingsTitle: 'Edit personal settings',
Expand Down
10 changes: 5 additions & 5 deletions apps/sensenet/src/services/PersonalSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const BuiltInDrawerItemType = tuple(
'SavedQueries',
'Trash',
'UsersAndGroups',
'Settings',
'System',
'ContentTemplates',
)

Expand Down Expand Up @@ -153,19 +153,19 @@ export const defaultSettings: PersonalSettingsType = {
export class PersonalSettings {
private checkDrawerItems(settings: Partial<PersonalSettingsType>): Partial<PersonalSettingsType> {
if (settings.default?.drawer?.items?.find((i) => typeof i === 'string')) {
;(settings.default.drawer.items as any) = undefined
; (settings.default.drawer.items as any) = undefined
}

if (settings.desktop?.drawer?.items?.find((i) => typeof i === 'string')) {
;(settings.desktop.drawer.items as any) = undefined
; (settings.desktop.drawer.items as any) = undefined
}

if (settings.tablet?.drawer?.items?.find((i) => typeof i === 'string')) {
;(settings.tablet.drawer.items as any) = undefined
; (settings.tablet.drawer.items as any) = undefined
}

if (settings.mobile?.drawer?.items?.find((i) => typeof i === 'string')) {
;(settings.mobile.drawer.items as any) = undefined
; (settings.mobile.drawer.items as any) = undefined
}

return settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ export const RichTextEditor: React.FC<
readOnly={props.settings.ReadOnly}
localization={props.localization?.richTextEditor}
onChange={({ editor }) => {
if (props.settings.ControlHint === 'sn:RichText' || props.settings.ControlHint === 'sn:TipTapEditor') {
props.fieldOnChange?.(props.settings.Name, editor.getHTML())
return
}

props.fieldOnChange?.(props.settings.Name, {
text: editor.getHTML(),
editor: JSON.stringify(editor.getJSON()),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
IconButton,
IconButtonProps,
Tooltip,
} from '@material-ui/core'
import CodeIcon from '@material-ui/icons/Code'
import { Editor } from '@tiptap/react'
import React, { FC, useState } from 'react'
import { useLocalization } from '../../hooks'
import { HtmlEditor } from '../html-editor'

interface HTMLEditorControlProps {
editor: Editor
buttonProps?: Partial<IconButtonProps>
}

export const HTMLEditorControl: FC<HTMLEditorControlProps> = ({ editor, buttonProps }) => {
const [open, setOpen] = useState(false)
const [html, setHtml] = useState(editor.getHTML())
const localization = useLocalization()

const handleClickOpen = () => {
setOpen(true)
}

const handleClose = () => {
if (editor.getHTML() === html) {
setOpen(false)
return
}

const confirmResult = window.confirm(localization.HTMLEditorControl.confirm)
if (!confirmResult) {
return
}
editor.commands.setContent(html)

setOpen(false)
}

return (
<>
<Tooltip title={`${localization.menubar.EditHtml}`}>
<IconButton
onClick={() => handleClickOpen()}
color={editor.isActive('code') ? 'primary' : 'default'}
{...buttonProps}>
<CodeIcon style={{ marginTop: '-7px' }} />
<span style={{ position: 'absolute', fontSize: '12px', top: '13px', fontWeight: 'bold' }}>html</span>
</IconButton>
</Tooltip>
<Dialog
open={open}
onClose={handleClose}
aria-labelledby="html-editor-control-title"
fullWidth
maxWidth="lg"
onExited={() => { }}>
<DialogTitle id="html-editor-control-title">{localization.HTMLEditorControl.title}</DialogTitle>
<DialogContent>
<HtmlEditor initialState={editor.getHTML()} fieldOnChange={setHtml} />
</DialogContent>
<DialogActions>
<Button
onClick={() => {
setOpen(false)
}}>
{localization.common.cancel}
</Button>
<Button
onClick={() => {
editor.commands.setContent(html)
setOpen(false)
}}
color="primary">
{localization.linkControl.submit}
</Button>
</DialogActions>
</Dialog>
</>
)
}
1 change: 1 addition & 0 deletions packages/sn-editor-react/src/components/controls/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './image-control'
export * from './link-control'
export * from './table-control'
export * from './typography-control'
export * from './html-editor-control'
Loading

0 comments on commit d68b065

Please sign in to comment.