From b0a1b4e2d14d670d70eb65b479bdfa38b826659a Mon Sep 17 00:00:00 2001 From: sveisvei Date: Fri, 9 Dec 2016 22:10:37 +0100 Subject: [PATCH] use table on compact diff view --- .../component/history/history-item-diff.jsx | 16 ++++++------ .../history/history-list-component.jsx | 25 ++++++++++++++++--- .../history/history-list-toggle-component.jsx | 7 +++--- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/frontend/src/component/history/history-item-diff.jsx b/frontend/src/component/history/history-item-diff.jsx index 0374073ab3..2471dc8367 100644 --- a/frontend/src/component/history/history-item-diff.jsx +++ b/frontend/src/component/history/history-item-diff.jsx @@ -10,7 +10,7 @@ const DIFF_PREFIXES = { N: '+', }; -const SPADEN_CLASS = { +const KLASSES = { A: style.blue, // array edited E: style.blue, // edited D: style.negative, // deleted @@ -32,13 +32,13 @@ function buildItemDiff (diff, key) { if (diff.lhs !== undefined) { change = (
-
- {key}: {JSON.stringify(diff.lhs)}
+
- {key}: {JSON.stringify(diff.lhs)}
); } else if (diff.rhs !== undefined) { change = (
-
+ {key}: {JSON.stringify(diff.rhs)}
+
+ {key}: {JSON.stringify(diff.rhs)}
); } @@ -55,12 +55,12 @@ function buildDiff (diff, idx) { } else if (diff.lhs !== undefined && diff.rhs !== undefined) { change = (
-
- {key}: {JSON.stringify(diff.lhs)}
-
+ {key}: {JSON.stringify(diff.rhs)}
+
- {key}: {JSON.stringify(diff.lhs)}
+
+ {key}: {JSON.stringify(diff.rhs)}
); } else { - const spadenClass = SPADEN_CLASS[diff.kind]; + const spadenClass = KLASSES[diff.kind]; const prefix = DIFF_PREFIXES[diff.kind]; change = (
{prefix} {key}: {JSON.stringify(diff.rhs || diff.item)}
); @@ -84,7 +84,7 @@ class HistoryItem extends PureComponent { changes = logEntry.diffs.map(buildDiff); } else { // Just show the data if there is no diff yet. - changes =
{JSON.stringify(logEntry.data, null, 2)}
; + changes =
{JSON.stringify(logEntry.data, null, 2)}
; } return {changes.length === 0 ? '(no changes)' : changes}; @@ -102,6 +102,8 @@ class HistoryItem extends PureComponent { const data = this.renderEventDiff(this.props.entry); + return data; + return (
diff --git a/frontend/src/component/history/history-list-component.jsx b/frontend/src/component/history/history-list-component.jsx index d13ecfc3ea..da0cb954cc 100644 --- a/frontend/src/component/history/history-list-component.jsx +++ b/frontend/src/component/history/history-list-component.jsx @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import HistoryItemDiff from './history-item-diff'; import HistoryItemJson from './history-item-json'; -import { Switch } from 'react-mdl'; +import { Switch, Table, TableHeader, Grid, Cell } from 'react-mdl'; import style from './history.scss'; @@ -23,13 +23,30 @@ class HistoryList extends Component { if (showData) { entries = history.map((entry) => ); } else { - entries = history.map((entry) => ); + entries = ( Object.assign({ + diff: (), + }, entry)) + } + style={{ width: '100%' }} + > + Type + User + Diff + Time +
); } return (
- Show full events - {entries} + + + Show full events + + + {entries}
); } diff --git a/frontend/src/component/history/history-list-toggle-component.jsx b/frontend/src/component/history/history-list-toggle-component.jsx index 28ba996613..a0dc2ff342 100644 --- a/frontend/src/component/history/history-list-toggle-component.jsx +++ b/frontend/src/component/history/history-list-toggle-component.jsx @@ -1,5 +1,6 @@ import React, { Component, PropTypes } from 'react'; import ListComponent from './history-list-container'; +import { Link } from 'react-router'; class HistoryListToggle extends Component { @@ -17,11 +18,11 @@ class HistoryListToggle extends Component { if (!this.props.history || this.props.history.length === 0) { return fetching..; } - + const { history, toggleName } = this.props; return (
-
Showing history for toggle: {this.props.toggleName}
- +
Showing history for toggle: {toggleName}
+
); }