-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(workbench): viewing trasnform component shouldn't crash
some latent cleanup here. I ended up doing a bunch of refactoring at the same time. Damn that DatasetComponent needs to drop in size.
- Loading branch information
Showing
10 changed files
with
124 additions
and
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,35 @@ | ||
import * as React from 'react' | ||
import { connect } from 'react-redux' | ||
import { bindActionCreators, Dispatch } from 'redux' | ||
|
||
import { WorkingDataset } from '../models/store' | ||
import { ApiActionThunk } from '../store/api' | ||
|
||
import { Transform } from '../models/dataset' | ||
import Store from '../models/store' | ||
import { QriRef } from '../models/qriRef' | ||
import { fsiWrite } from '../actions/api' | ||
import Code from './Code' | ||
|
||
export interface TransformProps { | ||
peername: string | ||
name: string | ||
value: string | ||
preview: string | ||
history: boolean | ||
workingDataset: WorkingDataset | ||
write: (peername: string, name: string, dataset: any) => ApiActionThunk | ||
data: Transform | ||
qriRef: QriRef | ||
|
||
// TODO (b5) - work in progress | ||
dryRun?: () => void | ||
} | ||
|
||
export const TransformComponent: React.FunctionComponent<TransformProps> = ({ data }) => { | ||
return <Code data={data.scriptBytes || ''} /> | ||
} | ||
|
||
const mapStateToProps = (state: Store, ownProps: TransformProps) => { | ||
return ownProps | ||
} | ||
|
||
const mergeProps = (props: any, actions: any): TransformProps => { //eslint-disable-line | ||
return { ...props, ...actions } | ||
} | ||
|
||
// TODO (b5) - setting a default value here b/c we're getting null value from | ||
// somewhere when we click workbench/transform component. need to investigate | ||
// and not pass a nonexistent value, ever. | ||
const Transform: React.FunctionComponent<TransformProps> = ({ value = '' }) => { | ||
return <Code data={value} /> | ||
const mapDispatchToProps = (dispatch: Dispatch) => { | ||
return bindActionCreators({ write: fsiWrite }, dispatch) | ||
} | ||
|
||
export default Transform | ||
export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(TransformComponent) |
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,39 @@ | ||
import React from 'react' | ||
import moment from 'moment' | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
import { faClock } from '@fortawesome/free-regular-svg-icons' | ||
|
||
import { Structure, Commit } from '../../models/dataset' | ||
import fileSize from '../../utils/fileSize' | ||
|
||
interface CommitDetailsHeaderProps { | ||
structure: Structure | ||
commit: Commit | ||
} | ||
|
||
const CommitDetailsHeader: React.FunctionComponent<CommitDetailsHeaderProps> = ({ structure, commit }) => { | ||
return ( | ||
<div className='commit-details-header'> | ||
{structure && commit && <div className='details-flex'> | ||
<div className='text-column'> | ||
<div id='commit-title' className='text'>{commit.title}</div> | ||
<div className='subtext'> | ||
{/* <img className= 'user-image' src = {'https://avatars0.githubusercontent.com/u/1154390?s=60&v=4'} /> */} | ||
<div className='time-message'> | ||
<FontAwesomeIcon icon={faClock} size='sm'/> | ||
{moment(commit.timestamp).format('MMMM Do YYYY, h:mm:ss a')} | ||
</div> | ||
</div> | ||
</div> | ||
<div className='details-column'> | ||
{structure.length && <div className='detail' id='commit-details-header-file-size'>{fileSize(structure.length)}</div>} | ||
{structure.format && <div className='detail' id='commit-details-header-format'>{structure.format.toUpperCase()}</div>} | ||
{structure.entries && <div className='detail' id='commit-details-header-entries'>{structure.entries.toLocaleString()} {structure.entries !== 1 ? 'entries' : 'entry'}</div>} | ||
{structure.errCount && <div className='detail' id='commit-details-header-errors'>{structure.errCount.toLocaleString()} {structure.errCount !== 1 ? 'errors' : 'error'}</div>} | ||
</div> | ||
</div>} | ||
</div> | ||
) | ||
} | ||
|
||
export default CommitDetailsHeader |
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 was deleted.
Oops, something went wrong.
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