add /nexblock?view=X&url=y page for rendering single nexblock

This commit is contained in:
Kyle McCormick
2021-02-10 14:51:19 -05:00
parent 6d35d33559
commit 7ecc0e7929
2 changed files with 29 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ import { TabContainer } from './tab-page';
import { fetchDatesTab, fetchOutlineTab, fetchProgressTab } from './course-home/data';
import { fetchCourse } from './courseware/data';
import initializeStore from './store';
import NexBlockPage from './plugin-test/NexBlockPage';
import PluginTestPage from './plugin-test/PluginTestPage';
subscribe(APP_READY, () => {
@@ -34,7 +35,8 @@ subscribe(APP_READY, () => {
<AppProvider store={initializeStore()}>
<UserMessagesProvider>
<Switch>
<Route exact path="/" component={PluginTestPage} />
<Route exact path="/plugintest" component={PluginTestPage} />
<Route exact path="/nexblock" component={NexBlockPage} />
<PageRoute path="/redirect" component={CoursewareRedirectLandingPage} />
<PageRoute path="/course/:courseId/home">
<TabContainer tab="outline" fetch={fetchOutlineTab} slice="courseHome">

View File

@@ -0,0 +1,26 @@
import React, { Component } from 'react';
import Plugin, { COMPONENT } from './Plugin';
const FALLBACK_URL = 'http://localhost:7331/remoteEntry.js';
const FALLBACK_VIEW = 'PluginOne';
// eslint-disable-next-line react/prefer-stateless-function
export default class NexBlockPage extends Component {
render() {
// eslint-disable-next-line react/prop-types
const query = new URLSearchParams(this.props.location.search);
const plugin = {
url: query.get('url') ?? FALLBACK_URL,
scope: 'plugin',
module: `./${query.get('view') ?? FALLBACK_VIEW}`,
type: COMPONENT,
};
return (
<div style={{ marginTop: '2em' }}>
<Plugin plugin={plugin} />
</div>
);
}
}