var React = require('react'), Fluxxor = require('fluxxor'); import {compact} from 'lodash'; var FluxMixin = Fluxxor.FluxMixin(React), StoreWatchMixin = Fluxxor.StoreWatchMixin; var TabbedArea = require('react-bootstrap/lib/TabbedArea'); var Annotations = require('../generic/annotations'), Breadcrumbs = require('../generic/breadcrumbs'), FoldableAuditSection = require('../generic/foldable_audit_section'), TabMixin = require('../generic/tab_mixin'), RoleGraph = require('../graph/graph'), Refresh = require('../refresh/refresh'); var AuditTable = require('../audit/table'); var Activity = require('./activity'), Updaters = require('./updaters'), Executors = require('./executors'), Details = require('./details'); export default React.createClass({ displayName: 'HostView', mixins: [FluxMixin, StoreWatchMixin('audit', 'host', 'resources', 'route'), TabMixin], askForNewData(state) { var actions = this.getFlux().actions; actions.audit.loadForRole('host', state.id); actions.audit.loadForResource('host', state.id); actions.host.load(state.id); actions.resources.loadOne('host', state.id); }, componentDidMount() { this.askForNewData(this.state); }, componentWillUpdate(nextProps, nextState) { if (this.state.id !== nextState.id) { this.askForNewData(nextState); } return true; }, getStateFromFlux() { var flux = this.getFlux(), id = flux.store('route').getParam('id'), audit = flux.store('audit').getEventFor('host', id), data = flux.store('host').getData(), resource = flux.store('resources').getResource('host', id); var ret = { id: id, loading: data.loading, host: data.host, owned: data.owned, roles: data.roles, owner: resource.data.owner, annotations: resource.data.annotations, resource: resource.data, audit: audit.data, resources: data.resources, executors: data.executors, updaters: data.updaters }; ret.loading.audit = audit.loading; ret.loading.owner = resource.loading; ret.loading.annotations = resource.loading; return ret; }, render() { var permissionsTab = this.permissionsTab(this.state.host.roleid), membershipsTab = this.membershipsTab(this.state.host.roleid), ownedTab = this.ownedTab(); var tabs = compact([ membershipsTab, ownedTab, permissionsTab ]); var elems = [ {url: '/ui/hosts', text: 'Hosts'}, {url: '', text: this.state.host.id}, {url: '', text: '(owned by ' + this.state.host.ownerid + ')'} ]; return (