From 5746986ee6de52ef5e23443841b06a3c7de0427b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20T=C3=B3th?= Date: Tue, 14 Nov 2023 15:56:54 +0100 Subject: [PATCH] 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