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 packages/compass-collections-ddl/config/webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ const config = {
.on('close', () => process.exit(0))
.on('error', spawnError => console.error(spawnError)); // eslint-disable-line no-console
}
},
externals: {
'mongodb-client-encryption': 'commonjs2 mongodb-client-encryption'
}
};

Expand Down
38 changes: 29 additions & 9 deletions packages/compass-collections-ddl/electron/renderer/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
/* eslint-disable no-console */
import React from 'react';
import ReactDOM from 'react-dom';
import app from 'hadron-app';
import AppRegistry from 'hadron-app-registry';
import { AppContainer } from 'react-hot-loader';
import DatabasePlugin, { activate } from 'plugin';
import { activate as daActivate } from '@mongodb-js/compass-deployment-awareness';
import { NamespaceStore } from 'mongodb-reflux-store';
import CollectionStore from './stores/collection-store';
import CollectionModel from 'mongodb-collection-model';
import CreateCollectionPlugin from 'components/create-collection-plugin';
import DropCollectionPlugin from 'components/drop-collection-plugin';

import CollectionStore from './mocks/collection-store';
import TextWriteButton from './mocks/text-write-button';

// Import global less file. Note: these styles WILL NOT be used in compass, as compass provides its own set
// of global styles. If you are wishing to style a given component, you should be writing a less file per
// component as per the CSS Modules ICSS spec. @see src/components/toggle-button for an example.
Expand All @@ -24,10 +26,10 @@ global.hadronApp.appRegistry = appRegistry;

appRegistry.registerStore('App.NamespaceStore', NamespaceStore);
appRegistry.registerStore('App.CollectionStore', CollectionStore);
appRegistry.registerComponent('DeploymentAwareness.TextWriteButton', TextWriteButton);

// Activate our plugin with the Hadron App Registry
activate(appRegistry);
daActivate(appRegistry);
appRegistry.onActivated();

// Since we are using HtmlWebpackPlugin WITHOUT a template,
Expand Down Expand Up @@ -64,10 +66,11 @@ import Connection from 'mongodb-connection-model';
import DataService from 'mongodb-data-service';

const connection = new Connection({
hostname: '127.0.0.1',
hostname: 'localhost',
port: 27017,
ns: 'admin'
});

const dataService = new DataService(connection);

appRegistry.emit('data-service-initialized', dataService);
Expand All @@ -76,12 +79,18 @@ dataService.connect((error, ds) => {
dataService.instance({}, (err, data) => {
const dbs = data.databases;
dbs.forEach((db) => {
db.collections = db.collections.map((collection) => {
return new CollectionModel(collection);
});
db.collections = db.collections
.filter(({ name }) => name && !name.startsWith('system.'))
.map((collection) => {
return new CollectionModel(collection);
});
});

if (err) console.log(err);
if (err) {
console.log(err);
process.exit(1);
}

appRegistry.emit('instance-refreshed', {
instance: {
databases: {
Expand All @@ -90,7 +99,18 @@ dataService.connect((error, ds) => {
dataLake: { isDataLake: false }
}
});
appRegistry.emit('database-changed', 'echo');


dataService.client.client.db('admin').command({buildinfo: 1}, (buildInfoError, info) => {
if (buildInfoError) {
console.log(buildInfoError);
return;
}

appRegistry.emit('server-version-changed', info.version);
});

appRegistry.emit('select-database', 'test');
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import React from 'react';
import PropTypes from 'prop-types';
import { TextButton } from 'hadron-react-buttons';
import { Tooltip } from 'hadron-react-components';

/**
* The wrapper class.
*/
const WRAPPER = 'tooltip-button-wrapper';

/**
* Button component that is aware of the write state of the application.
* This button contains only text, no icons, no animations.
*/
class TextWriteButton extends React.Component {
static displayName = 'TextWriteButton';

static propTypes = {
className: PropTypes.string.isRequired,
clickHandler: PropTypes.func.isRequired,
dataTestId: PropTypes.string,
isCollectionLevel: PropTypes.bool,
text: PropTypes.string.isRequired,
tooltipId: PropTypes.string.isRequired
}

/**
* Subscribe to the state changing stores.
*/
componentDidMount() {
}

/**
* Unsubscribe from the stores.
*/
componentWillUnmount() {
this.unsubscribeWriteState();
}

/**
* Determine if the application is in a writable state.
*
* @returns {Boolean} If the application is writable.
*/
isWritable() {
const isWritable = true;
return isWritable;
}

/**
* Handle write state changes.
*
* @param {Object} state - The write state.
*/
writeStateChanged(state) {
this.setState(state);
}

/**
* Get the tooltip text.
*
* @returns {String} The tooltip text.
*/
tooltipText() {
if (!this.isWritable()) {
return 'Not writable';
}
}

/**
* Render the component.
*
* @returns {React.Component} The rendered component.
*/
render() {
const tooltip = (this.isWritable()) ? null : (<Tooltip id={this.props.tooltipId} />);
return (
<div className={WRAPPER} data-tip={this.tooltipText()} data-for={this.props.tooltipId}>
<TextButton
className={this.props.className}
dataTestId={this.props.dataTestId}
disabled={!this.isWritable()}
clickHandler={this.props.clickHandler}
text={this.props.text} />
{tooltip}
</div>
);
}
}

export default TextWriteButton;

This file was deleted.

Loading