Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/internal-packages/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const app = require('ampersand-app');
const StoreConnector = require('./lib/components/store-connector');
const SortableTable = require('./lib/components/sortable-table');
const TabNavBar = require('./lib/components/tab-nav-bar');
const StatusRow = require('./lib/components/status-row');
const InstanceActions = require('./lib/actions/instance-actions');
const InstanceStore = require('./lib/stores/instance-store');
const CollectionStore = require('./lib/stores/collection-store');
Expand All @@ -15,6 +16,7 @@ function activate() {
app.appRegistry.registerComponent('App.SortableTable', SortableTable);
app.appRegistry.registerComponent('App.ModalStatusMessage', ModalStatusMessage);
app.appRegistry.registerComponent('App.TabNavBar', TabNavBar);
app.appRegistry.registerComponent('App.StatusRow', StatusRow);
app.appRegistry.registerAction('App.InstanceActions', InstanceActions);
app.appRegistry.registerStore('App.InstanceStore', InstanceStore);
app.appRegistry.registerStore('App.CollectionStore', CollectionStore);
Expand All @@ -28,6 +30,7 @@ function deactivate() {
app.appRegistry.deregisterComponent('App.SortableTable');
app.appRegistry.deregisterComponent('App.ModalStatusMessage');
app.appRegistry.deregisterComponent('App.TabNavBar');
app.appRegistry.deregisterComponent('App.StatusRow');
app.appRegistry.deregisterAction('App.InstanceActions');
app.appRegistry.deregisterStore('App.InstanceStore');
app.appRegistry.deregisterStore('App.CollectionStore');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,27 @@ class StatusRow extends React.Component {
* @returns {React.Component} The component.
*/
render() {
let className = 'status-row';
if (this.props.style !== 'default') {
className += ` status-row-has-${this.props.style}`;
}
return (
<div className="status-row">
{this.props.children}
<div className={className}>
{this.props.children}
</div>
);
}
}

StatusRow.propTypes = {
style: React.PropTypes.oneOf(['default', 'warning', 'error']),
children: React.PropTypes.node
};

StatusRow.defaultProps = {
style: 'default'
};

StatusRow.displayName = 'StatusRow';

module.exports = StatusRow;
1 change: 1 addition & 0 deletions src/internal-packages/app/styles/index.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import './sortable-table.less';
@import './modal-status-message.less';
@import './tab-nav-bar.less';
@import './status-row.less';
23 changes: 23 additions & 0 deletions src/internal-packages/app/styles/status-row.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.status-row {
display: flex;
flex-wrap: nowrap;
align-items: center;
padding: 5px 12px;

min-height: 26px;
border-bottom: 1px solid @gray7;

font-size: 13px;
font-weight: 200;

background-color: @gray8;
color: #000;
span, div, p {
display: inline-block;
}
}

.status-row-has-warning {
background-color: #FEE9C3;
color: #7F6A4E;
}
37 changes: 26 additions & 11 deletions src/internal-packages/explain/lib/components/compass-explain.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const React = require('react');
const app = require('ampersand-app');
const ExplainBody = require('./explain-body');
const ExplainHeader = require('./explain-header');

const StatusRow = app.appRegistry.getComponent('App.StatusRow');
// const debug = require('debug')('mongodb-compass:explain');

/**
Expand All @@ -20,6 +20,11 @@ const ExplainHeader = require('./explain-header');
* .explain-json (mutually exclusive with .explain-tree)
*/

const READ_ONLY_WARNING = 'Explain plans on readonly views are not supported.';

const COLLECTION_SCAN_WARNING = 'To prevent unintended collection scans, please'
+ ' enter your query first before applying and viewing your explain plan.';

class CompassExplain extends React.Component {

constructor(props) {
Expand All @@ -31,7 +36,15 @@ class CompassExplain extends React.Component {
this.queryBar = app.appRegistry.getComponent('Query.QueryBar');
}

renderComponent() {
renderWarning(warning) {
return (
<StatusRow style="warning">
{warning}
</StatusRow>
);
}

renderContent() {
return (
<div className="column-container with-refinebar">
<div className="column main">
Expand All @@ -54,24 +67,26 @@ class CompassExplain extends React.Component {
);
}

renderReadonly() {
return (
<div className="compass-explain-notice">
Explain plans on readonly views are not supported.
</div>
);
}

/**
* Render Explain.
*
* @returns {React.Component} The Explain view.
*/
render() {
let content;

if (this.CollectionStore.isReadonly()) {
content = this.renderWarning(READ_ONLY_WARNING);
} else if (this.props.explainState === 'initial') {
content = this.renderWarning(COLLECTION_SCAN_WARNING);
} else {
content = this.renderContent();
}

return (
<div className="compass-explain header-margin">
<this.queryBar />
{this.CollectionStore.isReadonly() ? this.renderReadonly() : this.renderComponent()}
{content}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const React = require('react');
const ExplainSummary = require('./explain-summary');
const app = require('ampersand-app');

const ViewSwitcher = require('./shared/view-switcher');
const StatusRow = require('./shared/status-row');
const StatusRow = app.appRegistry.getComponent('App.StatusRow');

const ExplainActions = require('../actions');

Expand Down
8 changes: 0 additions & 8 deletions src/internal-packages/explain/styles/compass-explain.less
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
.compass-explain {

&-notice {
color: steelblue;
background-color: #b0e0e6;
border-radius: 5px;
padding: 15px;
margin-bottom: 10px;
}

// hacks for json view on explain tab
ol.document-list li.document-list-item ol.document-property-body li.document-property.array ol.document-property-body .document-property-key,
ol.document-list li.document-list-item ol.document-property-body li.document-property.object ol.document-property-body .document-property-key {
Expand Down
1 change: 0 additions & 1 deletion src/internal-packages/explain/styles/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@

// shared components
@import './shared/view-switcher.less';
@import './shared/status-row.less';
@import './shared/palette.less';
14 changes: 0 additions & 14 deletions src/internal-packages/explain/styles/shared/status-row.less

This file was deleted.

5 changes: 3 additions & 2 deletions src/internal-packages/indexes/lib/component/indexes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const IndexList = require('./index-list');
const CreateIndexButton = require('./create-index-button');
const LoadIndexesStore = require('../store/load-indexes-store');
const app = require('ampersand-app');
const StatusRow = app.appRegistry.getComponent('App.StatusRow');

/**
* Component for the indexes.
Expand Down Expand Up @@ -67,9 +68,9 @@ class Indexes extends React.Component {

renderReadonly() {
return (
<div className="index-container-notice">
<StatusRow style="warning">
Readonly views may not contain indexes.
</div>
</StatusRow>
);
}

Expand Down
8 changes: 0 additions & 8 deletions src/internal-packages/indexes/styles/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@

.index-container {

&-notice {
color: steelblue;
background-color: #b0e0e6;
border-radius: 5px;
padding: 15px;
margin-bottom: 10px;
}

.column-container {
.column.main {
&::-webkit-scrollbar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class StatusRow extends React.Component {
*/
render() {
return (
<Row className="status-row">
<Row className="validation-status-row">
<Col lg={12} md={12} sm={12} xs={12}>
{this.props.children}
</Col>
Expand Down
11 changes: 6 additions & 5 deletions src/internal-packages/validation/lib/components/validation.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const app = require('ampersand-app');
const React = require('react');
const ValidationActions = require('../actions');
const StatusRow = require('./common/status-row');
const ValidationStatusRow = require('./common/status-row');
const ViewSwitcher = require('./common/view-switcher');
const RuleBuilder = require('./rule-builder');
const JSONView = require('./json-view');
const StatusRow = app.appRegistry.getComponent('App.StatusRow');

const Grid = require('react-bootstrap').Grid;

Expand Down Expand Up @@ -69,25 +70,25 @@ class Validation extends React.Component {

return (
<Grid fluid>
<StatusRow>
<ValidationStatusRow>
<ViewSwitcher
label="View as:"
buttonLabels={['Rule Builder', 'JSON']}
activeButton={activeButton}
onClick={this.switchView.bind(this)}
disabled={!this.props.isExpressibleByRules}
/>
</StatusRow>
</ValidationStatusRow>
{view}
</Grid>
);
}

renderReadonly() {
return (
<div className="validation-notice">
<StatusRow style="warning">
Document validation rules may not be added to readonly views.
</div>
</StatusRow>
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/internal-packages/validation/styles/index.less
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// import your less files here, one per component
@import './validation.less';
@import './view-switcher.less';
@import './status-row.less';
@import './rule-builder.less';
@import './json-view.less';
@import './option-selector.less';
@import './editable.less';
@import './json-input.less';
@import './validation-status-row.less';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.status-row {
.validation-status-row {
display: flex;
flex-wrap: nowrap;
align-items: center;
Expand Down
8 changes: 0 additions & 8 deletions src/internal-packages/validation/styles/validation.less
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
.validation {

&-notice {
color: steelblue;
background-color: #b0e0e6;
border-radius: 5px;
padding: 15px;
margin-bottom: 10px;
}

&-rule-builder-wrapper {
// TODO work-around so that the dropdowns can be shown, otherwise they get cut off.
padding-bottom: 150px;
Expand Down