This repository has been archived by the owner on Jun 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Project Path field to new project flow (#70)
- Loading branch information
1 parent
802ee93
commit 79d88c6
Showing
12 changed files
with
225 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// @flow | ||
import React, { PureComponent } from 'react'; | ||
import styled from 'styled-components'; | ||
import { connect } from 'react-redux'; | ||
import { changeProjectHomePath } from '../../actions'; | ||
import { getProjectHomePath } from '../../reducers/paths.reducer'; | ||
import TextButton from '../TextButton'; | ||
import { Tooltip } from 'react-tippy'; | ||
import { COLORS } from '../../constants'; | ||
const { dialog } = window.require('electron').remote; | ||
|
||
type Props = { | ||
defaultProjectHome: string, | ||
changeProjectHomePath: (path: string) => void, | ||
}; | ||
|
||
class ProjectPath extends PureComponent<Props> { | ||
updatePath = () => { | ||
dialog.showOpenDialog( | ||
{ | ||
message: 'Select the directory of Project', | ||
properties: ['openDirectory'], | ||
}, | ||
(paths: ?[string]) => { | ||
// The user might cancel out without selecting a directory. | ||
// In that case, do nothing. | ||
if (!paths) { | ||
return; | ||
} | ||
|
||
// Only a single path should be selected | ||
const [path] = paths; | ||
this.props.changeProjectHomePath(path); | ||
} | ||
); | ||
}; | ||
|
||
render() { | ||
const { defaultProjectHome } = this.props; | ||
return ( | ||
<MainText> | ||
created in | ||
<Tooltip title={defaultProjectHome} position="bottom"> | ||
<TextButton onClick={() => this.updatePath()}> | ||
{defaultProjectHome.length > 30 | ||
? `${defaultProjectHome.slice(0, 30)}...` | ||
: defaultProjectHome} | ||
</TextButton> | ||
</Tooltip> | ||
</MainText> | ||
); | ||
} | ||
} | ||
|
||
const MainText = styled.div` | ||
text-align: left; | ||
margin: -25px 0 30px 5px; | ||
font-size: 18px; | ||
color: ${COLORS.gray['500']}; | ||
`; | ||
|
||
const mapStateToProps = state => { | ||
return { | ||
defaultProjectHome: getProjectHomePath(state.paths), | ||
}; | ||
}; | ||
|
||
const mapDispatchToProps = { | ||
changeProjectHomePath, | ||
}; | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(ProjectPath); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.