Skip to content

Commit 5746986

Browse files
authored
Add Contenttypes component and add hidden switch. (#1578)
* Add Contenttypes component and add hidden switch. * Add switch style and test.
1 parent f2ed4a5 commit 5746986

File tree

3 files changed

+80
-26
lines changed

3 files changed

+80
-26
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { PATHS, resolvePathParams } from '../../../src/application-paths'
2+
import { pathWithQueryParams } from '../../../src/services/query-string-builder'
3+
4+
const contextMenuItems = ['browse', 'copyto', 'edit', 'moveto', 'delete']
5+
describe('Groups', () => {
6+
before(() => {
7+
cy.login()
8+
cy.visit(
9+
pathWithQueryParams({
10+
path: resolvePathParams({ path: PATHS.contentTypes.appPath, params: { browseType: 'explorer' } }),
11+
newParams: { repoUrl: Cypress.env('repoUrl') },
12+
}),
13+
)
14+
//cy.get('[data-test="groups"]').click()
15+
})
16+
it('Switch should reveal hidden types', () => {
17+
cy.get('[data-test="table-cell-application"]').should('not.exist')
18+
cy.get('[data-test="hidden-type-switch"]')
19+
.click()
20+
.then(() => {
21+
cy.get('[data-test="table-cell-application"]').should('exist')
22+
})
23+
})
24+
})

apps/sensenet/src/components/MainRouter.tsx

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const TrashComponent = lazy(() => import(/* webpackChunkName: "Trash" */ './tras
1616
const EventListComponent = lazy(() => import(/* webpackChunkName: "EventList" */ './event-list/event-list'))
1717
const CustomContent = lazy(() => import(/* webpackChunkName: "CustomContent" */ './content/CustomContent'))
1818
const SettingsComponent = lazy(() => import(/* webpackChunkName: "setup" */ './settings'))
19+
const ContentTypeListComponent = lazy(
20+
() => import(/* webpackChunkName: "contenttypes" */ './content-list/contenttype-list'),
21+
)
1922

2023
export const MainRouter = () => {
2124
return (
@@ -63,32 +66,7 @@ export const MainRouter = () => {
6366
</Route>
6467

6568
<Route path={PATHS.contentTypes.appPath}>
66-
<ContentComponent
67-
rootPath={PATHS.contentTypes.snPath}
68-
fieldsToDisplay={[
69-
{ field: 'DisplayName' },
70-
{ field: 'Name' },
71-
{ field: 'Description' },
72-
{ field: 'ParentTypeName' as any },
73-
{ field: 'ModificationDate' },
74-
{ field: 'ModifiedBy' },
75-
]}
76-
loadChildrenSettings={{
77-
select: [
78-
'DisplayName',
79-
'Name',
80-
'Description',
81-
'ParentTypeName' as any,
82-
'ModificationDate',
83-
'ModifiedBy',
84-
],
85-
query: "+TypeIs:'ContentType' .AUTOFILTERS:OFF",
86-
inlinecount: 'allpages',
87-
top: 1000,
88-
}}
89-
hasTree={false}
90-
alwaysRefreshChildren={true}
91-
/>
69+
<ContentTypeListComponent />
9270
</Route>
9371

9472
<Route path={PATHS.dashboard.appPath}>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React, { lazy, useState } from 'react'
2+
import { PATHS } from '../../application-paths'
3+
import { Switch } from '@sensenet/controls-react'
4+
5+
const ContentComponent = lazy(() => import(/* webpackChunkName: "content" */ '../content'))
6+
7+
const ContentTypeList: React.FC = () => {
8+
const [showHiddenTypes, setShowHiddenTypes] = useState(false)
9+
const renderBeforeGrid = () => {
10+
return (
11+
<div style={{ marginTop: '20px', marginBottom: '20px' }}>
12+
<label htmlFor="showHiddenTypes" style={{ marginRight: '10px' }}>
13+
Show hidden types
14+
</label>
15+
<Switch
16+
data-test="hidden-type-switch"
17+
size="medium"
18+
checked={showHiddenTypes}
19+
onChange={() => setShowHiddenTypes(!showHiddenTypes)}
20+
/>
21+
</div>
22+
)
23+
}
24+
25+
const contentTypeQuery =
26+
"+TypeIs:'ContentType'" + (!showHiddenTypes ? ' -Categories:*HideByDefault*' : '') + ' .AUTOFILTERS:OFF'
27+
28+
return (
29+
<ContentComponent
30+
renderBeforeGrid={renderBeforeGrid}
31+
rootPath={PATHS.contentTypes.snPath}
32+
fieldsToDisplay={[
33+
{ field: 'DisplayName' },
34+
{ field: 'Name' },
35+
{ field: 'Description' },
36+
{ field: 'ParentTypeName' as any },
37+
{ field: 'ModificationDate' },
38+
{ field: 'ModifiedBy' },
39+
]}
40+
loadChildrenSettings={{
41+
select: ['DisplayName', 'Name', 'Description', 'ParentTypeName' as any, 'ModificationDate', 'ModifiedBy'],
42+
query: contentTypeQuery,
43+
inlinecount: 'allpages',
44+
top: 1000,
45+
}}
46+
hasTree={false}
47+
alwaysRefreshChildren={true}
48+
/>
49+
)
50+
}
51+
52+
export default ContentTypeList

0 commit comments

Comments
 (0)