Skip to content

Commit

Permalink
fix(workbench): history transform views need to work as well
Browse files Browse the repository at this point in the history
switching to representing transforms as just strings (instead of an object with a scriptBytes path)
as per @ramfox's suggestion. We might need the `syntax` field in a transform at some point, but
that time isn't coming until we support transforms other than starlark. Shouldn't be for a while.
  • Loading branch information
b5 committed Mar 4, 2020
1 parent 98915b5 commit 02fe214
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/components/workbench/DatasetComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const DatasetComponent: React.FunctionComponent<DatasetComponentProps> =
>
<div className='transition-wrap'>
<Transform
data={data.transform}
data={data.transform || ''}
qriRef={qriRef}
/>
</div>
Expand Down
9 changes: 4 additions & 5 deletions app/components/workbench/Transform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ import * as React from 'react'
import { connect } from 'react-redux'
import { bindActionCreators, Dispatch } from 'redux'

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 {
data: Transform
data: string
qriRef: QriRef

// TODO (b5) - work in progress
dryRun?: () => void
}

export const TransformComponent: React.FunctionComponent<TransformProps> = ({ data }) => {
return <Code data={data.scriptBytes || ''} />
}
export const TransformComponent: React.FC<TransformProps> = ({ data = '' }) => (
<Code data={data} />
)

const mapStateToProps = (state: Store, ownProps: TransformProps) => {
return ownProps
Expand Down
7 changes: 1 addition & 6 deletions app/models/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,14 @@ export interface Structure {

export type Schema = JSONSchema7

export interface Transform {
format?: string
scriptBytes?: string
}

export interface Dataset {
meta?: Meta
structure?: Structure
body?: Body
bodyPath?: string
commit?: Commit
readme?: string
transform?: Transform
transform?: string
[key: string]: any
}

Expand Down
3 changes: 3 additions & 0 deletions app/reducers/commitDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ const commitDetailsReducer: Reducer = (state = initialState, action: AnyAction):
},
readme: {
value: dataset.readme
},
transform: {
value: dataset && dataset.transform && dataset.transform.scriptBytes ? atob(dataset.transform.scriptBytes) : undefined
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/reducers/workingDataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const workingDatasetsReducer: Reducer = (state = initialState, action: AnyAction
value: dataset && dataset.structure ? dataset.structure : undefined
},
transform: {
value: dataset && dataset.transform ? { scriptBytes: atob(dataset.transform.scriptBytes) } : undefined
value: dataset && dataset.transform && dataset.transform.scriptBytes ? atob(dataset.transform.scriptBytes) : undefined
}
}
}
Expand Down

0 comments on commit 02fe214

Please sign in to comment.