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
9 changes: 6 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ import { gold } from '../../compass-ui-colors';
export function FavoriteIcon({
// When it's a favorite, the star is filled in with gold.
isFavorite = false,
favoriteColor = gold,
darkMode = false,
showCircle = true,
size = spacing[4],
}: {
isFavorite?: boolean;
favoriteColor?: string;
darkMode?: boolean;
showCircle?: boolean;
size?: number;
}): React.ReactElement {
const stroke = darkMode ? uiColors.white : uiColors.black;
Expand All @@ -24,15 +28,18 @@ export function FavoriteIcon({
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
{showCircle && (
<path
d="M12 22.6667C17.891 22.6667 22.6667 17.891 22.6667 12C22.6667 6.10897 17.891 1.33334 12 1.33334C6.10897 1.33334 1.33334 6.10897 1.33334 12C1.33334 17.891 6.10897 22.6667 12 22.6667Z"
stroke={stroke}
strokeMiterlimit="10"
/>
)}
<path
d="M12 22.6667C17.891 22.6667 22.6667 17.891 22.6667 12C22.6667 6.10897 17.891 1.33334 12 1.33334C6.10897 1.33334 1.33334 6.10897 1.33334 12C1.33334 17.891 6.10897 22.6667 12 22.6667Z"
stroke={stroke}
strokeMiterlimit="10"
/>
<path
id="favoriteIconStar"
d="M11.9195 15.6372L8.89689 17.3104C8.77598 17.3831 8.62053 17.274 8.63781 17.1103L9.20779 13.5639C9.22506 13.5094 9.19051 13.4366 9.15597 13.4003L6.7206 10.8905C6.61697 10.7814 6.66879 10.5995 6.82424 10.5813L10.2096 10.0721C10.2614 10.0721 10.3132 10.0175 10.3477 9.98118L11.8677 6.76215C11.9368 6.63485 12.1095 6.63485 12.1786 6.76215L13.664 9.96299C13.6813 10.0175 13.7331 10.0539 13.8022 10.0539L17.1875 10.5631C17.3257 10.5813 17.3775 10.7632 17.2911 10.8723L14.8212 13.4003C14.7867 13.4366 14.7694 13.5094 14.7694 13.5639L15.3394 17.1103C15.3567 17.2558 15.2185 17.3649 15.0803 17.3104L12.075 15.6372C12.0231 15.6008 11.9713 15.6008 11.9195 15.6372Z"
stroke={isFavorite ? gold : stroke}
fill={isFavorite ? gold : 'none'}
stroke={isFavorite ? favoriteColor : stroke}
fill={isFavorite ? favoriteColor : 'none'}
strokeMiterlimit="10"
/>
</svg>
Expand Down
14 changes: 4 additions & 10 deletions packages/compass-home/src/components/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { css } from '@mongodb-js/compass-components';
import {
ConnectionInfo,
DataService,
convertConnectionInfoToModel,
getConnectionTitle,
} from 'mongodb-data-service';
import toNS from 'mongodb-ns';
Expand Down Expand Up @@ -114,22 +113,17 @@ function Home({ appName }: { appName: string }): React.ReactElement | null {

// TODO: Remove this comment once we only have one connections package:
// This is currently only used by the new connections package.
// We've moved to not calling the `data-service-connected` event inside
// of connections and instead call it here.
async function onConnected(
// We've moved to calling the `data-service-connected` event here instead
// of inside `connections`/`compass-connect` and instead call it here.
function onConnected(
connectionInfo: ConnectionInfo,
dataService: DataService
) {
const legacyConnectionModel = await convertConnectionInfoToModel(
connectionInfo
);

appRegistry.emit(
'data-service-connected',
null, // No error connecting.
dataService,
connectionInfo,
legacyConnectionModel // TODO: Remove this once we remove the dependency in compass-sidebar.
connectionInfo
);
}

Expand Down
7 changes: 5 additions & 2 deletions packages/compass-sidebar/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = (config) => {
singleRun: true,
files: ['test/karma-setup.js'],
reporters: ['mocha'],
preprocessors: { 'test/karma-setup.js': ['webpack', 'sourcemap', 'electron'] },
preprocessors: { 'test/karma-setup.js': ['webpack', 'sourcemap'] },
browsers: ['Compass'],
frameworks: ['mocha', 'chai', 'sinon', 'chai-sinon'],
webpack: webpackConfig,
Expand All @@ -28,9 +28,12 @@ module.exports = (config) => {
customLaunchers: {
Compass: {
base: 'Electron',
flags: ['--no-sandbox'],
browserWindowOptions: {
webPreferences: {
nodeIntegration: true
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions packages/compass-sidebar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"start:watch": "npm run clean && webpack --config ./config/webpack.watch.config.js",
"test": "cross-env NODE_ENV=test mocha-webpack \"./src/**/*.spec.js\"",
"test:watch": "cross-env NODE_ENV=test mocha-webpack \"./src/**/*.spec.js\" --watch",
"test:karma": "npm run prestart && xvfb-maybe cross-env NODE_ENV=test karma start",
"test:karma": "xvfb-maybe cross-env NODE_ENV=test karma start",
"cover": "nyc npm run test",
"test-check-ci": "npm run cover && npm run test:karma && npm run compile && npm run check",
"check": "npm run lint && npm run depcheck",
Expand All @@ -30,8 +30,9 @@
"license": "SSPL",
"peerDependencies": {
"@mongodb-js/compass-components": "^0.9.1",
"@mongodb-js/compass-connect": "^7.17.1",
"@mongodb-js/connect-form": "^0.4.1",
"debug": "*",
"mongodb-data-service": "^21.15.1",
"prop-types": "^15.7.2",
"react": "^16.14.0",
"react-bootstrap": "^0.32.1",
Expand All @@ -51,11 +52,11 @@
"@hot-loader/react-dom": "^16.9.0",
"@mongodb-js/compass-app-stores": "^5.17.1",
"@mongodb-js/compass-components": "^0.9.1",
"@mongodb-js/compass-connect": "^7.17.1",
"@mongodb-js/compass-databases-navigation": "^0.3.1",
"@mongodb-js/compass-deployment-awareness": "^11.17.1",
"@mongodb-js/compass-server-version": "^5.17.1",
"@mongodb-js/compass-ssh-tunnel-status": "^6.17.1",
"@mongodb-js/connect-form": "^0.4.1",
"autoprefixer": "^9.4.6",
"babel-loader": "^8.2.2",
"chai": "^4.2.0",
Expand Down Expand Up @@ -136,6 +137,7 @@
"xvfb-maybe": "^0.2.1"
},
"dependencies": {
"@mongodb-js/compass-logging": "^0.6.1",
"@mongodb-js/mongodb-redux-common": "^1.7.0"
},
"homepage": "https://github.com/mongodb-js/compass",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
FavoriteIcon,
mergeProps,
useFocusRing
} from '@mongodb-js/compass-components';

import styles from './favorite-button.module.less';

const FavoriteButton = ({
favoriteOptions,
toggleIsFavoriteModalVisible
}) => {
const isFavorite = !!favoriteOptions;
const hex = favoriteOptions?.color;
const style = {
backgroundColor: hex || '#243642',
color: isFavorite ? '#ffffff' : '#88989a'
};

const focusRingProps = useFocusRing();
const buttonProps = mergeProps({
type: 'button',
'aria-label': 'Edit saved connection',
title: 'Edit saved connection',
onClick: () => toggleIsFavoriteModalVisible(),
className: styles['favorite-button-text'],
style
}, focusRingProps);

return (
<div className={styles['favorite-button']}>
<button
{...buttonProps}
>
<FavoriteIcon
darkMode
isFavorite={isFavorite}
favoriteColor="#ffffff"
showCircle={false}
size={18}
/>
FAVORITE
</button>
</div>
);
};

FavoriteButton.displayName = 'FavoriteButton';
FavoriteButton.propTypes = {
// Can be undefined. See ConnectionFavoriteOptions of ConnectionInfo.
favoriteOptions: PropTypes.object,
toggleIsFavoriteModalVisible: PropTypes.func.isRequired
};

export default FavoriteButton;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.is-favorite-pill {
.favorite-button {
font-size: 11px;
padding: 0px 0px 12px 36px;
align-items: center;
Expand All @@ -7,11 +7,13 @@

&-text {
text-transform: uppercase;
display: flex;
align-items: center;
flex-direction: row;
border-radius: 14px;
border-style: solid;
border-width: 1px;
border-color: transparent;
padding: 3px 10px;
border: none;
padding: 2px 11px;
padding-left: 6px;
margin-right: 5px;
font-weight: bold;
cursor: pointer;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import { mount } from 'enzyme';
import FavoriteButton from './favorite-button';

import styles from './favorite-button.module.less';

describe('FavoriteButton [Component]', () => {
context('when it is a new connection', () => {
let component;

beforeEach(() => {
component = mount(
<FavoriteButton
toggleIsFavoriteModalVisible={()=>{}}
favoriteOptions={undefined}
/>
);
});

afterEach(() => {
component = null;
});

it('displays the the default button without star filled in', () => {
expect(component.find(`.${styles['favorite-button']}`)).to.be.present();
expect(component.find(`.${styles['favorite-button-text']}`)).to.be.present();
let starStyle = component.find('#favoriteIconStar').get(0).props;
expect(starStyle).to.have.property('fill', 'none');
});
});

context('when it is a saved with no color', () => {
let component;

beforeEach(() => {
component = mount(
<FavoriteButton
toggleIsFavoriteModalVisible={()=>{}}
favoriteOptions={{
name: '123',
color: undefined
}}
/>
);
});

afterEach(() => {
component = null;
});

it('displays the the filled in star', () => {
expect(component.find(`.${styles['favorite-button']}`)).to.be.present();
expect(component.find(`.${styles['favorite-button-text']}`)).to.be.present();

let starStyle = component.find('#favoriteIconStar').get(0).props;
expect(starStyle).to.have.property('fill', '#ffffff');
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import FavoriteButton from './favorite-button';
export default FavoriteButton;

This file was deleted.

This file was deleted.

Loading