Skip to content

Commit b4a4206

Browse files
committed
Remove useless/unavailable info from AppsIndex
1 parent 2cc1fbe commit b4a4206

File tree

3 files changed

+35
-94
lines changed

3 files changed

+35
-94
lines changed

dashboard/Apps/AppsIndex.react.js

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,11 @@ let CloningNote = ({ app, clone_status, clone_progress }) => {
4545
return <div>Cloning is {progress}% complete</div>
4646
};
4747

48-
let CountsSection = (props) => {
49-
return (
50-
<div className={props.className}>
51-
<div className={styles.section}>{props.title}</div>
52-
{props.children}
53-
</div>
54-
);
55-
};
48+
let CountsSection = ({ className, title, children }) =>
49+
<div className={className}>
50+
<div className={styles.section}>{title}</div>
51+
{children}
52+
</div>
5653

5754
let Metric = (props) => {
5855
return (
@@ -63,46 +60,20 @@ let Metric = (props) => {
6360
);
6461
};
6562

66-
let AppCard = (props) => {
67-
let sharing = null;
68-
if (props.app.collabInfo) {
69-
if (props.app.isOwner()) {
70-
sharing = 'shared with ' + pluralize(props.app.collaboratorCount, 'person', 'people');
71-
} else {
72-
sharing = html`shared by ${props.app.owner}`;
73-
}
74-
}
75-
return (
76-
<li onClick={() => history.pushState(null, html`/apps/${props.app.slug}/browser`)}>
77-
<a className={styles.icon}>
78-
{props.icon ? <img src={props.icon} /> : <Icon width={56} height={56} name='blank-app-outline' fill='#1E384D' />}
79-
</a>
80-
<CountsSection className={styles.plan} title='Current plan'>
81-
<Metric number={dash(props.app.requestLimit)} label='requests/s' />
82-
<Metric number={dash(props.app.requestLimit, Math.floor(props.app.requestLimit / 20))} label='background job' />
83-
<Metric number={dash(props.app.requestLimit, '$' + (props.app.requestLimit - 30) * 10)} label='monthly' />
84-
<a href={html`/apps/${props.app.slug}/settings`} className={styles.edit} onClick={(e) => {
85-
e.stopPropagation();
86-
history.pushState(null, html`/apps/${props.app.slug}/settings`);
87-
}}>Edit</a>
88-
</CountsSection>
89-
<CountsSection className={styles.glance} title='At a glance'>
90-
<Metric number={dash(props.app.requests, prettyNumber(props.app.requests))} label='requests' />
91-
<Metric number={dash(props.app.users, prettyNumber(props.app.users))} label='total users' />
92-
<Metric number={dash(props.app.installations, prettyNumber(props.app.installations))} label='total installations' />
93-
</CountsSection>
94-
<div className={styles.details}>
95-
<a className={styles.appname}>{props.app.name}</a>
96-
{props.app.is_cloning ? <CloningNote
97-
app={props.app}
98-
clone_status={props.app.clone_status}
99-
clone_progress={props.app.clone_progress}/> :
100-
<div>Created <span className={styles.ago}>{howLongAgo(props.app.createdAt)}</span></div>}
101-
</div>
102-
{sharing}
103-
</li>
104-
)
105-
};
63+
let AppCard = ({
64+
app,
65+
icon,
66+
}) => <li onClick={() => history.pushState(null, html`/apps/${app.slug}/browser`)}>
67+
{icon ? <a className={styles.icon}><img src={icon} /></a> : null}
68+
<CountsSection className={styles.glance} title='At a glance'>
69+
<Metric number={dash(app.users, prettyNumber(app.users))} label='total users' />
70+
<Metric number={dash(app.installations, prettyNumber(app.installations))} label='total installations' />
71+
</CountsSection>
72+
<div className={styles.details}>
73+
<a className={styles.appname}>{app.name}</a>
74+
<div className={styles.serverVersion}>Server version: <span className={styles.ago}>{app.enabledFeatures.serverVersion || 'unknown'}</span></div>
75+
</div>
76+
</li>
10677

10778
export default class AppsIndex extends React.Component {
10879
constructor() {
@@ -113,7 +84,7 @@ export default class AppsIndex extends React.Component {
11384

11485
componentWillMount() {
11586
document.body.addEventListener('keydown', this.focusField);
116-
AppsManager.getAppsInfo().then(() => {
87+
AppsManager.getAllAppsIndexStats().then(() => {
11788
this.forceUpdate();
11889
});
11990
}

dashboard/Apps/AppsIndex.scss

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
margin: 14px 0;
106106
padding: 0 9px;
107107
height: 74px;
108-
108+
109109
&:hover{
110110
background: #172C3B;
111111
}
@@ -124,16 +124,14 @@
124124
}
125125

126126
.appname {
127+
@include ellipsis();
127128
display: inline-block;
128129
font-size: 22px;
129130
color: white;
130-
max-width: 180px;
131-
overflow: hidden;
132-
text-overflow: ellipsis;
133-
white-space: nowrap;
134131
}
135132

136133
.details {
134+
@include ellipsis();
137135
padding: 9px 0;
138136
color: #788c97;
139137
font-size: 12px;
@@ -153,29 +151,8 @@
153151

154152
.glance {
155153
float: right;
156-
width: 340px;
157154
padding: 10px 12px;
158155
border-left: 1px solid #1e3b4d;
159-
border-right: 1px solid #1e3b4d;
160-
}
161-
162-
@media (max-width: 1300px) {
163-
.glance {
164-
display: none;
165-
}
166-
}
167-
168-
.plan {
169-
float: right;
170-
width: 300px;
171-
padding: 10px 12px;
172-
position: relative;
173-
}
174-
175-
@media (max-width: 640px) {
176-
.plan {
177-
display: none;
178-
}
179156
}
180157

181158
.section {
@@ -200,6 +177,10 @@
200177
font-size: 11px;
201178
}
202179

180+
.serverVersion {
181+
@include ellipsis();
182+
}
183+
203184
.edit {
204185
@include DIN17Font;
205186
position: absolute;

lib/AppsManager.js

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* This source code is licensed under the license found in the LICENSE file in
66
* the root directory of this source tree.
77
*/
8+
import Parse from 'parse';
89
import ParseApp from 'lib/ParseApp';
910
import { get, post, del } from 'lib/AJAX';
1011
import { unescape } from 'lib/StringEscaping';
@@ -66,25 +67,13 @@ const AppsManager = {
6667
},
6768

6869
// Fetch the latest usage and request info for the apps index
69-
getAppsInfo() {
70-
return get('/apps_info').then((response) => {
71-
this.apps().forEach((app) => {
72-
let info = response[app.slug];
73-
if (info) {
74-
app.installations = info.installations;
75-
app.requests = info.requests;
76-
app.users = info.users;
77-
app.requestLimit = info.requestLimit;
78-
79-
app.is_cloning = info.is_cloning;
80-
if (app.is_cloning) {
81-
app.clone_message = info.clone_message;
82-
app.clone_status = info.clone_status;
83-
app.clone_progress = info.clone_progress;
84-
}
85-
}
86-
});
87-
});
70+
getAllAppsIndexStats() {
71+
return Parse.Promise.when(this.apps().map(app => {
72+
return Parse.Promise.when(
73+
app.getClassCount('_Installation').then(count => app.installations = count),
74+
app.getClassCount('_User').then(count => app.users = count)
75+
);
76+
}));
8877
},
8978

9079
// Options should be a list containing a subset of

0 commit comments

Comments
 (0)