Skip to content

Commit

Permalink
fix: updating modules to match the new format from frontend-base
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjoy committed Oct 2, 2024
1 parent ffe6478 commit e4eb2b1
Show file tree
Hide file tree
Showing 19 changed files with 410 additions and 108 deletions.
280 changes: 236 additions & 44 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
"module": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"/dist",
"/scss/**/*.scss"
"/dist"
],
"config": {
"name": "baseTest",
"exposes": {
"./ModuleOne": "./src/ModuleOne",
"./ModuleTwo": "./src/ModuleTwo",
"./ModuleThree": "./src/ModuleThree"
"./ModuleOne": "./src/module-one",
"./ModuleTwo": "./src/module-two",
"./ModuleThree": "./src/module-three"
}
},
"browserslist": [
"extends @edx/browserslist-config"
],
"scripts": {
"temp:pack-it": "npm run pack frontend-project-test && npm run pack frontend-project-module-test",
"build:module": "PORT=8082 openedx build:module",
"dev": "PORT=8082 openedx dev",
"dev:module": "PORT=8082 openedx dev:module",
Expand Down
27 changes: 0 additions & 27 deletions src/ModuleThree.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions src/index.jsx

This file was deleted.

3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as moduleOneConfig } from './module-one';
export { default as moduleThreeConfig } from './module-three';
export { default as moduleTwoConfig } from './module-two';
20 changes: 7 additions & 13 deletions src/ModuleOne.tsx → src/module-one/ModuleOne.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
import { getConfig } from '@openedx/frontend-base';
import { Container } from '@openedx/paragon';
import { Link, Route, Routes } from 'react-router-dom';
import { Link, Outlet } from 'react-router-dom';

import './moduleOne.css';

const ModuleOne = () => (
<main>
<Container className="py-5">
<h1>Module One</h1>
<h1 className="one">Module One</h1>
<p>This module is acting as a homepage because it was mounted at the root.</p>
<p>The site's name is {getConfig().SITE_NAME}!</p>
<ul>
<li><Link to="child">View the child page content</Link></li>
<li><Link to="/two">View Module Two</Link></li>
<li><Link to="/three">View Module THree</Link></li>
<li><Link to="/three">View Module Three</Link></li>
</ul>
<Routes>
<Route path="child" element={
<div>You're viewing the content of the child page at /child</div>
}/>
</Routes>
<Outlet />
<p>Module one content after the outlet.</p>
</Container>
</main>
);

export default ModuleOne;

export const config = {
path: 'one',
component: ModuleOne,
};
5 changes: 5 additions & 0 deletions src/module-one/ModuleOneChild.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function ModuleOneChild() {
return (
<div>You're viewing the content of the child page at /child</div>
)
}
31 changes: 31 additions & 0 deletions src/module-one/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ApplicationModuleConfig, HeaderTypes } from "@openedx/frontend-base";

const config: ApplicationModuleConfig = {
routes: [
{
path: '/',
lazy: async () => {
const { default: Component } = await import('./ModuleOne');
return {
Component,
handle: {
headerId: HeaderTypes.DEFAULT,
}
}
},
children: [
{
path: 'child',
lazy: async () => {
const { default: Component } = await import('./ModuleOneChild');
return {
Component,
}
}
}
]
}
]
};

export default config;
4 changes: 4 additions & 0 deletions src/module-one/moduleOne.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
h1.one {
color: red;
text-decoration: underline wavy;
}
21 changes: 21 additions & 0 deletions src/module-three/ModuleThree.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Container } from '@openedx/paragon';
import { Link, Outlet } from 'react-router-dom';

import './moduleThree.scss';

export default function ModuleThree() {
return (
<main>
<Container className="py-5">
<h1 className="three">Module Three</h1>
<ul>
<li><Link to="child">View the Module Three child page content</Link></li>
<li><Link to="/">View Module One</Link></li>
<li><Link to="/two">View Module Two</Link></li>
</ul>
<Outlet />
<p>Module three content after the outlet.</p>
</Container>
</main>
)
}
5 changes: 5 additions & 0 deletions src/module-three/ModuleThreeChild.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function ModuleThreeChild() {
return (
<div>You're viewing the content of the module three child page at /child</div>
)
}
31 changes: 31 additions & 0 deletions src/module-three/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ApplicationModuleConfig, HeaderTypes } from "@openedx/frontend-base";

