Skip to content

Commit 7dbf266

Browse files
authored
Merge pull request #44 from zxan1285/apps-reorder
Apps reorder
2 parents 7f2c991 + 446bde3 commit 7dbf266

File tree

18 files changed

+253
-20
lines changed

18 files changed

+253
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2.1.1] - Unreleased
8+
9+
### Added
10+
- Possibility to re-arrange applications order
11+
712
## [2.1.0] - 2018-12-11
813

914
### Changed

build/webpack/config.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ let config = {
8080
{
8181
test: /\.css$/,
8282
use: [
83-
// 'style-loader',
84-
'css-loader',
83+
(mode === developmentMode ? 'style-loader' : 'css-loader'),
8584
{
8685
loader: 'postcss-loader',
8786
options: {
@@ -162,19 +161,25 @@ switch(mode) {
162161
filename: 'manifest.json',
163162
transform: function transformData(data) {
164163
const chunks = {
165-
app: data.assetsByChunkName.app[0],
166-
style: data.assetsByChunkName.app[1],
167-
vendors: data.assetsByChunkName.vendor
164+
app: data.assetsByChunkName.app[1],
165+
style: data.assetsByChunkName.app[0],
166+
vendors: data.assetsByChunkName.vendors
168167
};
169168
return JSON.stringify(chunks);
170169
}
171170
})
172171
);
173172

174-
175173
config = extractCSS(config);
176174
break;
177175
case developmentMode:
176+
config.optimization = {};
177+
config.output = {
178+
path: path.join(process.cwd(), './dist'),
179+
filename: 'bundle.js',
180+
publicPath: 'http://localhost:3000/app/'
181+
};
182+
178183
break;
179184
}
180185

build/webpack/server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const logger = require('../../server/lib/logger');
66

77
const options = {
88
publicPath: 'http://localhost:3000/app/',
9+
disableHostCheck: true,
910
hot: true,
1011
inline: true,
1112
historyApiFallback: true,

client/actions/application.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,28 @@ export function cancelDeleteApplication() {
160160
};
161161
}
162162

163+
export function moveApplication(appId, direction, onSuccess) {
164+
const moveTo = direction === 'up' ? -1 : 1;
165+
return (dispatch) => {
166+
dispatch({
167+
type: constants.MOVE_APPLICATION,
168+
meta: {
169+
onSuccess: () => {
170+
if (onSuccess) {
171+
onSuccess();
172+
}
173+
dispatch(fetchApplicationsAll());
174+
}
175+
},
176+
payload: {
177+
promise: axios.patch(`/api/applications/${appId}/${moveTo}`, {
178+
responseType: 'json'
179+
})
180+
}
181+
});
182+
};
183+
}
184+
163185
export function deleteApplication(appId, onSuccess) {
164186
return (dispatch) => {
165187
dispatch({

client/components/Applications/ApplicationOverview.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default class ApplicationOverview extends React.Component {
1010
onReset: React.PropTypes.func.isRequired,
1111
onChangeSearch: React.PropTypes.func.isRequired,
1212
fetchApplications: React.PropTypes.func.isRequired,
13+
moveApplication: React.PropTypes.func.isRequired,
1314
deleteApplication: React.PropTypes.func.isRequired,
1415
updateApplication: React.PropTypes.func.isRequired,
1516
requestDeleteApplication: React.PropTypes.func.isRequired,
@@ -48,6 +49,7 @@ export default class ApplicationOverview extends React.Component {
4849
<ApplicationsTable
4950
loading={loading}
5051
applications={applications}
52+
moveApplication={this.props.moveApplication}
5153
deleteApplication={this.props.deleteApplication}
5254
fetchApplications={this.props.fetchApplications}
5355
updateApplication={this.props.updateApplication}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
a.move-app.disabled {
2+
color: #909090;
3+
background-color: #f6f6f6;
4+
cursor: default;
5+
}

client/components/Applications/ApplicationsList.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React, { Component } from 'react';
2-
import { Link } from 'react-router';
32
import varstring from 'varstring';
43

54
export default class ApplicationsList extends Component {
@@ -24,7 +23,7 @@ export default class ApplicationsList extends Component {
2423
const logo = (app.logo) ? app.logo : 'https://cdn.auth0.com/manage/v0.3.1866/img/badge-grey.svg';
2524
const name = app.name || key;
2625

27-
const link = app.customURLEnabled ? varstring(app.customURL, {
26+
const link = app.customURLEnabled ? varstring(app.customURL || '', {
2827
domain: window.config.AUTH0_DOMAIN,
2928
connection: app.connection,
3029
client_id: app.client,

client/components/Applications/ApplicationsTable.jsx

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1+
import './ApplicationTable.css';
12
import React, { Component } from 'react';
23

34
import {
45
Confirm,
5-
TableActionCell,
66
Table,
77
TableCell,
8-
TableRouteCell,
98
TableBody,
10-
TableTextCell,
11-
TableHeader,
12-
TableColumn,
139
TableRow
1410
} from '../Dashboard';
1511
import { Link } from 'react-router';
@@ -21,6 +17,7 @@ export default class ApplicationsTable extends Component {
2117
React.PropTypes.array
2218
]).isRequired,
2319
loading: React.PropTypes.bool.isRequired,
20+
moveApplication: React.PropTypes.func.isRequired,
2421
deleteApplication: React.PropTypes.func.isRequired,
2522
updateApplication: React.PropTypes.func.isRequired,
2623
fetchApplications: React.PropTypes.func.isRequired,
@@ -43,8 +40,28 @@ export default class ApplicationsTable extends Component {
4340
}
4441
}
4542

43+
renderMoveButton(id, direction, row, total) {
44+
const icon = direction === 'up' ? 'icon-budicon-462' : 'icon-budicon-460';
45+
const enabled = (direction === 'up' && row > 1) || (direction === 'down' && row < total);
46+
return (
47+
<li title={direction} data-toggle="tooltip">
48+
<a
49+
href="#" onClick={(e) => {
50+
if (enabled) {
51+
this.props.moveApplication(id, direction);
52+
}
53+
}} className={`move-app ${!enabled ? 'disabled' : ''}`}
54+
>
55+
<i className={icon} />
56+
</a>
57+
</li>
58+
);
59+
}
60+
4661
render() {
47-
const { applications, renderActions, appId } = this.props;
62+
const { applications, appId } = this.props;
63+
const rowsTotal = Object.keys(applications).length;
64+
let rowIndex = 0;
4865
return (
4966
<div>
5067
<Confirm
@@ -63,12 +80,12 @@ export default class ApplicationsTable extends Component {
6380
const application = applications[key];
6481
const logo = application.logo || 'https://cdn.auth0.com/manage/v0.3.1866/img/badge-grey.svg';
6582
const type = application.type;
66-
const callback = application.callback;
6783
const enabled = application.enabled;
6884
const appClassName = `btn btn-publish-app ${enabled ? 'btn-transparent' : 'btn-success'}`;
6985
const appButtonText = enabled ? 'UNPUBLISH' : 'PUBLISH';
7086
const name = application.name || application.client;
7187
const loginUrl = application.loginUrl;
88+
rowIndex++;
7289
return (
7390
<TableRow key={key}>
7491
<TableCell>
@@ -97,6 +114,8 @@ export default class ApplicationsTable extends Component {
97114
<i className="icon-budicon-187" />
98115
</a>
99116
</li>
117+
{this.renderMoveButton(key, 'up', rowIndex, rowsTotal)}
118+
{this.renderMoveButton(key, 'down', rowIndex, rowsTotal)}
100119
<li title="Edit" data-toggle="tooltip">
101120
<Link to={`/applications/${key}`}>
102121
<i className="icon-budicon-329" />

client/constants.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ export const CREATE_APPLICATION_PENDING = 'CREATE_APPLICATION_PENDING';
7777
export const CREATE_APPLICATION_REJECTED = 'CREATE_APPLICATION_REJECTED';
7878
export const CREATE_APPLICATION_FULFILLED = 'CREATE_APPLICATION_FULFILLED';
7979

80+
// Move application
81+
export const MOVE_APPLICATION = 'MOVE_APPLICATION';
82+
export const MOVE_APPLICATION_PENDING = 'MOVE_APPLICATION_PENDING';
83+
export const MOVE_APPLICATION_REJECTED = 'MOVE_APPLICATION_REJECTED';
84+
export const MOVE_APPLICATION_FULFILLED = 'MOVE_APPLICATION_FULFILLED';
85+
8086
// Delete application
8187
export const DELETE_APPLICATION = 'DELETE_APPLICATION';
8288
export const DELETE_APPLICATION_PENDING = 'DELETE_APPLICATION_PENDING';

client/containers/Applications/Applications.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Applications extends Component {
6969
error={error}
7070
applications={apps}
7171
loading={loading}
72+
moveApplication={this.props.moveApplication}
7273
deleteApplication={this.props.deleteApplication}
7374
updateApplication={this.props.updateApplication}
7475
requestDeleteApplication={this.props.requestDeleteApplication}

0 commit comments

Comments
 (0)