Skip to content

Commit ac8d85e

Browse files
feat: add visual distinction in data browser for internal classes and display their real names with underscore (#1878)
1 parent cbce861 commit ac8d85e

9 files changed

+39
-31
lines changed

src/components/CategoryList/CategoryList.react.js

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ export default class CategoryList extends React.Component {
5959
<div ref={this.listWrapperRef} className={styles.class_list}>
6060
{this.props.categories.map((c) => {
6161
let id = c.id || c.name;
62+
if (c.type === 'separator') {
63+
return <hr key={id} className={styles.separator} />;
64+
}
6265
let count = c.count;
6366
let className = id === this.props.current ? styles.active : '';
6467
let link = this.context.generatePath(

src/components/CategoryList/CategoryList.scss

+8-1
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
.class_list {
1111
position: relative;
1212
margin-bottom: 5px;
13+
border-left: 1px solid #3e87b2;
1314

1415
a {
1516
display: block;
1617
padding-left: 12px;
1718
height: 20px;
1819
line-height: 20px;
19-
border-left: 1px solid #3e87b2;
2020
color: #8fb9cf;
2121
font-size: 12px;
2222

@@ -55,3 +55,10 @@
5555
background: white;
5656
transition: top 0.2s cubic-bezier(1, 0, 0, 1);
5757
}
58+
59+
.separator {
60+
margin: 6px 0 6px 12px;
61+
background-color: #3e87b2;
62+
border: 0;
63+
height: 1px;
64+
}

src/dashboard/Data/Browser/AddColumnDialog.react.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ import SegmentSelect from 'components/SegmentSelect/SegmentSelect.react';
2121
import FileInput from 'components/FileInput/FileInput.react';
2222
import styles from 'dashboard/Data/Browser/Browser.scss';
2323
import validateNumeric from 'lib/validateNumeric';
24-
import {
25-
DataTypes,
26-
SpecialClasses
27-
} from 'lib/Constants';
24+
import { DataTypes } from 'lib/Constants';
2825

2926
function validColumnName(name) {
3027
return !!name.match(/^[a-zA-Z][_a-zA-Z0-9]*$/);
@@ -100,7 +97,7 @@ export default class AddColumnDialog extends React.Component {
10097
<Dropdown
10198
value={this.state.target}
10299
onChange={(target) => this.setState({ target: target })}>
103-
{this.props.classes.map((c) => <Option key={c} value={c}>{SpecialClasses[c] || c}</Option>)}
100+
{this.props.classes.map((c) => <Option key={c} value={c}>{c}</Option>)}
104101
</Dropdown>
105102
);
106103
}

src/dashboard/Data/Browser/AttachSelectedRowsDialog.react.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import Label from 'components/Label/Label.react';
55
import TextInput from 'components/TextInput/TextInput.react';
66
import Dropdown from 'components/Dropdown/Dropdown.react';
77
import Option from 'components/Dropdown/Option.react';
8-
import { SpecialClasses } from 'lib/Constants';
98

109
export default class AttachSelectedRowsDialog extends React.Component {
1110
constructor(props) {
@@ -147,7 +146,7 @@ export default class AttachSelectedRowsDialog extends React.Component {
147146
>
148147
{classes.map(className => (
149148
<Option key={className} value={className}>
150-
{SpecialClasses[className] || className}
149+
{className}
151150
</Option>
152151
))}
153152
</Dropdown>

src/dashboard/Data/Browser/Browser.react.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1379,14 +1379,17 @@ class Browser extends DashboardView {
13791379
} else if (count >= 1000) {
13801380
count = prettyNumber(count);
13811381
}
1382-
if (SpecialClasses[key]) {
1383-
special.push({ name: SpecialClasses[key], id: key, count: count });
1382+
if (SpecialClasses.includes(key)) {
1383+
special.push({ name: key, id: key, count: count });
13841384
} else {
13851385
categories.push({ name: key, count: count });
13861386
}
13871387
});
13881388
special.sort((a, b) => stringCompare(a.name, b.name));
13891389
categories.sort((a, b) => stringCompare(a.name, b.name));
1390+
if (special.length > 0 && categories.length > 0) {
1391+
special.push({ type: 'separator', id: 'classSeparator' })
1392+
}
13901393
return (
13911394
<CategoryList
13921395
current={current}
@@ -1621,7 +1624,7 @@ class Browser extends DashboardView {
16211624
} else if (this.state.rowsToDelete) {
16221625
extras = (
16231626
<DeleteRowsDialog
1624-
className={SpecialClasses[className] || className}
1627+
className={className}
16251628
selection={this.state.rowsToDelete}
16261629
relation={this.state.relation}
16271630
onCancel={() => this.setState({ rowsToDelete: null })}
@@ -1738,7 +1741,7 @@ class Browser extends DashboardView {
17381741
} else if (this.state.rowsToExport) {
17391742
extras = (
17401743
<ExportSelectedRowsDialog
1741-
className={SpecialClasses[className] || className}
1744+
className={className}
17421745
selection={this.state.rowsToExport}
17431746
onCancel={this.cancelExportSelectedRows}
17441747
onConfirm={() => this.confirmExportSelectedRows(this.state.rowsToExport)}

src/dashboard/Data/Browser/CreateClassDialog.react.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ export default class CreateClassDialog extends React.Component {
4646

4747
render() {
4848
let availableClasses = ['Custom'];
49-
for (let raw in SpecialClasses) {
50-
if (raw !== '_Session' && this.props.currentClasses.indexOf(raw) < 0) {
51-
availableClasses.push(SpecialClasses[raw]);
49+
for (let raw of SpecialClasses) {
50+
if (raw !== '_Session' && !this.props.currentClasses.includes(raw)) {
51+
availableClasses.push(raw);
5252
}
5353
}
5454

src/dashboard/Data/Browser/DataBrowser.react.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import * as ColumnPreferences from 'lib/ColumnPreferences';
1313
import ParseApp from 'lib/ParseApp';
1414
import React from 'react';
1515
import PropTypes from 'lib/PropTypes';
16-
import { SpecialClasses } from 'lib/Constants';
1716

1817
/**
1918
* DataBrowser renders the browser toolbar and data table
@@ -200,7 +199,7 @@ export default class DataBrowser extends React.Component {
200199
e.preventDefault();
201200
break;
202201
case 37:
203-
// Left - standalone (move to the next visible column on the left)
202+
// Left - standalone (move to the next visible column on the left)
204203
// or with ctrl/meta (excel style - move to the first visible column)
205204
this.setState({
206205
current: {
@@ -212,7 +211,7 @@ export default class DataBrowser extends React.Component {
212211
e.preventDefault();
213212
break;
214213
case 38:
215-
// Up - standalone (move to the previous row)
214+
// Up - standalone (move to the previous row)
216215
// or with ctrl/meta (excel style - move to the first row)
217216
this.setState({
218217
current: {
@@ -223,7 +222,7 @@ export default class DataBrowser extends React.Component {
223222
e.preventDefault();
224223
break;
225224
case 39:
226-
// Right - standalone (move to the next visible column on the right)
225+
// Right - standalone (move to the next visible column on the right)
227226
// or with ctrl/meta (excel style - move to the last visible column)
228227
this.setState({
229228
current: {
@@ -235,7 +234,7 @@ export default class DataBrowser extends React.Component {
235234
e.preventDefault();
236235
break;
237236
case 40:
238-
// Down - standalone (move to the next row)
237+
// Down - standalone (move to the next row)
239238
// or with ctrl/meta (excel style - move to the last row)
240239
this.setState({
241240
current: {
@@ -322,7 +321,7 @@ export default class DataBrowser extends React.Component {
322321
<BrowserToolbar
323322
count={count}
324323
hidePerms={className === '_Installation'}
325-
className={SpecialClasses[className] || className}
324+
className={className}
326325
classNameForEditors={className}
327326
setCurrent={this.setCurrent}
328327
enableDeleteAllRows={this.context.currentApp.serverInfo.features.schemas.clearAllDataFromClass && !preventSchemaEdits}

src/dashboard/Data/Browser/SchemaOverview.react.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class Browser extends DashboardView {
4949
} else if (count >= 1000) {
5050
count = prettyNumber(count);
5151
}
52-
if (SpecialClasses[key]) {
53-
special.push({ name: SpecialClasses[key], id: key, count: count });
52+
if (SpecialClasses.includes(key)) {
53+
special.push({ name: key, id: key, count: count });
5454
} else {
5555
categories.push({ name: key, count: count });
5656
}

src/lib/Constants.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ export const Directions = {
4545
LEFT: 'LEFT'
4646
};
4747

48-
export const SpecialClasses = {
49-
_User: 'User',
50-
_Installation: 'Installation',
51-
_Role: 'Role',
52-
_Product: 'Product',
53-
_Session: 'Session',
54-
_PushStatus: 'PushStatus',
55-
};
48+
export const SpecialClasses = [
49+
'_User',
50+
'_Installation',
51+
'_Role',
52+
'_Product',
53+
'_Session',
54+
'_PushStatus',
55+
];
5656

5757
export const DefaultColumns = {
5858
All: [ 'objectId', 'ACL', 'createdAt', 'updatedAt' ],

0 commit comments

Comments
 (0)