diff --git a/themes/src/main/resources/theme/keycloak-preview/account/index.ftl b/themes/src/main/resources/theme/keycloak-preview/account/index.ftl index bd00cdadd5..4d0f093c7a 100644 --- a/themes/src/main/resources/theme/keycloak-preview/account/index.ftl +++ b/themes/src/main/resources/theme/keycloak-preview/account/index.ftl @@ -77,7 +77,24 @@ - + + <#if properties.developmentMode?has_content && properties.developmentMode == "true"> + + + + + + + <#if properties.extensions?has_content> + <#list properties.extensions?split(' ') as script> + <#if properties.developmentMode?has_content && properties.developmentMode == "true"> + + <#else> + + + + + @@ -107,7 +124,7 @@ }; keycloak.init({onLoad: 'check-sso'}).success(function(authenticated) { loadjs("/node_modules/react/umd/react.development.js", function() { - loadjs("/node_modules/react-dom/umd/react-dom.development.js", function() { + loadjs("/node_modules/react-dom/umd/react-dom.development.js", function() { loadjs("/node_modules/systemjs/dist/system.src.js", function() { loadjs("/systemjs.config.js", function() { System.import('${resourceUrl}/Main.js').catch(function (err) { diff --git a/themes/src/main/resources/theme/keycloak-preview/account/resources/Main.tsx b/themes/src/main/resources/theme/keycloak-preview/account/resources/Main.tsx new file mode 100644 index 0000000000..269950ffcc --- /dev/null +++ b/themes/src/main/resources/theme/keycloak-preview/account/resources/Main.tsx @@ -0,0 +1,49 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; + +import {HashRouter} from 'react-router-dom'; + +import {App} from './app/App'; + +const e = React.createElement; + +export interface MainProps { +} + +//declare function loadjs(url,loadListener?); + +//loadjs('/js/MyExtension.js'); + +export class Main extends React.Component { + + constructor(props: MainProps) { + super(props); + } + + render() { + return ( + + + + ); + } +}; + +const domContainer = document.querySelector('#main_react_container'); +ReactDOM.render(e(Main), domContainer); \ No newline at end of file diff --git a/themes/src/main/resources/theme/keycloak-preview/account/resources/app/App.tsx b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/App.tsx new file mode 100644 index 0000000000..dc08e92cfb --- /dev/null +++ b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/App.tsx @@ -0,0 +1,67 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as React from 'react'; +import {Route, Link} from 'react-router-dom'; + +import {KeycloakService} from './keycloak-service/keycloak.service'; + +import {Logout} from './widgets/Logout'; +import {AccountPage} from './content/account-page/AccountPage'; +import {ApplicationsPage} from './content/applications-page/ApplicationsPage'; +import {PasswordPage} from './content/password-page/PasswordPage'; +import {ExtensionPages} from './content/extensions/ExtensionPages'; + +declare function toggleReact():void; +declare function isWelcomePage(): boolean; + +export interface AppProps {}; + +export class App extends React.Component { + private kcSvc: KeycloakService = KeycloakService.Instance; + + constructor(props:AppProps) { + super(props); + console.log('Called into App constructor'); + toggleReact(); + } + + render() { + toggleReact(); + + // check login + if (!this.kcSvc.authenticated() && !isWelcomePage()) { + this.kcSvc.login(); + } + + return ( + + + + + ); + } +}; \ No newline at end of file diff --git a/themes/src/main/resources/theme/keycloak-preview/account/resources/app/content/account-page/AccountPage.tsx b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/content/account-page/AccountPage.tsx new file mode 100644 index 0000000000..a17684a051 --- /dev/null +++ b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/content/account-page/AccountPage.tsx @@ -0,0 +1,35 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as React from 'react'; + +export interface AccountPageProps { +} + +export class AccountPage extends React.Component { + + constructor(props: AccountPageProps) { + super(props); + } + + render() { + return ( +
+

Hello Account Page

+
+ ); + } +}; \ No newline at end of file diff --git a/themes/src/main/resources/theme/keycloak-preview/account/resources/app/content/applications-page/ApplicationsPage.tsx b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/content/applications-page/ApplicationsPage.tsx new file mode 100644 index 0000000000..258cf10bd9 --- /dev/null +++ b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/content/applications-page/ApplicationsPage.tsx @@ -0,0 +1,35 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as React from 'react'; + +export interface ApplicationsPageProps { +} + +export class ApplicationsPage extends React.Component { + + constructor(props: ApplicationsPageProps) { + super(props); + } + + render() { + return ( +
+

Hello Applications Page

+
+ ); + } +}; \ No newline at end of file diff --git a/themes/src/main/resources/theme/keycloak-preview/account/resources/app/content/extensions/ExtensionPages.tsx b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/content/extensions/ExtensionPages.tsx new file mode 100644 index 0000000000..64749ebb4f --- /dev/null +++ b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/content/extensions/ExtensionPages.tsx @@ -0,0 +1,48 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as React from 'react'; +import {Route, Link} from 'react-router-dom'; + +export interface PageDef { + path: string, + label: string, + component: React.ComponentType, +} + +declare const extensionPages: PageDef[]; + +export class ExtensionPages { // extends React.Component { + + public static get Links(): React.ReactElement { + if (typeof extensionPages === 'undefined') return (); + + const links: React.ReactElement[] = extensionPages.map((page: PageDef) => + {page.label} + ); + return ({links}); + } + + public static get Routes(): React.ReactElement { + if (typeof extensionPages === 'undefined') return (); + + const routes: React.ReactElement[] = extensionPages.map((page) => + + ); + return ({routes}); + } + +}; \ No newline at end of file diff --git a/themes/src/main/resources/theme/keycloak-preview/account/resources/app/content/password-page/PasswordPage.tsx b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/content/password-page/PasswordPage.tsx new file mode 100644 index 0000000000..59b5f8bc0d --- /dev/null +++ b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/content/password-page/PasswordPage.tsx @@ -0,0 +1,35 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as React from 'react'; + +export interface PasswordPageProps { +} + +export class PasswordPage extends React.Component { + + constructor(props: PasswordPageProps) { + super(props); + } + + render() { + return ( +
+

Hello Password Page

+
+ ); + } +}; \ No newline at end of file diff --git a/themes/src/main/resources/theme/keycloak-preview/account/resources/app/widgets/Logout.tsx b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/widgets/Logout.tsx index 4032ea9886..2051f83922 100644 --- a/themes/src/main/resources/theme/keycloak-preview/account/resources/app/widgets/Logout.tsx +++ b/themes/src/main/resources/theme/keycloak-preview/account/resources/app/widgets/Logout.tsx @@ -18,6 +18,8 @@ import * as React from 'react'; import {Link} from 'react-router-dom'; import {KeycloakService} from '../keycloak-service/keycloak.service'; +declare const baseUrl; + export interface LogoutProps { } @@ -27,16 +29,13 @@ export class Logout extends React.Component { super(props); } - handleLogout = () => { - KeycloakService.Instance.logout(); + private handleLogout() { + KeycloakService.Instance.logout(baseUrl); } render() { - return ( -
- Logout -
+ Logout ); } }