const config: ApplicationModuleConfig = {
routes: [
{
path: 'three',
lazy: async () => {
const { default: Component } = await import('./ModuleThree');
return {
Component,
handle: {
headerId: HeaderTypes.STUDIO,
}
}
},
children: [
{
path: 'child',
lazy: async () => {
const { default: Component } = await import('./ModuleThreeChild');
return {
Component,
}
}
}
]
}
]
};

export default config;
4 changes: 4 additions & 0 deletions src/module-three/moduleThree.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
h1.three {
color: green;
text-decoration: underline double;
}
4 changes: 4 additions & 0 deletions src/module-three/moduleThree.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 6 additions & 12 deletions src/ModuleTwo.tsx → src/module-two/ModuleTwo.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
import { Container } from '@openedx/paragon';
import { Link, Route, Routes } from 'react-router-dom';
import { Link, Outlet } from 'react-router-dom';

import './moduleTwo.scss';

const ModuleTwo = () => (
<main>
<Container className="py-5">
<h1>Module Two</h1>
<h1 className="two">Module Two</h1>
<ul>
<li><Link to="child">View the Module Two child page content</Link></li>
<li><Link to="/">View Module One</Link></li>
<li><Link to="/three">View Module Three</Link></li>
</ul>
<Routes>
<Route path="child" element={
<div>You're viewing the child page of Module Two.</div>
} />
</Routes>
<Outlet />
<p>Module two content after the outlet.</p>
</Container>
</main>
);

export default ModuleTwo;

export const config = {
path: 'two',
component: ModuleTwo,
};
5 changes: 5 additions & 0 deletions src/module-two/ModuleTwoChild.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function ModuleTwoChild() {
return (
<div>You're viewing the content of the module two child page at /child</div>
)
}
34 changes: 34 additions & 0 deletions src/module-two/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ApplicationModuleConfig, HeaderTypes } from "@openedx/frontend-base";

const config: ApplicationModuleConfig = {
routes: [
{
path: 'two',
lazy: async () => {
const { default: Component } = await import('./ModuleTwo');
return {
Component,
handle: {
headerId: HeaderTypes.LEARNING,
}
}
},
children: [
{
path: 'child',
lazy: async () => {
const { default: Component } = await import('./ModuleTwoChild');
return {
Component,
handle: {
headerId: HeaderTypes.DEFAULT
}
}
}
}
]
}
],
};

export default config;
4 changes: 4 additions & 0 deletions src/module-two/moduleTwo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
h1.two {
color: blue;
text-decoration: underline dashed;
}
9 changes: 5 additions & 4 deletions test.site.config.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { SiteConfig } from '@openedx/frontend-base';
import { EnvironmentTypes, ProjectSiteConfig } from '@openedx/frontend-base';

const config: SiteConfig = {
const config: ProjectSiteConfig = {
apps: [],
ACCESS_TOKEN_COOKIE_NAME: 'edx-jwt-cookie-header-payload',
BASE_URL: 'http://localhost:8080',
ACCOUNT_PROFILE_URL: 'http://localhost:1995',
Expand All @@ -17,12 +18,12 @@ const config: SiteConfig = {
FAVICON_URL: 'https://edx-cdn.org/v3/default/favicon.ico',
MARKETING_SITE_BASE_URL: 'http://localhost:18000',
ORDER_HISTORY_URL: 'http://localhost:1996/orders',
REFRESH_ACCESS_TOKEN_ENDPOINT: 'http://localhost:18000/login_refresh',
REFRESH_ACCESS_TOKEN_API_PATH: '/login_refresh',
SEGMENT_KEY: '',
SITE_NAME: 'localhost',
USER_INFO_COOKIE_NAME: 'edx-user-info',
APP_ID: 'base-test',
ENVIRONMENT: 'dev',
ENVIRONMENT: EnvironmentTypes.TEST,
ACCOUNT_SETTINGS_URL: 'http://localhost:1997',
DISCOVERY_API_BASE_URL: 'http://localhost:18381',
IGNORED_ERROR_REGEX: null,
Expand Down

0 comments on commit e4eb2b1

Please sign in to comment.