From f2ed4a5adfb7640324590cfd644102a998bb0a20 Mon Sep 17 00:00:00 2001 From: Adam Hassan Date: Tue, 14 Nov 2023 15:01:35 +0100 Subject: [PATCH 1/5] Fix grid row height (#1574) * virtualized table grid style * fix grid glitch * padding adjust * change order --------- Co-authored-by: vargajoe Co-authored-by: VargaJoe <17780970+VargaJoe@users.noreply.github.com> --- .../components/content-list/content-list.tsx | 15 ++++ apps/sensenet/src/globalStyles.ts | 1 - .../src/ContentList/virtualized-table.tsx | 72 ++++++++++--------- 3 files changed, 53 insertions(+), 35 deletions(-) diff --git a/apps/sensenet/src/components/content-list/content-list.tsx b/apps/sensenet/src/components/content-list/content-list.tsx index 9e0fc154f..b444b473e 100644 --- a/apps/sensenet/src/components/content-list/content-list.tsx +++ b/apps/sensenet/src/components/content-list/content-list.tsx @@ -733,8 +733,23 @@ export const ContentList = (props: Co setActiveContent(rowMouseEventHandlerParams.rowData) handleItemClick(rowMouseEventHandlerParams) }, + rowStyle: { + position: 'static', + top: 'auto', + height: 'auto', + overflow: 'initial', + padding: '5px 0px', + }, onRowDoubleClick: onItemDoubleClickFunc, disableHeader: props.hideHeader, + containerStyle: { + height: '100%', + display: 'flex', + flexDirection: 'column', + overflowY: 'auto', + maxHeight: '100%', + paddingBottom: '15px', + }, }} /> {activeContent ? ( diff --git a/apps/sensenet/src/globalStyles.ts b/apps/sensenet/src/globalStyles.ts index 2fe3fcae4..55eed16b3 100644 --- a/apps/sensenet/src/globalStyles.ts +++ b/apps/sensenet/src/globalStyles.ts @@ -117,7 +117,6 @@ export const useGlobalStyles = makeStyles((theme: Theme) => { }, }, virtualizedCellStyle: { - height: '57px', width: '100%', padding: 0, }, diff --git a/packages/sn-list-controls-react/src/ContentList/virtualized-table.tsx b/packages/sn-list-controls-react/src/ContentList/virtualized-table.tsx index 282ab0ed8..ee153d5dd 100644 --- a/packages/sn-list-controls-react/src/ContentList/virtualized-table.tsx +++ b/packages/sn-list-controls-react/src/ContentList/virtualized-table.tsx @@ -20,6 +20,7 @@ import { Table, TableCellProps, TableCellRenderer, + TableProps, } from 'react-virtualized' import { ColumnSetting, ContentListBaseProps } from './content-list-base-props' import { ActionsCell, DateCell, ReferenceCell, RowCheckbox, VirtualDefaultCell, VirtualDisplayNameCell } from '.' @@ -77,6 +78,39 @@ interface ExtendedGenericContent extends GenericContent { ColumnSettings?: string } +interface snTableProps extends Partial { + /** + * Number of rows in table. + */ + rowCount: number + /** + * Callback responsible for returning a data row given an index. + * ({ index: number }): any + */ + rowHeight: number | ((params: Index) => number) + /** Fixed height of header row */ + headerHeight: number + /** + * Callback responsible for returning a data row given an index. + * ({ index: number }): any + */ + rowGetter: (info: Index) => any + /** + * Callback invoked when a user clicks on a table row. + * ({ index: number }): void + */ + onRowClick?: (info: RowMouseEventHandlerParams) => void + /** + * Callback invoked when a user double-clicks on a table row. + * ({ index: number }): void + */ + onRowDoubleClick?: (info: RowMouseEventHandlerParams) => void + /** + * Disable rendering the header at all + */ + disableHeader?: boolean +} + interface VirtualizedTableProps extends ContentListBaseProps { /** * Contains custom cell template components @@ -94,38 +128,7 @@ interface VirtualizedTableProps extends ContentListBas handleColumnSettingsClick?: () => void - tableProps: { - /** - * Number of rows in table. - */ - rowCount: number - /** - * Callback responsible for returning a data row given an index. - * ({ index: number }): any - */ - rowHeight: number | ((params: Index) => number) - /** Fixed height of header row */ - headerHeight: number - /** - * Callback responsible for returning a data row given an index. - * ({ index: number }): any - */ - rowGetter: (info: Index) => any - /** - * Callback invoked when a user clicks on a table row. - * ({ index: number }): void - */ - onRowClick?: (info: RowMouseEventHandlerParams) => void - /** - * Callback invoked when a user double-clicks on a table row. - * ({ index: number }): void - */ - onRowDoubleClick?: (info: RowMouseEventHandlerParams) => void - /** - * Disable rendering the header at all - */ - disableHeader?: boolean - } + tableProps: snTableProps } const minColumnWith = (field: keyof ExtendedGenericContent) => { @@ -388,10 +391,11 @@ export const VirtualizedTable = (prop direction: 'inherit', outline: 'none', }} - {...tableProps} - rowClassName={getRowClassName}> + rowClassName={getRowClassName} + {...tableProps}> {currentFieldsToDisplay.map((field) => { const currentField = field.field + return ( Date: Tue, 14 Nov 2023 15:56:54 +0100 Subject: [PATCH 2/5] Add Contenttypes component and add hidden switch. (#1578) * Add Contenttypes component and add hidden switch. * Add switch style and test. --- .../cypress/e2e/content-types/switcher.cy.ts | 24 +++++++++ apps/sensenet/src/components/MainRouter.tsx | 30 ++--------- .../content-list/contenttype-list.tsx | 52 +++++++++++++++++++ 3 files changed, 80 insertions(+), 26 deletions(-) create mode 100644 apps/sensenet/cypress/e2e/content-types/switcher.cy.ts create mode 100644 apps/sensenet/src/components/content-list/contenttype-list.tsx diff --git a/apps/sensenet/cypress/e2e/content-types/switcher.cy.ts b/apps/sensenet/cypress/e2e/content-types/switcher.cy.ts new file mode 100644 index 000000000..a2c8c0c55 --- /dev/null +++ b/apps/sensenet/cypress/e2e/content-types/switcher.cy.ts @@ -0,0 +1,24 @@ +import { PATHS, resolvePathParams } from '../../../src/application-paths' +import { pathWithQueryParams } from '../../../src/services/query-string-builder' + +const contextMenuItems = ['browse', 'copyto', 'edit', 'moveto', 'delete'] +describe('Groups', () => { + before(() => { + cy.login() + cy.visit( + pathWithQueryParams({ + path: resolvePathParams({ path: PATHS.contentTypes.appPath, params: { browseType: 'explorer' } }), + newParams: { repoUrl: Cypress.env('repoUrl') }, + }), + ) + //cy.get('[data-test="groups"]').click() + }) + it('Switch should reveal hidden types', () => { + cy.get('[data-test="table-cell-application"]').should('not.exist') + cy.get('[data-test="hidden-type-switch"]') + .click() + .then(() => { + cy.get('[data-test="table-cell-application"]').should('exist') + }) + }) +}) diff --git a/apps/sensenet/src/components/MainRouter.tsx b/apps/sensenet/src/components/MainRouter.tsx index 082355868..e1d207159 100644 --- a/apps/sensenet/src/components/MainRouter.tsx +++ b/apps/sensenet/src/components/MainRouter.tsx @@ -16,6 +16,9 @@ const TrashComponent = lazy(() => import(/* webpackChunkName: "Trash" */ './tras const EventListComponent = lazy(() => import(/* webpackChunkName: "EventList" */ './event-list/event-list')) const CustomContent = lazy(() => import(/* webpackChunkName: "CustomContent" */ './content/CustomContent')) const SettingsComponent = lazy(() => import(/* webpackChunkName: "setup" */ './settings')) +const ContentTypeListComponent = lazy( + () => import(/* webpackChunkName: "contenttypes" */ './content-list/contenttype-list'), +) export const MainRouter = () => { return ( @@ -63,32 +66,7 @@ export const MainRouter = () => { - + diff --git a/apps/sensenet/src/components/content-list/contenttype-list.tsx b/apps/sensenet/src/components/content-list/contenttype-list.tsx new file mode 100644 index 000000000..f440e0c16 --- /dev/null +++ b/apps/sensenet/src/components/content-list/contenttype-list.tsx @@ -0,0 +1,52 @@ +import React, { lazy, useState } from 'react' +import { PATHS } from '../../application-paths' +import { Switch } from '@sensenet/controls-react' + +const ContentComponent = lazy(() => import(/* webpackChunkName: "content" */ '../content')) + +const ContentTypeList: React.FC = () => { + const [showHiddenTypes, setShowHiddenTypes] = useState(false) + const renderBeforeGrid = () => { + return ( +
+ + setShowHiddenTypes(!showHiddenTypes)} + /> +
+ ) + } + + const contentTypeQuery = + "+TypeIs:'ContentType'" + (!showHiddenTypes ? ' -Categories:*HideByDefault*' : '') + ' .AUTOFILTERS:OFF' + + return ( + + ) +} + +export default ContentTypeList From 8d97b921241db30903a06bd419d53629f3d4393a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20T=C3=B3th?= Date: Fri, 17 Nov 2023 11:23:23 +0100 Subject: [PATCH 3/5] Feature flag for Categories field. (#1583) --- .../components/content-list/contenttype-list.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/sensenet/src/components/content-list/contenttype-list.tsx b/apps/sensenet/src/components/content-list/contenttype-list.tsx index f440e0c16..3f5594daf 100644 --- a/apps/sensenet/src/components/content-list/contenttype-list.tsx +++ b/apps/sensenet/src/components/content-list/contenttype-list.tsx @@ -1,12 +1,21 @@ import React, { lazy, useState } from 'react' import { PATHS } from '../../application-paths' import { Switch } from '@sensenet/controls-react' +import { useRepository } from '@sensenet/hooks-react' const ContentComponent = lazy(() => import(/* webpackChunkName: "content" */ '../content')) const ContentTypeList: React.FC = () => { + const repository = useRepository() const [showHiddenTypes, setShowHiddenTypes] = useState(false) + const categoryField = repository.schemas.getFieldTypeByName('Categories') + const isCategoryFieldAvailable = categoryField !== undefined + const renderBeforeGrid = () => { + if (!isCategoryFieldAvailable) { + return <> + } + return (
) diff --git a/apps/sensenet/src/components/search/search-bar.tsx b/apps/sensenet/src/components/search/search-bar.tsx index da96b2dba..d84b38a32 100644 --- a/apps/sensenet/src/components/search/search-bar.tsx +++ b/apps/sensenet/src/components/search/search-bar.tsx @@ -59,15 +59,13 @@ export const SearchBar = () => { className={classes.inputButton} aria-label={localization.clearTerm} title={localization.clearTerm} - onClick={() => null}> - { - if (searchInputRef.current) { - searchInputRef.current.value = '' - } - searchState.setTerm('') - }} - /> + onClick={() => { + if (searchInputRef.current) { + searchInputRef.current.value = '' + } + searchState.setTerm('') + }}> + )}