Skip to content

Commit 7644157

Browse files
committed
Merged in master
2 parents 7b9cadd + f124554 commit 7644157

File tree

10 files changed

+183
-176
lines changed

10 files changed

+183
-176
lines changed

dashboard/assets.go

Lines changed: 45 additions & 45 deletions
Large diffs are not rendered by default.

dashboard/src/App.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React, { Component } from 'react';
2-
import ReactTimeout from 'react-timeout';
1+
import { Container, Segment, Message } from 'semantic-ui-react';
2+
import { withAuth } from './auth/Auth';
3+
import api, { isUnauthorized } from './api/api.js';
34
import DeploymentOperator from './deployment/DeploymentOperator';
45
import DeploymentReplicationOperator from './replication/DeploymentReplicationOperator';
5-
import StorageOperator from './storage/StorageOperator';
6-
import NoOperator from './NoOperator';
76
import Loading from './util/Loading';
8-
import api, { IsUnauthorized } from './api/api';
9-
import { Container, Segment, Message } from 'semantic-ui-react';
10-
import { withAuth } from './auth/Auth';
7+
import NoOperator from './NoOperator';
8+
import React, { Component } from 'react';
9+
import ReactTimeout from 'react-timeout';
10+
import StorageOperator from './storage/StorageOperator';
1111

