Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Feature/Module/connector => "Plugin" #590

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/client/app/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ import createApolloClient from '../../common/createApolloClient';
import createReduxStore, { storeReducer } from '../../common/createReduxStore';
import settings from '../../../settings';
import Routes from './Routes';
import modules from '../modules';
import plugins from '../plugins';

const { hostname, pathname, port } = url.parse(__BACKEND_URL__);

const fetch = createApolloFetch({
uri: hostname === 'localhost' ? '/graphql' : __BACKEND_URL__,
constructOptions: modules.constructFetchOptions
constructOptions: plugins.constructFetchOptions
});
const cache = new InMemoryCache();

for (const middleware of modules.middlewares) {
for (const middleware of plugins.middlewares) {
fetch.batchUse(({ requests, options }, next) => {
options.credentials = 'same-origin';
options.headers = options.headers || {};
Expand All @@ -51,14 +51,14 @@ for (const middleware of modules.middlewares) {
});
}

for (const afterware of modules.afterwares) {
for (const afterware of plugins.afterwares) {
fetch.batchUseAfter(({ response, options }, next) => {
afterware(response, options, next);
});
}

let connectionParams = {};
for (const connectionParam of modules.connectionParams) {
for (const connectionParam of plugins.connectionParams) {
Object.assign(connectionParams, connectionParam());
}

Expand All @@ -76,7 +76,7 @@ wsClient.use([
{
applyMiddleware(operationOptions, next) {
let params = {};
for (const param of modules.connectionParams) {
for (const param of plugins.connectionParams) {
Object.assign(params, param());
}

Expand Down Expand Up @@ -176,7 +176,7 @@ export default class Main extends React.Component {
return this.state.error ? (
<RedBox error={this.state.error} />
) : (
modules.getWrappedRoot(
plugins.getWrappedRoot(
<Provider store={store}>
<ApolloProvider client={client}>
<ConnectedRouter history={history}>{Routes}</ConnectedRouter>
Expand Down
4 changes: 2 additions & 2 deletions src/client/app/Routes.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { TabNavigator } from 'react-navigation';

import modules from '../modules';
import plugins from '../plugins';

const MainScreenNavigator = TabNavigator({
...modules.tabItems
...plugins.tabItems
});

export default MainScreenNavigator;
4 changes: 2 additions & 2 deletions src/client/app/Routes.web.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Switch } from 'react-router-dom';

import modules from '../modules';
import plugins from '../plugins';

export default <Switch>{modules.routes}</Switch>;
export default <Switch>{plugins.routes}</Switch>;
2 changes: 1 addition & 1 deletion src/client/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { render, hydrate } from 'react-native';
// Work around warning about React.hydrate during SSR
import AppContainer from 'react-native-web/dist/apis/AppRegistry/AppContainer';

// Virtual module, see webpack-virtual-modules usage in webpack.run.js
// Virtual module, see webpack-virtual-plugins usage in webpack.run.js
// eslint-disable-next-line import/no-unresolved, import/no-extraneous-dependencies, import/extensions
import 'backend_reload';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Row from 'antd/lib/row';
import Col from 'antd/lib/col';
import MenuItem from './MenuItem';

import modules from '../../../../../../modules';
import plugins from '../../../../../../plugins';
import settings from '../../../../../../../../settings';

class NavBar extends React.Component {
Expand Down Expand Up @@ -36,7 +36,7 @@ class NavBar extends React.Component {
{settings.app.name}
</NavLink>
</MenuItem>
{modules.navItems}
{plugins.navItems}
</Menu>
</Col>
<Col span={10}>
Expand All @@ -47,7 +47,7 @@ class NavBar extends React.Component {
theme="dark"
style={{ lineHeight: '64px', float: 'right' }}
>
{modules.navItemsRight}
{plugins.navItemsRight}
{__DEV__ && (
<MenuItem>
<a href="/graphiql">GraphiQL</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { NavLink } from 'react-router-dom';
import { Container, Navbar, Nav, NavItem } from 'reactstrap';

import modules from '../../../../../../modules';
import plugins from '../../../../../../plugins';
import settings from '../../../../../../../../settings';

const NavBar = () => (
Expand All @@ -12,11 +12,11 @@ const NavBar = () => (
<NavLink to="/" className="navbar-brand">
{settings.app.name}
</NavLink>
{modules.navItems}
{plugins.navItems}
</Nav>

<Nav className="ustify-content-end">
{modules.navItemsRight}
{plugins.navItemsRight}
{(!__PERSIST_GQL__ || __DEV__) && (
<NavItem>
<a href="/graphiql" className="nav-link">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Ionicons } from '@expo/vector-icons';
import { createTabBarIconWrapper } from '../common/components/native';
import Contact from './containers/Contact';

import Feature from '../connector';
import Plugin from '../plugin';

export default new Feature({
export default new Plugin({
tabItem: {
Contact: {
screen: Contact,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import { Route, NavLink } from 'react-router-dom';
import { MenuItem } from '../../modules/common/components/web';
import { MenuItem } from '../../plugins/common/components/web';
import Contact from './containers/Contact';

import Feature, { featureCatalog } from '../connector';
import Plugin, { featureCatalog } from '../plugin';

console.log('catalog:', featureCatalog);

export default new Feature({
export default new Plugin({
route: <Route exact path="/contact" component={Contact} />,
navItem: (
<MenuItem key="contact">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { createTabBarIconWrapper } from '../common/components/native';
import Counter from './containers/Counter';
import reducers from './reducers';

import Feature from '../connector';
import Plugin from '../plugin';

export default new Feature({
export default new Plugin({
tabItem: {
Counter: {
screen: Counter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Route } from 'react-router-dom';
import Counter from './containers/Counter';
import reducers from './reducers';

import Feature from '../connector';
import Plugin from '../plugin';

export default new Feature({
export default new Plugin({
route: <Route exact path="/" component={Counter} />,
reducer: { counter: reducers }
});
4 changes: 2 additions & 2 deletions src/client/modules/index.js → src/client/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import contact from './contact';
import pageNotFound from './pageNotFound';
import './favicon';

import Feature from './connector';
import Plugin from './plugin';

export default new Feature(counter, post, upload, user, subscription, contact, pageNotFound);
export default new Plugin(counter, post, upload, user, subscription, contact, pageNotFound);
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react';
import { Route } from 'react-router-dom';

import PageNotFound from './containers/PageNotFound';
import Feature from '../connector';
import Plugin from '../plugin';

export default new Feature({
export default new Plugin({
route: <Route component={PageNotFound} />
});
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

mutation addComment($input: AddCommentInput!) {
addComment(input: $input) {
... CommentInfo
...CommentInfo
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

mutation addPost($input: AddPostInput!) {
addPost(input: $input) {
... PostInfo
...PostInfo
comments {
... CommentInfo
...CommentInfo
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ subscription onCommentUpdated($postId: Int!) {
id
postId
node {
... CommentInfo
...CommentInfo
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

mutation editComment($input: EditCommentInput!) {
editComment(input: $input) {
... CommentInfo
...CommentInfo
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

mutation editPost($input: EditPostInput!) {
editPost(input: $input) {
... PostInfo
...PostInfo
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

query post($id: Int!) {
post(id: $id) {
... PostInfo
...PostInfo
comments {
... CommentInfo
...CommentInfo
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

subscription onPostUpdated($id: Int!) {
postUpdated(id: $id) {
... PostInfo
...PostInfo
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ query posts($limit: Int!, $after: Int) {
edges {
cursor
node {
... PostInfo
...PostInfo
}
}
pageInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import PostEdit from './containers/PostEdit';

import reducers from './reducers';

import Feature from '../connector';
import Plugin from '../plugin';

class PostListScreen extends React.Component {
static navigationOptions = ({ navigation }) => ({
Expand Down Expand Up @@ -45,7 +45,7 @@ const PostNavigator = StackNavigator({
PostEdit: { screen: PostEditScreen }
});

export default new Feature({
export default new Plugin({
tabItem: {
Post: {
screen: PostNavigator,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react';
import { Route, NavLink } from 'react-router-dom';
import { MenuItem } from '../../modules/common/components/web';
import { MenuItem } from '../../plugins/common/components/web';

import Post from './containers/Post';
import PostEdit from './containers/PostEdit';

import reducers from './reducers';

import Feature from '../connector';
import Plugin from '../plugin';

export default new Feature({
export default new Plugin({
route: [<Route exact path="/posts" component={Post} />, <Route exact path="/post/:id" component={PostEdit} />],
navItem: (
<MenuItem key="/posts">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Subscription Module
# Subscription Plugin

The purpose of this module is to provide a starting point for applications that wish to charge users a monthly subscription fee for access to certain features of the site. This is implemented using [Stripe](https://stripe.com).

### Features Supported
### Plugins Supported

- After registering an account, users will be redirected to the page for subscribing using a credit card.
- Pages protected by `SubscriptionRoute` will be redirected to the subscribe page if no subscription is found.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from 'react';
import { Route, NavLink } from 'react-router-dom';

import { MenuItem } from '../../modules/common/components/web';
import { MenuItem } from '../../plugins/common/components/web';
import Subscription from './containers/Subscription';
import SubscribersOnly from './containers/SubscribersOnly';
import UpdateCard from './containers/UpdateCard';
import { SubscriberRoute } from './containers/Auth';
import reducers from './reducers';

import Feature from '../connector';
import Plugin from '../plugin';

export default new Feature({
export default new Plugin({
route: [
<Route exact path="/subscription" component={Subscription} />,
<SubscriberRoute exact scope="user" path="/subscribers-only" component={SubscribersOnly} />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { createTabBarIconWrapper } from '../common/components/native';
import Upload from './containers/Upload';
import reducers from './reducers';

import Feature from '../connector';
import Plugin from '../plugin';

export default new Feature({
export default new Plugin({
catalogInfo: { upload: true },
tabItem: {
Upload: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react';
import { Route, NavLink } from 'react-router-dom';
import { constructUploadOptions } from 'apollo-fetch-upload';
import { MenuItem } from '../../modules/common/components/web';
import { MenuItem } from '../../plugins/common/components/web';

// Component and helpers
import Upload from './containers/Upload';
import reducers from './reducers';

import Feature from '../connector';
import Plugin from '../plugin';

export default new Feature({
export default new Plugin({
catalogInfo: { upload: true },
route: <Route exact path="/upload" component={Upload} />,
navItem: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
mutation addUser($input: AddUserInput!) {
addUser(input: $input) {
user {
... UserInfo
...UserInfo
}
errors {
field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

query currentUser {
currentUser {
... UserInfo
...UserInfo
}
}
Loading