theme.keycloak.v2.account.resources.ContentPages.js.map Maven / Gradle / Ivy
{"version":3,"file":"ContentPages.js","names":["React","Route","Switch","NavItem","NavExpandable","Msg","PageNotFound","ForbiddenPage","isModulePageDef","item","modulePath","undefined","isExpansion","contentItem","content","groupId","group","itemId","isChildOf","parent","child","createNavItems","activePage","contentParam","groupNum","createElement","Fragment","links","map","navLinkId","id","key","title","localize","label","labelParams","isExpanded","page","to","path","isActive","type","makeNavItems","console","log","setIds","expansionGroupNum","i","length","initGroupAndItemIds","flattenContent","pageDefs","flat","push","makeRoutes","routes","node","module","componentName","exact","render","pageDef","component"],"sources":["../src/app/ContentPages.tsx"],"sourcesContent":["/*\n * Copyright 2019 Red Hat, Inc. and/or its affiliates.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as React from 'react';\nimport {Route, Switch} from 'react-router-dom';\nimport {NavItem, NavExpandable} from '@patternfly/react-core';\nimport {Msg} from './widgets/Msg';\nimport {PageNotFound} from './content/page-not-found/PageNotFound';\nimport { ForbiddenPage } from './content/forbidden-page/ForbiddenPage';\n\nexport interface ContentItem {\n id?: string;\n label: string;\n labelParams?: string[];\n hidden?: string;\n groupId: string; // computed value\n itemId: string; // computed value\n};\n\nexport interface Expansion extends ContentItem {\n content: ContentItem[];\n}\n\nexport interface PageDef extends ContentItem {\n path: string;\n}\n\nexport interface ComponentPageDef extends PageDef {\n component: React.ComponentType;\n}\n\nexport interface ModulePageDef extends PageDef {\n modulePath: string;\n componentName: string;\n module: React.Component; // computed value\n}\n\nexport function isModulePageDef(item: ContentItem): item is ModulePageDef {\n return (item as ModulePageDef).modulePath !== undefined;\n}\n\nexport function isExpansion(contentItem: ContentItem): contentItem is Expansion {\n return (contentItem as Expansion).content !== undefined;\n}\n\ndeclare const content: ContentItem[];\n\nfunction groupId(group: number): string {\n return 'grp-' + group;\n}\n\nfunction itemId(group: number, item: number): string {\n return 'grp-' + group + '_itm-' + item;\n}\n\nfunction isChildOf(parent: Expansion, child: PageDef): boolean {\n for (var item of parent.content) {\n if (isExpansion(item) && isChildOf(item, child)) return true;\n if (parent.groupId === child.groupId) return true;\n }\n\n return false;\n}\n\nfunction createNavItems(activePage: PageDef, contentParam: ContentItem[], groupNum: number): React.ReactNode {\n if (typeof content === 'undefined') return ( );\n\n const links: React.ReactElement[] = contentParam.map((item: ContentItem) => {\n const navLinkId = `nav-link-${item.id}`;\n if (isExpansion(item)) {\n return \n {createNavItems(activePage, item.content, groupNum + 1)}\n \n } else {\n const page: PageDef = item as PageDef;\n return \n {Msg.localize(page.label, page.labelParams)}\n \n }\n });\n\n return ({links} );\n}\n\nexport function makeNavItems(activePage: PageDef): React.ReactNode {\n console.log({activePage});\n return createNavItems(activePage, content, 0);\n}\n\nfunction setIds(contentParam: ContentItem[], groupNum: number): number {\n if (typeof contentParam === 'undefined') return groupNum;\n let expansionGroupNum = groupNum;\n\n for (let i = 0; i < contentParam.length; i++) {\n const item: ContentItem = contentParam[i];\n if (isExpansion(item)) {\n item.itemId = itemId(groupNum, i);\n expansionGroupNum = expansionGroupNum + 1;\n item.groupId = groupId(expansionGroupNum);\n expansionGroupNum = setIds(item.content, expansionGroupNum);\n console.log('currentGroup=' + (expansionGroupNum));\n } else {\n item.groupId = groupId(groupNum);\n item.itemId = itemId(groupNum, i);\n }\n };\n\n return expansionGroupNum;\n}\n\nexport function initGroupAndItemIds(): void {\n setIds(content, 0);\n console.log({content});\n}\n\n// get rid of Expansions and put all PageDef items into a single array\nexport function flattenContent(pageDefs: ContentItem[]): PageDef[] {\n const flat: PageDef[] = [];\n\n for (let item of pageDefs) {\n if (isExpansion(item)) {\n flat.push(...flattenContent(item.content));\n } else {\n flat.push(item as PageDef);\n }\n }\n\n return flat;\n}\n\nexport function makeRoutes(): React.ReactNode {\n if (typeof content === 'undefined') return ();\n\n const pageDefs: PageDef[] = flattenContent(content);\n\n const routes: React.ReactElement[] = pageDefs.map((page: PageDef) => {\n if (isModulePageDef(page)) {\n const node: React.ReactNode = React.createElement(page.module[page.componentName], {'pageDef': page});\n return node} />;\n } else {\n const pageDef: ComponentPageDef = page as ComponentPageDef;\n return ;\n }\n });\n\n return (\n {routes}\n \n \n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK;AACjB,SAAQC,KAAK,EAAEC,MAAM;AACrB,SAAQC,OAAO,EAAEC,aAAa;AAC9B,SAAQC,GAAG;AACX,SAAQC,YAAY;AACpB,SAASC,aAAa;AASrB;AAoBD,OAAO,SAASC,eAAeA,CAACC,IAAiB,EAAyB;EACtE,OAAQA,IAAI,CAAmBC,UAAU,KAAKC,SAAS;AAC3D;AAEA,OAAO,SAASC,WAAWA,CAACC,WAAwB,EAA4B;EAC5E,OAAQA,WAAW,CAAeC,OAAO,KAAKH,SAAS;AAC3D;AAIA,SAASI,OAAOA,CAACC,KAAa,EAAU;EACpC,OAAO,MAAM,GAAGA,KAAK;AACzB;AAEA,SAASC,MAAMA,CAACD,KAAa,EAAEP,IAAY,EAAU;EACjD,OAAO,MAAM,GAAGO,KAAK,GAAG,OAAO,GAAGP,IAAI;AAC1C;AAEA,SAASS,SAASA,CAACC,MAAiB,EAAEC,KAAc,EAAW;EAC3D,KAAK,IAAIX,IAAI,IAAIU,MAAM,CAACL,OAAO,EAAE;IAC7B,IAAIF,WAAW,CAACH,IAAI,CAAC,IAAIS,SAAS,CAACT,IAAI,EAAEW,KAAK,CAAC,EAAE,OAAO,IAAI;IAC5D,IAAID,MAAM,CAACJ,OAAO,KAAKK,KAAK,CAACL,OAAO,EAAE,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