1212
const PodInfoView = ({pod, namespace}) => (
1313
<Segment basic>
@@ -19,17 +19,19 @@ const PodInfoView = ({pod, namespace}) => (
1919
);
2020

2121
const OperatorsView = ({error, deployment, deploymentReplication, storage, pod, namespace}) => {
22-
const podInfoView = (<PodInfoView pod={pod} namespace={namespace}/>);
23-
if (deployment) {
24-
return (<DeploymentOperator podInfoView={podInfoView} error={error}/>);
25-
}
26-
if (deploymentReplication) {
27-
return (<DeploymentReplicationOperator podInfoView={podInfoView} error={error}/>);
28-
}
29-
if (storage) {
30-
return (<StorageOperator podInfoView={podInfoView} error={error}/>);
31-
}
32-
return (<NoOperator podInfoView={podInfoView} error={error}/>);
22+
let Operator = NoOperator;
23+
if (deployment)
24+
Operator = DeploymentOperator;
25+
else if (deploymentReplication)
26+
Operator = DeploymentReplicationOperator;
27+
else if (storage)
28+
Operator = StorageOperator;
29+
return (
30+
<Operator
31+
podInfoView={<PodInfoView pod={pod} namespace={namespace} />}
32+
error={error}
33+
/>
34+
);
3335
}
3436

3537
const LoadingView = () => (
@@ -59,7 +61,7 @@ class App extends Component {
5961
this.setState({
6062
error: e.message
6163
});
62-
if (IsUnauthorized(e)) {
64+
if (isUnauthorized(e)) {
6365
this.props.doLogout();
6466
}
6567
}

dashboard/src/api/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function IsUnauthorized(e) {
1+
export function isUnauthorized(e) {
22
return (e.status === 401);
33
}
44

dashboard/src/deployment/DeploymentDetails.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ReactTimeout from 'react-timeout';
22
import React, { Component } from 'react';
3-
import api, { IsUnauthorized } from '../api/api.js';
3+
import api, { isUnauthorized } from '../api/api.js';
44
import Loading from '../util/Loading.js';
55
import MemberList from './MemberList.js';
66
import styled from 'react-emotion';
@@ -54,7 +54,7 @@ class DeploymentDetails extends Component {
5454
loading: false,
5555
error: e.message
5656
});
57-
if (IsUnauthorized(e)) {
57+
if (isUnauthorized(e)) {
5858
this.props.doLogout();
5959
return;
6060
}

dashboard/src/deployment/DeploymentList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Icon, Loader, Popup, Table } from 'semantic-ui-react';
22
import { Link } from "react-router-dom";
3-
import api, { IsUnauthorized } from '../api/api.js';
3+
import api, { isUnauthorized } from '../api/api.js';
44
import CommandInstruction from '../util/CommandInstruction.js';
55
import Loading from '../util/Loading.js';
66
import React, { Component } from 'react';
@@ -173,7 +173,7 @@ class DeploymentList extends Component {
173173
});
174174
} catch (e) {
175175
this.setState({error: e.message, loading: false});
176-
if (IsUnauthorized(e)) {
176+
if (isUnauthorized(e)) {
177177
this.props.doLogout();
178178
return;
179179
}

dashboard/src/replication/DeploymentReplicationDetails.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ReactTimeout from 'react-timeout';
22
import React, { Component } from 'react';
3-
import api, { IsUnauthorized } from '../api/api.js';
3+
import api, { isUnauthorized } from '../api/api.js';
44
import Loading from '../util/Loading.js';
55
import styled from 'react-emotion';
66
import { Header, Loader, Segment } from 'semantic-ui-react';
@@ -98,7 +98,7 @@ class DeploymentReplicationDetails extends Component {
9898
loading: false,
9999
error: e.message
100100
});
101-
if (IsUnauthorized(e)) {
101+
if (isUnauthorized(e)) {
102102
this.props.doLogout();
103103
return;
104104
}

dashboard/src/replication/DeploymentReplicationList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Icon, Loader, Popup, Table } from 'semantic-ui-react';
22
import { Link } from "react-router-dom";
3-
import api, { IsUnauthorized } from '../api/api.js';
3+
import api, { isUnauthorized } from '../api/api.js';
44
import CommandInstruction from '../util/CommandInstruction.js';
55
import Loading from '../util/Loading.js';
66
import React, { Component } from 'react';
@@ -134,7 +134,7 @@ class DeploymentReplicationList extends Component {
134134
});
135135
} catch (e) {
136136
this.setState({error: e.message, loading: false});
137-
if (IsUnauthorized(e)) {
137+
if (isUnauthorized(e)) {
138138
this.props.doLogout();
139139
return;
140140
}

dashboard/src/storage/StorageList.js

Lines changed: 5 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { Accordion, Header, Icon, Loader, Popup, Table } from 'semantic-ui-react';
2-
import api, { IsUnauthorized } from '../api/api.js';
3-
import CommandInstruction from '../util/CommandInstruction.js';
4-
import VolumeList from './VolumeList.js';
1+
import { Loader, Table } from 'semantic-ui-react';
2+
import api, { isUnauthorized } from '../api/api.js';
53
import Loading from '../util/Loading.js';
64
import React, { Component } from 'react';
75
import ReactTimeout from 'react-timeout';
86
import styled from 'react-emotion';
97
import { withAuth } from '../auth/Auth.js';
8+
import StorageRow from './StorageRow';
109

1110
const LoaderBox = styled('span')`
1211
float: right;
@@ -31,65 +30,13 @@ const HeaderView = ({loading}) => (
3130
</Table.Header>
3231
);
3332

34-
const RowView = ({name, stateColor,localPaths, storageClass, storageClassIsDefault, deleteCommand, describeCommand, expanded, toggleExpand}) => (
35-
<Table.Row>
36-
<Table.Cell>
37-
<Popup trigger={<Icon name={(stateColor==="green") ? "check" : "bell"} color={stateColor}/>}>
38-
{getStateColorDescription(stateColor)}
39-
</Popup>
40-
</Table.Cell>
41-
<Table.Cell onClick={toggleExpand}>
42-
<Accordion>
43-
<Accordion.Title active={expanded}>
44-
<Icon name='dropdown' />
45-
{name}
46-
</Accordion.Title>
47-
</Accordion>
48-
</Table.Cell>
49-
<Table.Cell>
50-
{localPaths.map((item, index) => <code key={index}>{item}</code>)}
51-
</Table.Cell>
52-
<Table.Cell>
53-
{storageClass}
54-
<span style={{"float":"right"}}>
55-
{storageClassIsDefault && <Popup trigger={<Icon name="exclamation"/>} content="Default storage class"/>}
56-
</span>
57-
</Table.Cell>
58-
<Table.Cell>
59-
<CommandInstruction
60-
trigger={<Icon link name="zoom"/>}
61-
command={describeCommand}
62-
title="Describe local storage"
63-
description="To get more information on the state of this local storage, run:"
64-
/>
65-
<span style={{"float":"right"}}>
66-
<CommandInstruction
67-
trigger={<Icon link name="trash"/>}
68-
command={deleteCommand}
69-
title="Delete local storage"
70-
description="To delete this local storage, run:"
71-
/>
72-
</span>
73-
</Table.Cell>
74-
</Table.Row>
75-
);
76-
77-
const VolumesRowView = ({name}) => (
78-
<Table.Row>
79-
<Table.Cell colSpan="5">
80-
<Header sub>Volumes</Header>
81-
<VolumeList storageName={name}/>
82-
</Table.Cell>
83-
</Table.Row>
84-
);
85-
8633
const ListView = ({items, loading}) => (
8734
<Table celled>
8835
<HeaderView loading={loading}/>
8936
<Table.Body>
9037
{
9138
(items) ? items.map((item) =>
92-
<RowComponent
39+
<StorageRow
9340
key={item.name}
9441
name={item.name}
9542
localPaths={item.local_paths}
@@ -105,34 +52,6 @@ const ListView = ({items, loading}) => (
10552
</Table>
10653
);
10754

108-
class RowComponent extends Component {
109-
state = {expanded: true};
110-
111-
onToggleExpand = () => { this.setState({expanded: !this.state.expanded});}
112-
113-
render() {
114-
return [<RowView
115-
key="datarow"
116-
name={this.props.name}
117-
localPaths={this.props.localPaths}
118-
stateColor={this.props.stateColor}
119-
storageClass={this.props.storageClass}
120-
storageClassIsDefault={this.props.storageClassIsDefault}
121-
deleteCommand={this.props.deleteCommand}
122-
describeCommand={this.props.describeCommand}
123-
toggleExpand={this.onToggleExpand}
124-
expanded={this.state.expanded}
125-
/>,
126-
this.state.expanded && <VolumesRowView
127-
key="volrow"
128-
name={this.props.name}
129-
expanded={this.state.expanded}
130-
toggleExpand={this.onToggleExpand}
131-
/>
132-
];
133-
}
134-
}
135-
13655
const EmptyView = () => (<div>No local storage resources</div>);
13756

13857
function createDeleteCommand(name) {
@@ -143,21 +62,6 @@ function createDescribeCommand(name) {
14362
return `kubectl describe ArangoLocalStorage ${name}`;
14463
}
14564

146-
function getStateColorDescription(stateColor) {
147-
switch (stateColor) {
148-
case "green":
149-
return "Everything is running smooth.";
150-
case "yellow":
151-
return "There is some activity going on, but local storage is available.";
152-
case "orange":
153-
return "There is some activity going on, local storage may be/become unavailable. You should pay attention now!";
154-
case "red":
155-
return "The local storage is in a bad state and manual intervention is likely needed.";
156-
default:
157-
return "State is not known.";
158-
}
159-
}
160-
16165
class StorageList extends Component {
16266
state = {
16367
items: undefined,
@@ -185,7 +89,7 @@ class StorageList extends Component {
18589
error: e.message,
18690
loading: false
18791
});
188-
if (IsUnauthorized(e)) {
92+
if (isUnauthorized(e)) {
18993
this.props.doLogout();
19094
return;
19195
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import { Accordion, Header, Icon, Popup, Table } from 'semantic-ui-react';
2+
import CommandInstruction from '../util/CommandInstruction.js';
3+
import VolumeList from './VolumeList.js';
4+
import React, { Component } from 'react';
5+
6+
const RowView = ({name, stateColor,localPaths, storageClass, storageClassIsDefault, deleteCommand, describeCommand, expanded, toggleExpand}) => (
7+
<Table.Row>
8+
<Table.Cell>
9+
<Popup trigger={<Icon name={(stateColor==="green") ? "check" : "bell"} color={stateColor}/>}>
10+
{getStateColorDescription(stateColor)}
11+
</Popup>
12+
</Table.Cell>
13+
<Table.Cell onClick={toggleExpand}>
14+
<Accordion>
15+
<Accordion.Title active={expanded}>
16+
<Icon name='dropdown' />
17+
{name}
18+
</Accordion.Title>
19+
</Accordion>
20+
</Table.Cell>
21+
<Table.Cell>
22+
{localPaths.map((item, index) => <code key={index}>{item}</code>)}
23+
</Table.Cell>
24+
<Table.Cell>
25+
{storageClass}
26+
<span style={{"float":"right"}}>
27+
{storageClassIsDefault && <Popup trigger={<Icon name="exclamation"/>} content="Default storage class"/>}
28+
</span>
29+
</Table.Cell>
30+
<Table.Cell>
31+
<CommandInstruction
32+
trigger={<Icon link name="zoom"/>}
33+
command={describeCommand}
34+
title="Describe local storage"
35+
description="To get more information on the state of this local storage, run:"
36+
/>
37+
<span style={{"float":"right"}}>
38+
<CommandInstruction
39+
trigger={<Icon link name="trash"/>}
40+
command={deleteCommand}
41+
title="Delete local storage"
42+
description="To delete this local storage, run:"
43+
/>
44+
</span>
45+
</Table.Cell>
46+
</Table.Row>
47+
);
48+
49+
const VolumesRowView = ({name}) => (
50+
<Table.Row>
51+
<Table.Cell colSpan="5">
52+
<Header sub>Volumes</Header>
53+
<VolumeList storageName={name}/>
54+
</Table.Cell>
55+
</Table.Row>
56+
);
57+
58+
class StorageRow extends Component {
59+
state = {expanded: true};
60+
61+
onToggleExpand = () => { this.setState({expanded: !this.state.expanded});}
62+
63+
render() {
64+
return [<RowView
65+
key="datarow"
66+
name={this.props.name}
67+
localPaths={this.props.localPaths}
68+
stateColor={this.props.stateColor}
69+
storageClass={this.props.storageClass}
70+
storageClassIsDefault={this.props.storageClassIsDefault}
71+
deleteCommand={this.props.deleteCommand}
72+
describeCommand={this.props.describeCommand}
73+
toggleExpand={this.onToggleExpand}
74+
expanded={this.state.expanded}
75+
/>,
76+
this.state.expanded && <VolumesRowView
77+
key="volrow"
78+
name={this.props.name}
79+
expanded={this.state.expanded}
80+
toggleExpand={this.onToggleExpand}
81+
/>
82+
];
83+
}
84+
}
85+
86+
function getStateColorDescription(stateColor) {
87+
switch (stateColor) {
88+
case "green":
89+
return "Everything is running smooth.";
90+
case "yellow":
91+
return "There is some activity going on, but local storage is available.";
92+
case "orange":
93+
return "There is some activity going on, local storage may be/become unavailable. You should pay attention now!";
94+
case "red":
95+
return "The local storage is in a bad state and manual intervention is likely needed.";
96+
default:
97+
return "State is not known.";
98+
}
99+
}
100+
101+
export default StorageRow;

0 commit comments

Comments
 (0)