Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restyling content list and settings cards #1623

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/sensenet/src/components/AddButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ const useStyles = makeStyles((theme: Theme) => {
display: 'flex',
alignItems: 'center',
justifyContent: 'space-evenly',
height: globals.common.drawerItemHeight,
height: globals.common.addButtonHeight,
paddingLeft: '2px',
},
listDropdown: {
padding: '10px 0 10px 10px',
Expand Down
3 changes: 2 additions & 1 deletion apps/sensenet/src/components/PageTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const useStyles = makeStyles((theme: Theme) => {
pageTitle: {
color: theme.palette.type === 'light' ? theme.palette.common.black : theme.palette.common.white,
fontFamily: '"Larsseit", Roboto',
fontSize: '20px',
fontSize: '24px',
padding: '8px 16px',
},
})
})
Expand Down
3 changes: 2 additions & 1 deletion apps/sensenet/src/components/appbar/desktop-app-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const useStyles = makeStyles(() => {
toolBar: {
position: 'static',
height: '100%',
paddingLeft: '32px',
minHeight: '42px',
paddingLeft: '16px',
paddingRight: 0,
},
logo: {
Expand Down
1 change: 1 addition & 0 deletions apps/sensenet/src/components/appbar/desktop-nav-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const useStyles = makeStyles((theme: Theme) =>
viewOptions: {
cursor: 'pointer',
marginRight: '16px',
padding: '7px',
},
navMenu: {
height: '100%',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ const useStyles = makeStyles(() => {
},
iconButton: {
color: globals.common.headerText,
'&:hover': {
backgroundColor: 'initial',
},
padding: '7px',
marginRight: '6px',
},
comboBox: {
position: 'relative',
Expand Down
6 changes: 3 additions & 3 deletions apps/sensenet/src/components/content-list/content-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const isReferenceField = (fieldName: string, repo: Repository, schema = '
}

const rowHeightConst = 67
const headerHeightConst = 58
const headerHeightConst = 48

/**
* Compare passed minutes with
Expand Down Expand Up @@ -747,9 +747,9 @@ export const ContentList = <T extends GenericContent = GenericContent>(props: Co
rowStyle: {
position: 'relative',
top: 'unset',
height: 'auto',
height: '48px',
overflow: 'initial',
padding: '5px 0px',
padding: '0',
},
onRowDoubleClick: onItemDoubleClickFunc,
disableHeader: props.hideHeader,
Expand Down
1 change: 0 additions & 1 deletion apps/sensenet/src/components/content/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const useStyles = makeStyles((theme: Theme) => {
width: '100%',
position: 'relative',
overflow: 'hidden',
paddingTop: '8px',
},
})
})
Expand Down
5 changes: 3 additions & 2 deletions apps/sensenet/src/components/drawer/PermanentDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ const useStyles = makeStyles((theme: Theme) => {
width: '100%',
},
listButton: {
height: '65px',
height: '60px',
paddingLeft: '2px',
},
expandCollapseWrapper: {
height: '49px',
Expand Down Expand Up @@ -126,7 +127,7 @@ export const PermanentDrawer = () => {
</List>

{systemItems && (
<List>
<List style={{ padding: 0 }}>
{systemItems.map((item) => {
return (
<li key={item.itemType}>
Expand Down
3 changes: 2 additions & 1 deletion apps/sensenet/src/components/drawer/PermanentDrawerItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const useStyles = makeStyles((theme: Theme) => {
},
},
listButton: {
height: '65px',
height: '60px',
paddingLeft: '2px',
},
listItemIconDark: {
color: theme.palette.common.white,
Expand Down
5 changes: 1 addition & 4 deletions apps/sensenet/src/components/layout/DesktopLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ const useStyles = makeStyles((theme: Theme) => {
boxSizing: 'border-box',
overflow: 'hidden',
height: '100%',
paddingTop: '10px',
'& > *': {
paddingLeft: `${globals.common.explorePaddingLeft}`,
},
padding: '0px',
},
executeActionPaper: {
height: '100%',
Expand Down
182 changes: 182 additions & 0 deletions apps/sensenet/src/components/settings/settings-table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
import {
IconButton,
makeStyles,
Table,
TableBody,
TableCell,
TableContainer,
TableHead,
TableRow,
} from '@material-ui/core'

import { Delete, Edit, InfoOutlined } from '@material-ui/icons'
import { Settings } from '@sensenet/default-content-types'
import { useRepository } from '@sensenet/hooks-react'
import React, { useContext } from 'react'
import { Link, useHistory } from 'react-router-dom'
import { ResponsivePersonalSettings } from '../../context'
import { useLocalization } from '../../hooks'
import { getPrimaryActionUrl } from '../../services'
import { useDialog } from '../dialogs'

const useStyles = makeStyles(() => ({
tableHead: {
backgroundColor: 'hsl(0deg 0% 24%)',
cursor: 'default',
},
tableHeadCell: {
color: 'white',
fontSize: '1.1rem',
},
stickyTableHeadCell: {
color: 'white',
padding: '0px 1px 0px 0px',
margin: 0,
textAlign: 'center',
maxWidth: '20px',
minWidth: '20px',
},
tableCell: {
verticalAlign: 'middle',
},
tableCellName: {
fontSize: '1.1rem',
},
descriptionCell: {
textAlign: 'left',
whiteSpace: 'normal',
wordBreak: 'break-word',
paddingTop: '12px',
paddingBottom: '12px',
},
stickyCell: {
maxWidth: '32px',
paddingLeft: '16px',
},
tableRow: {
'&:hover': {
backgroundColor: 'rgba(255, 255, 255, 0.08)',
},
},
}))

export const SETUP_DOCS_URL = 'https://docs.sensenet.com/guides/settings/setup'
const hasDocumentation = ['Portal', 'OAuth', 'DocumentPreview', 'OfficeOnline', 'Indexing', 'Sharing']
const isSystemSettings = [
'DocumentPreview',
'OAuth',
'OfficeOnline',
'Indexing',
'Sharing',
'Logging',
'Portal',
'Permission',
'MailProcessor',
'UserProfile',
'ColumnSettings',
'TaskManagement',
'MultiFactorAuthentication',
]
export const createAnchorFromName = (name: string) => `#${name.toLocaleLowerCase()}`

export interface SettingsTableProps {
settings: Settings[]
onContextMenu: (ev: React.MouseEvent, setting: Settings) => void
}

export const SettingsTable = ({ settings, onContextMenu }: SettingsTableProps) => {
const classes = useStyles()
const localization = useLocalization().settings
const repository = useRepository()
const uiSettings = useContext(ResponsivePersonalSettings)
const history = useHistory()
const { openDialog } = useDialog()
const updatedSettings = settings.map((setting: Settings) => {
return {
...setting,
nameToDisplay: setting.Name.split('.')[0]
.replace(/([A-Z])/g, ' $1')
.trim(),
nameToTest: setting.Name.replace(/\.settings/gi, '')
.replace(/\s+/g, '-')
.toLowerCase(),
}
})
const hasDeletableSetting = updatedSettings.some((setting) => !isSystemSettings.includes(setting.Name.split('.')[0]))
return (
<TableContainer>
<Table>
<TableHead className={classes.tableHead}>
<TableRow>
<TableCell className={classes.tableHeadCell}>{localization.name}</TableCell>
<TableCell className={classes.tableHeadCell}>{localization.description}</TableCell>
<TableCell className={classes.stickyTableHeadCell}>{localization.edit}</TableCell>
<TableCell className={classes.stickyTableHeadCell}>{localization.learnMore}</TableCell>
{hasDeletableSetting && (
<TableCell className={classes.stickyTableHeadCell}>{localization.delete}</TableCell>
)}
</TableRow>
</TableHead>
<TableBody>
{updatedSettings.map((setting) => (
<TableRow
key={setting.Id}
className={classes.tableRow}
onContextMenu={(ev) => {
ev.preventDefault()
onContextMenu(ev, setting)
}}>
<TableCell component="th" scope="row" className={`${classes.tableCell} ${classes.tableCellName}`}>
{setting.nameToDisplay}
</TableCell>
<TableCell className={`${classes.tableCell} ${classes.descriptionCell}`}>
{setting.Description || '-'}
</TableCell>
<TableCell className={classes.stickyCell}>
<Link
to={getPrimaryActionUrl({ content: setting, repository, uiSettings, location: history.location })}
style={{ textDecoration: 'none' }}>
<IconButton aria-label={localization.edit} data-test={`${setting.nameToTest}-edit-button`}>
<Edit />
</IconButton>
</Link>
</TableCell>
<TableCell className={classes.stickyCell}>
{hasDocumentation.includes(
(setting.Name || setting.DisplayName || '')?.replace(/\.settings/gi, ''),
) && (
<a
target="_blank"
rel="noopener noreferrer"
href={`${SETUP_DOCS_URL}${createAnchorFromName(setting.Name)}`}>
<IconButton>
<InfoOutlined />
</IconButton>
</a>
)}
</TableCell>
{hasDeletableSetting && (
<TableCell className={classes.stickyCell}>
{!isSystemSettings.includes(setting.Name.split('.')[0]) && (
<IconButton
aria-label={localization.delete}
data-test={`${setting.nameToTest}-delete-button`}
onClick={() => {
openDialog({
name: 'delete',
props: { content: [setting] },
dialogProps: { disableBackdropClick: true, disableEscapeKeyDown: true },
})
}}>
<Delete />
</IconButton>
)}
</TableCell>
)}
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
)
}
33 changes: 16 additions & 17 deletions apps/sensenet/src/components/settings/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { navigateToAction } from '../../services/content-context-service'
import { ContentContextMenu } from '../context-menu/content-context-menu'
import { EditBinary } from '../edit/edit-binary'
import { BrowseView, EditView, NewView, VersionView } from '../view-controls'
import { ContentCard } from './content-card'
import { SettingsTable } from './settings-table'

const Setup = () => {
const repository = useRepository()
Expand All @@ -22,7 +22,10 @@ const Setup = () => {
const [reloadToken, setReloadToken] = useState(Date.now())
const [settings, setSettings] = useState<Settings[]>([])
const [isContextMenuOpened, setIsContextMenuOpened] = useState(false)
const [contextMenuAnchor, setContextMenuAnchor] = useState<HTMLElement | null>(null)
const [contextMenuAnchorPos, setContextMenuAnchorPos] = useState<{ top: number; left: number }>({
top: 0,
left: 0,
})
const [contextMenuItem, setContextMenuItem] = useState<Settings | null>(null)
const requestReload = useCallback(() => setReloadToken(Date.now()), [])

Expand Down Expand Up @@ -97,27 +100,23 @@ const Setup = () => {
content={contextMenuItem ?? settings[0]}
onClose={() => setIsContextMenuOpened(false)}
menuProps={{
anchorEl: contextMenuAnchor,
anchorReference: 'anchorPosition' as const,
anchorPosition: contextMenuAnchorPos,
BackdropProps: {
onClick: () => setIsContextMenuOpened(false),
onContextMenu: (ev) => ev.preventDefault(),
},
}}
/>
{settings.map((s) => {
return (
<ContentCard
settings={s}
key={s.Id}
onContextMenu={(ev) => {
ev.preventDefault()
setContextMenuAnchor((ev.currentTarget as HTMLElement) || null)
setContextMenuItem(s)
setIsContextMenuOpened(true)
}}
/>
)
})}
<SettingsTable
settings={settings}
onContextMenu={(ev, setting) => {
ev.preventDefault()
setContextMenuAnchorPos({ top: ev.clientY, left: ev.clientX })
setContextMenuItem(setting)
setIsContextMenuOpened(true)
}}
/>
</div>
) : null}
</>
Expand Down
4 changes: 2 additions & 2 deletions apps/sensenet/src/components/tree/tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export function Tree({ treeData, itemCount, onItemClick, loadMore, isLoading, ac
)

const nodeItem = (
<Tooltip title={item.Name} placement="bottom">
<Tooltip title={item.Name} key={keyPrefix} placement="bottom">
<ListItem
ref={listItemRef}
className={classes.listItem}
Expand Down Expand Up @@ -219,7 +219,7 @@ export function Tree({ treeData, itemCount, onItemClick, loadMore, isLoading, ac
)
}
return (
<MuiList key={key} style={style}>
<MuiList key={key} style={{ padding: 0 }}>
{renderItem(treeData.children?.[index], index.toString(), 10)}
</MuiList>
)
Expand Down
Loading
Loading