Skip to content

Commit

Permalink
mod: renamed configuration to settings, and settings to system
Browse files Browse the repository at this point in the history
  • Loading branch information
hashtagnulla committed Apr 16, 2024
1 parent 248cbfe commit 46ab666
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 58 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
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
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 @@ -149,19 +149,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

0 comments on commit 46ab666

Please sign in to comment.