mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-15 17:50:48 +02:00
minor cleanups, move header to common component
This commit is contained in:
parent
cde4f510df
commit
21012adc08
@ -3,7 +3,7 @@ import React, { Component, PureComponent } from 'react';
|
|||||||
|
|
||||||
import { Link } from 'react-router';
|
import { Link } from 'react-router';
|
||||||
import { Grid, Cell, List, ListItem, ListItemContent, Textfield, Icon } from 'react-mdl';
|
import { Grid, Cell, List, ListItem, ListItemContent, Textfield, Icon } from 'react-mdl';
|
||||||
|
import { HeaderTitle } from '../common';
|
||||||
|
|
||||||
class StatefulTextfield extends Component {
|
class StatefulTextfield extends Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
@ -51,8 +51,7 @@ class ClientStrategies extends PureComponent {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h5><Icon name={icon} /> {appName}</h5>
|
<HeaderTitle title={<span><Icon name={icon} /> {appName}</span>} subtitle={description} />
|
||||||
{description && <p>{description} </p>}
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Cell col={3}>
|
<Cell col={3}>
|
||||||
<h6> Toggles</h6>
|
<h6> Toggles</h6>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { AppsLinkList } from '../common';
|
import { AppsLinkList, HeaderTitle } from '../common';
|
||||||
|
|
||||||
class ClientStrategies extends Component {
|
class ClientStrategies extends Component {
|
||||||
|
|
||||||
@ -17,8 +17,7 @@ class ClientStrategies extends Component {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h5>Applications</h5>
|
<HeaderTitle title="Applications" />
|
||||||
<hr />
|
|
||||||
<AppsLinkList apps={applications} />
|
<AppsLinkList apps={applications} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { DataTable, TableHeader, Chip, Switch, IconButton } from 'react-mdl';
|
import { Link } from 'react-router';
|
||||||
|
import { DataTable, TableHeader, IconButton, Icon } from 'react-mdl';
|
||||||
|
import { HeaderTitle } from '../common';
|
||||||
|
|
||||||
class ArchiveList extends Component {
|
class ArchiveList extends Component {
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
@ -13,8 +15,9 @@ class ArchiveList extends Component {
|
|||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h6>Toggle Archive</h6>
|
<HeaderTitle title="Toggle Archive" />
|
||||||
|
{
|
||||||
|
archive.length > 0 ?
|
||||||
<DataTable
|
<DataTable
|
||||||
rows={archive}
|
rows={archive}
|
||||||
style={{ width: '100%' }}>
|
style={{ width: '100%' }}>
|
||||||
@ -24,7 +27,12 @@ class ArchiveList extends Component {
|
|||||||
<TableHeader style={{ width: '25px' }} name="enabled" cellFormatter={(v) => (v ? 'Yes' : '-')}>Enabled</TableHeader>
|
<TableHeader style={{ width: '25px' }} name="enabled" cellFormatter={(v) => (v ? 'Yes' : '-')}>Enabled</TableHeader>
|
||||||
<TableHeader name="name">Toggle name</TableHeader>
|
<TableHeader name="name">Toggle name</TableHeader>
|
||||||
<TableHeader numeric name="createdAt">Created</TableHeader>
|
<TableHeader numeric name="createdAt">Created</TableHeader>
|
||||||
</DataTable>
|
</DataTable> :
|
||||||
|
<div style={{ textAlign: 'center' }}>
|
||||||
|
<Icon name="report" style={{ color: '#aaa', fontSize: '40px' }}/><br />
|
||||||
|
No archived feature toggles, go see <Link to="/features">active toggles here</Link>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
const { List, ListItem, ListItemContent } = require('react-mdl');
|
const {
|
||||||
|
List, ListItem, ListItemContent,
|
||||||
|
Grid, Cell,
|
||||||
|
Button, Icon,
|
||||||
|
} = require('react-mdl');
|
||||||
const { Link } = require('react-router');
|
const { Link } = require('react-router');
|
||||||
|
|
||||||
export const AppsLinkList = ({ apps }) => (
|
export const AppsLinkList = ({ apps }) => (
|
||||||
@ -16,3 +20,26 @@ export const AppsLinkList = ({ apps }) => (
|
|||||||
</List>
|
</List>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const HeaderTitle = ({ title, actions, subtitle }) => (
|
||||||
|
<Grid style={{ borderBottom: '1px solid #f1f1f1', marginBottom: '10px' }}>
|
||||||
|
<Cell col={6}>
|
||||||
|
<h4 className="mdl-typography--subhead">{title}</h4>
|
||||||
|
{subtitle && <small>{subtitle}</small>}
|
||||||
|
</Cell>
|
||||||
|
<Cell col={6} style={{ textAlign: 'right' }}>{actions}</Cell>
|
||||||
|
</Grid>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const FormButtons = ({ submitText = 'Create', onCancel }) => (
|
||||||
|
<div>
|
||||||
|
<Button type="submit" ripple raised primary icon="add">
|
||||||
|
<Icon name="add" />
|
||||||
|
{ submitText }
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button type="cancel" ripple raised onClick={onCancel} style={{ float: 'right' }}>
|
||||||
|
<Icon name="cancel" />
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
import { Textfield, Button, Switch, Icon } from 'react-mdl';
|
import { Textfield, Switch } from 'react-mdl';
|
||||||
import StrategiesSection from './strategies-section-container';
|
import StrategiesSection from './strategies-section-container';
|
||||||
|
|
||||||
|
import { FormButtons } from '../../common';
|
||||||
|
|
||||||
const trim = (value) => {
|
const trim = (value) => {
|
||||||
if (value && value.trim) {
|
if (value && value.trim) {
|
||||||
return value.trim();
|
return value.trim();
|
||||||
@ -77,15 +79,10 @@ class AddFeatureToggleComponent extends Component {
|
|||||||
removeStrategy={removeStrategy} />
|
removeStrategy={removeStrategy} />
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<Button type="submit" ripple raised primary icon="add">
|
<FormButtons
|
||||||
<Icon name="add" />
|
submitText={editmode ? 'Update' : 'Create'}
|
||||||
{editmode ? 'Update' : 'Create'}
|
onCancel={onCancel}
|
||||||
</Button>
|
/>
|
||||||
|
|
||||||
<Button type="cancel" ripple raised onClick={onCancel} style={{ float: 'right' }}>
|
|
||||||
<Icon name="cancel" />
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,7 @@ class History extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<HistoryList history={history} title="Last 100 changes" />
|
||||||
<h5>Last 100 changes</h5>
|
|
||||||
<HistoryList history={history} />
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import React, { Component } from 'react';
|
|||||||
import HistoryItemDiff from './history-item-diff';
|
import HistoryItemDiff from './history-item-diff';
|
||||||
import HistoryItemJson from './history-item-json';
|
import HistoryItemJson from './history-item-json';
|
||||||
import { Switch, Table, TableHeader, Grid, Cell } from 'react-mdl';
|
import { Switch, Table, TableHeader, Grid, Cell } from 'react-mdl';
|
||||||
|
import { HeaderTitle } from '../common';
|
||||||
|
|
||||||
import style from './history.scss';
|
import style from './history.scss';
|
||||||
|
|
||||||
@ -41,11 +42,7 @@ class HistoryList extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={style.history}>
|
<div className={style.history}>
|
||||||
<Grid>
|
<HeaderTitle title={this.props.title} actions={<Switch checked={showData} onChange={this.toggleShowDiff.bind(this)}>Show full events</Switch>}/>
|
||||||
<Cell>
|
|
||||||
<Switch checked={showData} onChange={this.toggleShowDiff.bind(this)}>Show full events</Switch>
|
|
||||||
</Cell>
|
|
||||||
</Grid>
|
|
||||||
{entries}
|
{entries}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -20,10 +20,9 @@ class HistoryListToggle extends Component {
|
|||||||
}
|
}
|
||||||
const { history, toggleName } = this.props;
|
const { history, toggleName } = this.props;
|
||||||
return (
|
return (
|
||||||
<div>
|
<ListComponent
|
||||||
<h5>Showing history for toggle: <Link to={`/features/edit/${toggleName}`}><strong>{toggleName}</strong></Link></h5>
|
history={history}
|
||||||
<ListComponent history={history} />
|
title={<span>Showing history for toggle: <Link to={`/features/edit/${toggleName}`}><strong>{toggleName}</strong></Link></span>}/>
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import React, { PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
|
|
||||||
import { Textfield, Button, IconButton } from 'react-mdl';
|
import { Textfield, IconButton } from 'react-mdl';
|
||||||
|
import { HeaderTitle, FormButtons } from '../common';
|
||||||
|
|
||||||
|
|
||||||
const trim = (value) => {
|
const trim = (value) => {
|
||||||
if (value && value.trim) {
|
if (value && value.trim) {
|
||||||
@ -35,6 +37,7 @@ const AddStrategy = ({
|
|||||||
onSubmit,
|
onSubmit,
|
||||||
}) => (
|
}) => (
|
||||||
<form onSubmit={onSubmit(input)}>
|
<form onSubmit={onSubmit(input)}>
|
||||||
|
<HeaderTitle title="Create new strategy"/>
|
||||||
<section>
|
<section>
|
||||||
<Textfield label="Strategy name"
|
<Textfield label="Strategy name"
|
||||||
name="name" required
|
name="name" required
|
||||||
@ -63,11 +66,9 @@ const AddStrategy = ({
|
|||||||
<br />
|
<br />
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<section>
|
<FormButtons
|
||||||
<Button type="submit" raised primary >Create</Button>
|
onCancel={onCancel}
|
||||||
|
/>
|
||||||
<Button type="cancel" raised onClick={onCancel}>Cancel</Button>
|
|
||||||
</section>
|
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ import React, { Component } from 'react';
|
|||||||
import { Link } from 'react-router';
|
import { Link } from 'react-router';
|
||||||
|
|
||||||
import { List, ListItem, ListItemContent, IconButton, Chip } from 'react-mdl';
|
import { List, ListItem, ListItemContent, IconButton, Chip } from 'react-mdl';
|
||||||
|
import { HeaderTitle } from '../common';
|
||||||
|
|
||||||
class StrategiesListComponent extends Component {
|
class StrategiesListComponent extends Component {
|
||||||
|
|
||||||
@ -24,10 +25,7 @@ class StrategiesListComponent extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h5>Strategies</h5>
|
<HeaderTitle title="Strategies" actions={<IconButton name="add" onClick={() => this.context.router.push('/strategies/create')} title="Add new strategy"/>} />
|
||||||
<IconButton name="add" onClick={() => this.context.router.push('/strategies/create')} title="Add new strategy"/>
|
|
||||||
|
|
||||||
<hr />
|
|
||||||
<List>
|
<List>
|
||||||
{strategies.length > 0 ? strategies.map((strategy, i) => {
|
{strategies.length > 0 ? strategies.map((strategy, i) => {
|
||||||
return (
|
return (
|
||||||
@ -41,8 +39,6 @@ class StrategiesListComponent extends Component {
|
|||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
);
|
||||||
}) : <ListItem>No entries</ListItem>}
|
}) : <ListItem>No entries</ListItem>}
|
||||||
|
|
||||||
|
|
||||||
</List>
|
</List>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user