Skip to content

Commit 02fe214

Browse files
committed
fix(workbench): history transform views need to work as well
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.
1 parent 98915b5 commit 02fe214

File tree

5 files changed

+10
-13
lines changed

5 files changed

+10
-13
lines changed

app/components/workbench/DatasetComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export const DatasetComponent: React.FunctionComponent<DatasetComponentProps> =
242242
>
243243
<div className='transition-wrap'>
244244
<Transform
245-
data={data.transform}
245+
data={data.transform || ''}
246246
qriRef={qriRef}
247247
/>
248248
</div>

app/components/workbench/Transform.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,22 @@ import * as React from 'react'
22
import { connect } from 'react-redux'
33
import { bindActionCreators, Dispatch } from 'redux'
44

5-
import { Transform } from '../../models/dataset'
65
import Store from '../../models/store'
76
import { QriRef } from '../../models/qriRef'
87
import { fsiWrite } from '../../actions/api'
98
import Code from '../Code'
109

1110
export interface TransformProps {
12-
data: Transform
11+
data: string
1312
qriRef: QriRef
1413

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

19-
export const TransformComponent: React.FunctionComponent<TransformProps> = ({ data }) => {
20-
return <Code data={data.scriptBytes || ''} />
21-
}
18+
export const TransformComponent: React.FC<TransformProps> = ({ data = '' }) => (
19+
<Code data={data} />
20+
)
2221

2322
const mapStateToProps = (state: Store, ownProps: TransformProps) => {
2423
return ownProps

app/models/dataset.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,14 @@ export interface Structure {
7979

8080
export type Schema = JSONSchema7
8181

82-
export interface Transform {
83-
format?: string
84-
scriptBytes?: string
85-
}
86-
8782
export interface Dataset {
8883
meta?: Meta
8984
structure?: Structure
9085
body?: Body
9186
bodyPath?: string
9287
commit?: Commit
9388
readme?: string
94-
transform?: Transform
89+
transform?: string
9590
[key: string]: any
9691
}
9792

app/reducers/commitDetail.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ const commitDetailsReducer: Reducer = (state = initialState, action: AnyAction):
7979
},
8080
readme: {
8181
value: dataset.readme
82+
},
83+
transform: {
84+
value: dataset && dataset.transform && dataset.transform.scriptBytes ? atob(dataset.transform.scriptBytes) : undefined
8285
}
8386
}
8487
}

app/reducers/workingDataset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const workingDatasetsReducer: Reducer = (state = initialState, action: AnyAction
102102
value: dataset && dataset.structure ? dataset.structure : undefined
103103
},
104104
transform: {
105-
value: dataset && dataset.transform ? { scriptBytes: atob(dataset.transform.scriptBytes) } : undefined
105+
value: dataset && dataset.transform && dataset.transform.scriptBytes ? atob(dataset.transform.scriptBytes) : undefined
106106
}
107107
}
108108
}

0 commit comments

Comments
 (0)