Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Fix position of commit button #47

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

exports[`CodeStatus Container Should render 1`] = `
<CodeStatus
commit={[Function]}
currentCommitHash="latest"
currentState="Idle"
getCommitLog={[Function]}
isCodeSaved={true}
lastSaveTime={1970-01-01T00:00:00.000Z}
width={250}
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/SubmitBar/CommitMessageBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class CommitMessageBox extends React.Component<CommitMessageBoxInterfaces
<div className="col form-row mb-2">
<div className="input-group">
<input
className="form-control"
className={classnames('form-control', styles['commit-input'])}
id="validationCommitMessage"
placeholder="Describe your commit."
maxLength={50}
Expand Down
12 changes: 1 addition & 11 deletions src/app/components/SubmitBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
faChevronLeft,
faChevronRight,
faCodeBranch,
faCog,
faLock,
faPlay,
Expand Down Expand Up @@ -158,16 +157,7 @@ export class SubmitBar extends React.Component<
</span>
<span>SAVE</span>
</button>
<button
id="commit_button"
className={classnames(styles.customBtn)}
onClick={() => this.toggleCommitMessageBox(!isCommitMessageBoxOpen)}
>
<span className={classnames(styles.icon)}>
<FontAwesomeIcon icon={faCodeBranch} />
</span>
<span>COMMIT</span>
</button>

<button
className={classnames(styles.customBtn)}
title="Submit Code"
Expand Down
46 changes: 45 additions & 1 deletion src/app/components/code/CodeStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { faCodeBranch } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { CommitMessageBox } from 'app/components/SubmitBar/CommitMessageBox';
import * as styles from 'app/styles/CodeStatus.module.css';
import * as Commitstyles from 'app/styles/SubmitBar.module.css';
import * as CodeStatusInterfaces from 'app/types/code/CodeStatus';
import classnames from 'classnames';
import * as React from 'react';
Expand All @@ -11,6 +15,8 @@ export class CodeStatus extends React.Component<
public constructor(props: CodeStatusInterfaces.Props) {
super(props);
this.state = {
commitMessage: '',
isCommitMessageBoxOpen: false,
lastSaveMessage: '',
};
}
Expand Down Expand Up @@ -68,12 +74,13 @@ export class CodeStatus extends React.Component<

public render() {
const { currentState, width, isCodeSaved, currentCommitHash } = this.props;
const { isCommitMessageBoxOpen, commitMessage } = this.state;
return (
<Row
className={classnames(styles.CodeStatusRow)}
style={{
width,
height: '3.5vh',
height: '6vh',
}}
>
<Col sm={6} className={classnames(styles.StatusTextCol)}>
Expand All @@ -91,6 +98,25 @@ export class CodeStatus extends React.Component<
</p>
)}
</Col>

<Col>
<button
id="commit_button"
className={classnames(Commitstyles.customBtn)}
onClick={() => this.toggleCommitMessageBox(!isCommitMessageBoxOpen)}
>
<span className={classnames(Commitstyles.icon)}>
<FontAwesomeIcon icon={faCodeBranch} />
</span>
<span>COMMIT</span>
</button>
</Col>
<CommitMessageBox
commitMessage={commitMessage}
isCommitMessageBoxOpen={isCommitMessageBoxOpen}
handleCommit={this.handleCommit}
updateCommitMessage={this.updateCommitMessage}
/>
<Col sm={5} className={classnames(styles.CommitStatusCol)}>
<p className={classnames(styles.StatusText)} style={{ textAlign: 'right' }}>
{currentState}
Expand All @@ -104,4 +130,22 @@ export class CodeStatus extends React.Component<
</Row>
);
}
private toggleCommitMessageBox = (isCommitMessageBoxOpen: boolean) => {
this.setState({
isCommitMessageBoxOpen,
});
};

private handleCommit = async () => {
const { commitMessage } = this.state;
const { commit, getCommitLog } = this.props;
await commit(commitMessage);
await this.toggleCommitMessageBox(false);
await getCommitLog();
};
private updateCommitMessage = (commitMessage: string) => {
this.setState({
commitMessage,
});
};
}
11 changes: 6 additions & 5 deletions src/app/containers/code/CodeStatus.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CodeActions } from 'app/actions';
import { CodeStatus } from 'app/components/code/CodeStatus';
import { RootState } from 'app/reducers';
import * as CodeStatusInterfaces from 'app/types/code/CodeStatus';
Expand Down Expand Up @@ -47,11 +48,11 @@ const mapStateToProps = (rootState: RootState) => {

const codeStatusContainer = connect<
CodeStatusInterfaces.StateProps,
{},
CodeStatusInterfaces.DispatchProps,
CodeStatusInterfaces.OwnProps
>(
mapStateToProps,
{},
)(CodeStatus);
>(mapStateToProps, {
commit: CodeActions.commit,
getCommitLog: CodeActions.getCommitLog,
})(CodeStatus);

export default codeStatusContainer;
2 changes: 1 addition & 1 deletion src/app/styles/CodeStatus.module.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.CodeStatusRow {
background-color: #202020;
height: 22px;
height: 50px;
margin: 0px;
}

Expand Down
20 changes: 17 additions & 3 deletions src/app/styles/CommitMessageBox.module.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.CommitMessageBox {
position: absolute;
left: 15px;
top: 45px;
left: 115px;
top: 40px;
width: 350px;
background-color: rgb(41, 41, 41);
background-color: white;
border: 2px solid royalblue;
border-radius: 5px !important;
color: #ddd;
border-radius: 3px;
z-index: 1000;
Expand All @@ -15,13 +17,25 @@

.customBtn:hover {
color: #fff;
background-color: royalblue;
}
.customBtn {
background-color: royalblue;
}

.customBtn:active {
transform: scale(1.04);
background-color: royalblue;
}

.customBtn:focus {
outline: none;
box-shadow: none;
background-color: royalblue;
}

.commit-input:focus,
.commit-input:active {
box-shadow: none;
outline: none;
}
9 changes: 8 additions & 1 deletion src/app/types/code/CodeStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ export interface OwnProps {
width: number;
}

export interface DispatchProps {
commit: (commitMessage: string) => void;
getCommitLog: () => void;
}

export interface State {
commitMessage: string;
isCommitMessageBoxOpen: boolean;
lastSaveMessage: string;
}

export type Props = OwnProps & StateProps & {};
export type Props = OwnProps & StateProps & DispatchProps;