mirror of
https://github.com/alice-lg/alice-lg.git
synced 2024-05-11 05:55:03 +00:00
Merge branch 'feature/ext-theme-texts' into develop
This commit is contained in:
@ -16,6 +16,9 @@ import { Component } from 'react'
|
||||
// Config
|
||||
import { configureAxios } from './config'
|
||||
|
||||
// Content
|
||||
import { contentUpdate } from './components/content/actions'
|
||||
|
||||
// Redux
|
||||
import { createStore, applyMiddleware } from 'redux'
|
||||
import { Provider } from 'react-redux'
|
||||
@ -56,6 +59,7 @@ const browserHistory = useRouterHistory(createHistory)({
|
||||
basename: '/alice'
|
||||
});
|
||||
|
||||
|
||||
// Setup application
|
||||
let store;
|
||||
const routerMiddleware = createRouterMiddleware(browserHistory);
|
||||
@ -73,6 +77,14 @@ if (window.NO_LOG) {
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
// Create extension endpoint:
|
||||
window.Alice = {
|
||||
updateContent: (content) => {
|
||||
store.dispatch(contentUpdate(content));
|
||||
}
|
||||
};
|
||||
|
||||
const history = syncHistoryWithStore(browserHistory, store);
|
||||
|
||||
// Setup axios
|
||||
|
@ -6,7 +6,8 @@ const initialState = {
|
||||
Interface: "interface",
|
||||
Metric: "metric",
|
||||
},
|
||||
prefix_lookup_enabled: false
|
||||
prefix_lookup_enabled: false,
|
||||
content: {}
|
||||
};
|
||||
|
||||
|
||||
|
10
client/components/content/actions.jsx
Normal file
10
client/components/content/actions.jsx
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
export const CONTENT_UPDATE = "@content/CONTENT_UPDATE";
|
||||
|
||||
export function contentUpdate(content) {
|
||||
return {
|
||||
type: CONTENT_UPDATE,
|
||||
payload: content
|
||||
}
|
||||
}
|
||||
|
39
client/components/content/index.jsx
Normal file
39
client/components/content/index.jsx
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
import React from 'react'
|
||||
import {connect} from 'react-redux'
|
||||
|
||||
/*
|
||||
* Content Component
|
||||
*/
|
||||
function ContentComponent(props) {
|
||||
let key = props.id;
|
||||
let defaultValue = props.children;
|
||||
|
||||
if (!key) {
|
||||
return <span>{defaultValue}</span>;
|
||||
}
|
||||
|
||||
// Traverse content by key, if content is found
|
||||
// return content, otherwise fall back to the default
|
||||
let tokens = key.split(".");
|
||||
let resolved = props.content;
|
||||
for (let part of tokens) {
|
||||
resolved = resolved[part];
|
||||
if (!resolved) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!resolved) {
|
||||
resolved = defaultValue;
|
||||
}
|
||||
|
||||
return (<span>{resolved}</span>);
|
||||
}
|
||||
|
||||
export default connect(
|
||||
(state) => ({
|
||||
content: state.content
|
||||
})
|
||||
)(ContentComponent);
|
||||
|
17
client/components/content/reducer.jsx
Normal file
17
client/components/content/reducer.jsx
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Content reducer
|
||||
*/
|
||||
|
||||
import {CONTENT_UPDATE} from './actions'
|
||||
|
||||
const initialState = {};
|
||||
|
||||
export default function reducer(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case CONTENT_UPDATE:
|
||||
return Object.assign({}, state, action.payload);
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
@ -2,6 +2,9 @@
|
||||
import React from 'react'
|
||||
import {Link} from 'react-router'
|
||||
|
||||
import Content from 'components/content'
|
||||
|
||||
|
||||
export default class SidebarHeader extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
@ -12,8 +15,12 @@ export default class SidebarHeader extends React.Component {
|
||||
</Link>
|
||||
</div>
|
||||
<div className="title">
|
||||
<h1>Alice</h1>
|
||||
<p>Your friendly bird looking glass</p>
|
||||
<h1><Content id="header.title">Alice</Content></h1>
|
||||
<p>
|
||||
<Content id="header.tagline">
|
||||
Your friendly bird looking glass.
|
||||
</Content>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -39,7 +39,7 @@ class RouteserversList extends React.Component {
|
||||
|
||||
return (
|
||||
<div className="routeservers-list">
|
||||
<h2>Routeservers</h2>
|
||||
<h2>route servers</h2>
|
||||
<ul>
|
||||
{routeservers}
|
||||
</ul>
|
||||
|
@ -7,6 +7,8 @@ import PageHeader from 'components/page-header'
|
||||
import Lookup from 'components/lookup'
|
||||
import LookupSummary from 'components/lookup/results-summary'
|
||||
|
||||
import Content from 'components/content'
|
||||
|
||||
class LookupView extends React.Component {
|
||||
render() {
|
||||
if (this.props.enabled == false) {
|
||||
@ -42,8 +44,8 @@ export default class Welcome extends React.Component {
|
||||
<PageHeader></PageHeader>
|
||||
|
||||
<div className="jumbotron">
|
||||
<h1>Welcome to Alice!</h1>
|
||||
<p>Your friendly bird looking glass</p>
|
||||
<h1><Content id="welcome.title">Welcome to Alice!</Content></h1>
|
||||
<p><Content id="welcome.tagline">Your friendly bird looking glass</Content></p>
|
||||
</div>
|
||||
|
||||
<LookupPage />
|
||||
|
@ -18,6 +18,9 @@ import errorsReducer
|
||||
import configReducer
|
||||
from 'components/config/reducer'
|
||||
|
||||
import contentReducer
|
||||
from 'components/content/reducer'
|
||||
|
||||
import lookupReducer
|
||||
from 'components/lookup/reducer'
|
||||
|
||||
@ -28,5 +31,6 @@ export default combineReducers({
|
||||
lookup: lookupReducer,
|
||||
errors: errorsReducer,
|
||||
config: configReducer,
|
||||
content: contentReducer,
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user