From 61729c3467717fadef4a4e0089af188c4ee90fcc Mon Sep 17 00:00:00 2001 From: sveisvei Date: Fri, 9 Dec 2016 22:11:05 +0100 Subject: [PATCH] load app list from common --- .../application/application-edit-component.js | 28 +++++++++++++------ .../application/application-list-component.js | 17 ++--------- frontend/src/component/common/index.js | 18 ++++++++++++ .../component/feature/view-edit-container.jsx | 17 +++-------- 4 files changed, 45 insertions(+), 35 deletions(-) create mode 100644 frontend/src/component/common/index.js diff --git a/frontend/src/component/application/application-edit-component.js b/frontend/src/component/application/application-edit-component.js index 2c2c73ebcf..27a560a1fa 100644 --- a/frontend/src/component/application/application-edit-component.js +++ b/frontend/src/component/application/application-edit-component.js @@ -43,13 +43,16 @@ class ClientStrategies extends PureComponent { instances, strategies, seenToggles, - data = {}, + url, + description, + icon = 'apps', + color, } = application; return (
-
{appName}
- {data.description &&

{data.description}

} +
{appName}
+ {description &&

{description}

}
Toggles
@@ -86,7 +89,11 @@ class ClientStrategies extends PureComponent { {instances.map(({ instanceId, clientIp, lastSeen }, i) => ( - {clientIp} last seen at {new Date(lastSeen).toLocaleString('nb-NO')}}> + {clientIp} last seen at {new Date(lastSeen).toLocaleString('nb-NO')} + }> {instanceId} @@ -98,12 +105,17 @@ class ClientStrategies extends PureComponent {
Edit app meta data
- storeApplicationMetaData(appName, 'url', e.target.value)} />
- storeApplicationMetaData(appName, 'description', e.target.value)} /> + storeApplicationMetaData(appName, 'url', e.target.value)} />
+ storeApplicationMetaData(appName, 'description', e.target.value)} />
- storeApplicationMetaData(appName, 'icon', e.target.value)} /> - storeApplicationMetaData(appName, 'color', e.target.value)} /> + storeApplicationMetaData(appName, 'icon', e.target.value)} /> + storeApplicationMetaData(appName, 'color', e.target.value)} />
diff --git a/frontend/src/component/application/application-list-component.js b/frontend/src/component/application/application-list-component.js index f96e3fc63b..dc35830bff 100644 --- a/frontend/src/component/application/application-list-component.js +++ b/frontend/src/component/application/application-list-component.js @@ -1,6 +1,5 @@ import React, { Component } from 'react'; -import { List, ListItem, ListItemContent } from 'react-mdl'; -import { Link } from 'react-router'; +import { AppsLinkList } from '../common'; class ClientStrategies extends Component { @@ -14,23 +13,13 @@ class ClientStrategies extends Component { } = this.props; if (!applications) { - return
loading...
; + return
Loading...
; } return (
Applications

- - {applications.map(({ appName, data = {} }) => ( - - - - {appName} - - - - ))} - +
); } diff --git a/frontend/src/component/common/index.js b/frontend/src/component/common/index.js new file mode 100644 index 0000000000..969c00f2b5 --- /dev/null +++ b/frontend/src/component/common/index.js @@ -0,0 +1,18 @@ +const React = require('react'); +const { List, ListItem, ListItemContent } = require('react-mdl'); +const { Link } = require('react-router'); + +export const AppsLinkList = ({ apps }) => ( + + {apps.length > 0 && apps.map(({ appName, description = '-', icon = 'apps' }) => ( + + + + {appName} + + + + ))} + +); + diff --git a/frontend/src/component/feature/view-edit-container.jsx b/frontend/src/component/feature/view-edit-container.jsx index 84f6469a98..66a9eeb5b8 100644 --- a/frontend/src/component/feature/view-edit-container.jsx +++ b/frontend/src/component/feature/view-edit-container.jsx @@ -12,6 +12,8 @@ import { fetchFeatureMetrics, fetchSeenApps } from '../../store/feature-metrics- import { fetchHistoryForToggle } from '../../store/history-actions'; import { getIcon } from '../history/history-item-diff'; +import { AppsLinkList } from '../common'; + class EditFeatureToggleWrapper extends React.Component { static propTypes () { @@ -30,7 +32,6 @@ class EditFeatureToggleWrapper extends React.Component { this.props.fetchHistoryForToggle(this.props.featureToggleName); this.props.fetchFeatureMetrics(); this.timer = setInterval(() => { - this.props.fetchSeenApps(); this.props.fetchFeatureMetrics(); }, 5000); } @@ -63,7 +64,7 @@ class EditFeatureToggleWrapper extends React.Component { if (features.length === 0 ) { return Loading; } - return Could not find {this.props.featureToggleName}; + return Could not find the toggle "{this.props.featureToggleName}"; } return ( @@ -105,17 +106,7 @@ class EditFeatureToggleWrapper extends React.Component {
Not used in a app in the last hour. This might be due to your client implementation is not reporting usage.
} - - {seenApps.length > 0 && seenApps.map(({ appName, data = {} }) => ( - - - - {appName} - - - - ))} - +
History