Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract out ui-components dropdown #6452

Merged
merged 6 commits into from
Feb 14, 2020
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
10 changes: 4 additions & 6 deletions packages/desktop-gui/cypress/integration/login_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ describe('Login', function () {
})

it('displays username in UI', function () {
cy.get('nav a').should(function ($a) {
expect($a).to.contain(this.user.name)
})
cy.get('.user-dropdown .dropdown-chosen').should('contain', this.user.name)
})

it('displays username in success dialog', () => {
Expand All @@ -117,22 +115,22 @@ describe('Login', function () {

context('log out', function () {
it('displays login button on logout', () => {
cy.get('nav a').contains('Jane').click()
cy.get('.user-dropdown .dropdown-chosen').contains('Jane').click()

cy.contains('Log Out').click()
cy.get('.nav').contains('Log In')
})

it('calls log:out', function () {
cy.get('nav a').contains('Jane').click()
cy.get('.user-dropdown .dropdown-chosen').contains('Jane').click()

cy.contains('Log Out').click().then(function () {
expect(this.ipc.logOut).to.be.called
})
})

it('has login button enabled when returning to login after logout', function () {
cy.get('nav a').contains('Jane').click()
cy.get('.user-dropdown .dropdown-chosen').contains('Jane').click()
cy.contains('Log Out').click()
cy.contains('Log In').click()

Expand Down
4 changes: 2 additions & 2 deletions packages/desktop-gui/cypress/integration/nav_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('Navigation', function () {
})

it('displays user name', () => {
cy.get('nav a').should(function ($a) {
cy.get('.user-dropdown .dropdown-chosen').should(function ($a) {
expect($a).to.contain(this.user.name)
})
})
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('Navigation', function () {
})

it('displays email instead of name', () => {
cy.get('nav a').should(function ($a) {
cy.get('.user-dropdown .dropdown-chosen').should(function ($a) {
expect($a).to.contain(this.user.email)
})
})
Expand Down
5 changes: 2 additions & 3 deletions packages/desktop-gui/src/app/nav.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { observer } from 'mobx-react'
import React, { Component } from 'react'
import { Dropdown } from '@packages/ui-components'

import appStore from '../lib/app-store'
import authApi from '../auth/auth-api'
Expand All @@ -9,8 +10,6 @@ import ipc from '../lib/ipc'
import { gravatarUrl } from '../lib/utils'
import { Link, routes } from '../lib/routing'

import Dropdown from '../dropdown/dropdown'

@observer
export default class Nav extends Component {
render () {
Expand Down Expand Up @@ -87,7 +86,7 @@ export default class Nav extends Component {

return (
<Dropdown
className='dropdown-toggle'
className='user-dropdown'
chosen={{ id: 'user' }}
others={[{ id: 'logout' }]}
onSelect={this._select}
Expand Down
22 changes: 17 additions & 5 deletions packages/desktop-gui/src/app/nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@
}

.nav {
> .open {
> a, > a:hover, > a:focus {
.dropdown-chosen {
&:hover, &:focus {
background-color: #111;
color: #fff;
}
Expand All @@ -140,6 +140,13 @@
font-size: 12px;
}

.dropdown-menu > li {
line-height: 30px;
font-size: 14px;
padding: 5px 15px;
}

.dropdown-chosen,
> li > div,
> li > a,
> li > span > a {
Expand All @@ -150,6 +157,7 @@
display: inline-block;
}

.dropdown-chosen,
> li > a,
> li > span > a {
&:hover,
Expand All @@ -163,23 +171,27 @@

.browsers-list {
margin: 5px;
border: 1px solid #c7c7c7;
border-radius: 4px;

li {
padding: 9px 15px;
white-space: nowrap;
}

&>a.dropdown-chosen {
.dropdown-chosen {
border-radius: 4px;
border: 1px solid #c7c7c7;
line-height: 28px !important;
background-color: #f6f6f6;

img {
position: relative;
top: -1px;
}

&.disabled,
&:active {
background-color: #dedede;
}
}

.fa-check-circle, .fa-sync-alt {
Expand Down
1 change: 1 addition & 0 deletions packages/desktop-gui/src/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
@import 'styles/vendor';
@import 'styles/components/*';
@import '!(styles)*/**/*';
@import '../../ui-components/src/dropdown';
4 changes: 1 addition & 3 deletions packages/desktop-gui/src/project-nav/browsers.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, { Component } from 'react'
import { observer } from 'mobx-react'
import Tooltip from '@cypress/react-tooltip'
import { BrowserIcon } from '@packages/ui-components'
import { BrowserIcon, Dropdown } from '@packages/ui-components'

import Dropdown from '../dropdown/dropdown'
import MarkdownRenderer from '../lib/markdown-renderer'

import projectsApi from '../projects/projects-api'

@observer
Expand Down
54 changes: 0 additions & 54 deletions packages/runner/src/dropdown/dropdown.jsx

This file was deleted.

78 changes: 0 additions & 78 deletions packages/runner/src/dropdown/dropdown.scss

This file was deleted.

20 changes: 19 additions & 1 deletion packages/runner/src/errors/errors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,29 @@
top: -1px;

&.fa-globe {
top: 0;
top: 0;
}
}
}

&.automation-failure {
.browser-icon {
margin-right: 5px;
vertical-align: middle;
position: relative;
top: -1px;
}

.dropdown-toggle {
margin-left: 5px;
}

.dropdown-menu li {
padding: 8px 12px;
white-space: nowrap;
}
}

.automation-disconnected button {
font-size: 18px;
line-height: 1.3;
Expand Down
5 changes: 2 additions & 3 deletions packages/runner/src/errors/no-automation.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import _ from 'lodash'
import React from 'react'
import { BrowserIcon } from '@packages/ui-components'

import Dropdown from '../dropdown/dropdown'
import { BrowserIcon, Dropdown } from '@packages/ui-components'

const displayName = (name) => _.capitalize(name)

Expand Down Expand Up @@ -42,6 +40,7 @@ const browserPicker = (browsers, onLaunchBrowser) => {
others={otherBrowsers}
onSelect={onLaunchBrowser}
renderItem={browser}
keyProperty='key'
/>
</div>
)
Expand Down
1 change: 1 addition & 0 deletions packages/runner/src/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
@import 'lib/shared';
@import '!(lib)*/**/!(selector-playground.scss)';

@import '../../ui-components/src/dropdown';
@import '../../reporter/src/main-runner';
Loading