Skip to content

Commit

Permalink
KEYCLOAK-11268: Change project layout
Browse files Browse the repository at this point in the history
  • Loading branch information
ssilvert committed Jun 7, 2020
1 parent 8a528a0 commit 4c7f4a8
Show file tree
Hide file tree
Showing 57 changed files with 105 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public AbstractAccountPage() {
public UriBuilder createUriBuilder() {
String fragment = null;
if (hashPath != null) {
hashPath.add(0, "app"); // TODO remove this once KEYCLOAK-11268 is resolved
fragment = "/" + String.join("/", hashPath);
}

Expand Down
1 change: 1 addition & 0 deletions themes/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node
web_modules
19 changes: 17 additions & 2 deletions themes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,25 @@

<properties>
<dir.common>src/main/resources/theme/keycloak/common/resources</dir.common>
<dir.account2>src/main/resources/theme/keycloak-preview/account/resources</dir.account2>
<dir.account2>src/main/resources/theme/keycloak-preview/account/src</dir.account2>
<args.npm.install>ci --no-optional --ignore-scripts</args.npm.install>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>${dir.account2}/web_modules</directory>
</fileset>
<fileset>
<directory>${dir.common}/web_modules</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
Expand Down Expand Up @@ -110,9 +123,11 @@
<exclude>**/Gruntfile.js</exclude>
<exclude>**/Gemfile*</exclude>
<exclude>**/.*</exclude>

<!-- Remove once rcue stops shipping this file -->
<exclude>**/git-Logo.svg</exclude>
<exclude>**/keycloak-preview/account/resources/node_modules/**</exclude>

<exclude>**/keycloak-preview/account/src/**</exclude>
</excludes>
</resource>
</resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
document.getElementById("landingLoggedInUser").innerHTML = loggedInUserName('${msg("unknownUser")}', '${msg("fullName")}');
}
loadjs("/app/Main.js");
loadjs("/Main.js");
}).error(function() {
alert('failed to initialize keycloak');
Expand Down Expand Up @@ -231,7 +231,7 @@
<h6>${msg("personalInfoIntroMessage")}</h6>
</div>
<div class="pf-c-card__body pf-c-content">
<h5 id="landingPersonalInfoLink" onclick="toggleReact()"><a href="#/app/personal-info">${msg("personalInfoHtmlTitle")}</a></h5>
<h5 id="landingPersonalInfoLink" onclick="toggleReact()"><a href="#personal-info">${msg("personalInfoHtmlTitle")}</a></h5>
</div>
</div>
</div>
Expand All @@ -242,9 +242,9 @@
<h6>${msg("accountSecurityIntroMessage")}</h6>
</div>
<div class="pf-c-card__body pf-c-content">
<h5 id="landingSigningInLink" onclick="toggleReact()"><a href="#/app/security/signingin">${msg("signingIn")}</a></h5>
<h5 id="landingDeviceActivityLink" onclick="toggleReact()"><a href="#/app/security/device-activity">${msg("deviceActivityHtmlTitle")}</a></h5>
<h5 id="landingLinkedAccountsLink" style="display:none" onclick="toggleReact()"><a href="#/app/security/linked-accounts">${msg("linkedAccountsHtmlTitle")}</a></h5>
<h5 id="landingSigningInLink" onclick="toggleReact()"><a href="#security/signingin">${msg("signingIn")}</a></h5>
<h5 id="landingDeviceActivityLink" onclick="toggleReact()"><a href="#security/device-activity">${msg("deviceActivityHtmlTitle")}</a></h5>
<h5 id="landingLinkedAccountsLink" style="display:none" onclick="toggleReact()"><a href="#security/linked-accounts">${msg("linkedAccountsHtmlTitle")}</a></h5>
</div>
</div>
</div>
Expand All @@ -255,7 +255,7 @@
<h6>${msg("applicationsIntroMessage")}</h6>
</div>
<div class="pf-c-card__body pf-c-content">
<h5 id="landingApplicationsLink" onclick="toggleReact()"><a href="#/app/applications">${msg("applicationsHtmlTitle")}</a></h5>
<h5 id="landingApplicationsLink" onclick="toggleReact()"><a href="#applications">${msg("applicationsHtmlTitle")}</a></h5>
</div>
</div>
</div>
Expand All @@ -266,7 +266,7 @@
<h6>${msg("resourceIntroMessage")}</h6>
</div>
<div class="pf-c-card__body pf-c-content">
<h5 id="landingMyResourcesLink" onclick="toggleReact()"><a href="#/app/resources">${msg("myResources")}</a></h5>
<h5 id="landingMyResourcesLink" onclick="toggleReact()"><a href="#resources">${msg("myResources")}</a></h5>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
# ignore typescript-generated files
# ignore typescript-generated files
*.js
*.js.map

# ignore keycloak.json - we won't need this much longer
keycloak.json

# ignore log files
*.log

# Do not commit, installed at compile time
node_modules

# Don't ignore these
!keycloak.js
!snowpack.config.js
!.eslintrc.js
!WelcomePageScripts.js
!content.js

public/app.css
public/base.css
public/assets/
web_modules/
public/assets/
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var content = [
id: 'personal-info',
path: 'personal-info',
label: 'personalInfoHtmlTitle',
modulePath: '/app/content/account-page/AccountPage.js',
modulePath: '/content/account-page/AccountPage.js',
componentName: 'AccountPage'
},
{
Expand All @@ -15,21 +15,21 @@ var content = [
id: 'signingin',
path: 'security/signingin',
label: 'signingIn',
modulePath: '/app/content/signingin-page/SigningInPage.js',
modulePath: '/content/signingin-page/SigningInPage.js',
componentName: 'SigningInPage',
},
{
id: 'device-activity',
path: 'security/device-activity',
label: 'device-activity',
modulePath: '/app/content/device-activity-page/DeviceActivityPage.js',
modulePath: '/content/device-activity-page/DeviceActivityPage.js',
componentName: 'DeviceActivityPage'
},
{
id: 'linked-accounts',
path: 'security/linked-accounts',
label: 'linkedAccountsHtmlTitle',
modulePath: '/app/content/linked-accounts-page/LinkedAccountsPage.js',
modulePath: '/content/linked-accounts-page/LinkedAccountsPage.js',
componentName: 'LinkedAccountsPage',
hidden: !features.isLinkedAccountsEnabled
}
Expand All @@ -39,14 +39,14 @@ var content = [
id: 'applications',
path: 'applications',
label: 'applications',
modulePath: '/app/content/applications-page/ApplicationsPage.js',
modulePath: '/content/applications-page/ApplicationsPage.js',
componentName: 'ApplicationsPage'
},
{
id: 'resources',
path: 'resources',
label: 'resources',
modulePath: '/app/content/my-resources-page/MyResourcesPage.js',
modulePath: '/content/my-resources-page/MyResourcesPage.js',
componentName: 'MyResourcesPage',
hidden: !features.isMyResourcesEnabled
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
var isWelcomePage = function () {
var winHash = window.location.hash;
return winHash.indexOf('#/app') !== 0;
return winHash === '#/';
};

var toggleReact = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[
"snowpack/assets/babel-plugin.js",
{
"webModulesUrl": "./web_modules",
"webModulesUrl": "../common/keycloak/web_modules",
"moduleResolution": "node"
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Do not commit, installed at compile time
node_modules
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function createNavItems(activePage: PageDef, contentParam: ContentItem[], groupN
groupId={item.groupId}
itemId={item.itemId}
key={item.itemId}
to={'#/app/' + page.path}
to={'#/' + page.path}
isActive={activePage.itemId === item.itemId}
type="button">
{Msg.localize(page.label, page.labelParams)}
Expand Down Expand Up @@ -158,10 +158,10 @@ export function makeRoutes(): React.ReactNode {
const routes: React.ReactElement<Route>[] = pageDefs.map((page: PageDef) => {
if (isModulePageDef(page)) {
const node: React.ReactNode = React.createElement(page.module[page.componentName], {'pageDef': page});
return <Route key={page.itemId} path={'/app/' + page.path} exact render={() => node} />;
return <Route key={page.itemId} path={'/' + page.path} exact render={() => node} />;
} else {
const pageDef: ComponentPageDef = page as ComponentPageDef;
return <Route key={page.itemId} path={'/app/' + page.path} exact component={pageDef.component}/>;
return <Route key={page.itemId} path={'/' + page.path} exact component={pageDef.component}/>;
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PageNavigation extends React.Component<PageNavProps, PageNavState> {
const items: PageDef[] = flattenContent(content);
const firstItem = items[0];
for (let item of items) {
const itemPath: string = '/app/' + item.path;
const itemPath: string = '/' + item.path;
if (itemPath === currentPath) {
return item;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"version": "1.0.0",
"description": "keycloak-preview account management written in React",
"scripts": {
"build": "snowpack && npm run check-types && npm run babel",
"babel": "babel --source-maps --extensions \".js,.ts,.tsx\" app/ --out-dir app/",
"build": "snowpack && npm run check-types && npm run babel && npm run move-web_modules",
"babel": "babel --source-maps --extensions \".js,.ts,.tsx\" app/ --out-dir ../resources/",
"babel:watch": "npm run babel -- --watch",
"check-types": "tsc --noImplicitAny --strictNullChecks --jsx react -p ./",
"check-types:watch": "npm run check-types -- -w",
"lint": "eslint ./app/**/*.ts*"
"lint": "eslint ./app/**/*.ts*",
"move-web_modules": "shx mv web_modules ../../../keycloak/common/resources"
},
"keywords": [],
"author": "Stan Silvert",
Expand Down Expand Up @@ -42,6 +43,7 @@
"eslint-plugin-react": "^7.12.4",
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-postcss": "^2.5.0",
"shx": "^0.3.2",
"snowpack": "^1.7.0",
"typescript": "^3.8.3"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
const copy = require('rollup-plugin-copy');
const postcss = require('rollup-plugin-postcss');

const appDest = '../resources/'
const appDestPublic = appDest + 'public/'

module.exports = {
rollup: {
plugins: [
postcss({
extract: 'public/app.css'
extract: appDestPublic + 'app.css'
}),
copy({
targets: [
{ src: 'node_modules/@patternfly/react-core/dist/styles/base.css', dest: 'public/' },
{ src: 'node_modules/@patternfly/react-core/dist/styles/assets/fonts/overpass-webfont/overpass*.woff2', dest: 'public/assets/fonts/overpass-webfont/'},
{ src: 'node_modules/@patternfly/react-core/dist/styles/assets/pficon/pficon.woff2', dest: 'public/assets/pficon/'},
{ src: 'node_modules/@patternfly/react-core/dist/styles/base.css', dest: appDestPublic },
{ src: 'node_modules/@patternfly/react-core/dist/styles/assets/fonts/overpass-webfont/overpass*.woff2', dest: appDestPublic + 'assets/fonts/overpass-webfont/'},
{ src: 'node_modules/@patternfly/react-core/dist/styles/assets/pficon/pficon.woff2', dest: appDestPublic + 'assets/pficon/'},
],
})
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
parent=base
deprecatedMode=false
scripts=WelcomePageScripts.js content.js
scripts=welcome-page-scripts.js content.js
developmentMode=false

# This is the logo in upper lefthand corner.
Expand Down

0 comments on commit 4c7f4a8

Please sign in to comment.