Skip to content

Commit

Permalink
Merge pull request #274 from microsoft/task/fix_orig_latest
Browse files Browse the repository at this point in the history
Fix "View Original" / "View Latest"
  • Loading branch information
darthtrevino authored Nov 1, 2022
2 parents f3ec46b + 8485be5 commit 0255461
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions javascript/app-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"lint": "essex lint"
},
"dependencies": {
"@datashaper/react": "^16.2.0",
"@datashaper/react": "^16.2.1",
"@datashaper/schema": "^8.0.1",
"@datashaper/tables": "^5.2.3",
"@datashaper/utilities": "^2.3.9",
"@datashaper/workflow": "^19.1.0",
"@datashaper/workflow": "^19.1.1",
"@essex/components": "^3.1.0",
"@fluentui/react": "^8.99.1",
"@fluentui/react-hooks": "^8.6.12",
Expand Down
4 changes: 2 additions & 2 deletions javascript/app-discover/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"lint": "essex lint"
},
"dependencies": {
"@datashaper/react": "^16.2.0",
"@datashaper/react": "^16.2.1",
"@datashaper/schema": "^8.0.1",
"@datashaper/tables": "^5.2.3",
"@datashaper/utilities": "^2.3.9",
"@datashaper/workflow": "^19.1.0",
"@datashaper/workflow": "^19.1.1",
"@essex-js-toolkit/hooks": "^4.0.3",
"@essex/components": "^3.1.0",
"@essex/hooks": "^4.0.13",
Expand Down
2 changes: 1 addition & 1 deletion javascript/app-discover/src/domain/Dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function useWorkflow(table: ColumnTable | undefined): Workflow {
const steps = useDataProcessingSteps()
return useMemo<Workflow>(() => {
const res = new Workflow()
res.defaultInput = from([{ id: '', table }])
res.defaultInput = { id: '', table }
steps.forEach(s => res.addStep(s))
return res
}, [steps, table])
Expand Down
4 changes: 2 additions & 2 deletions javascript/app-model-exposure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"lint": "essex lint"
},
"dependencies": {
"@datashaper/react": "^16.2.0",
"@datashaper/react": "^16.2.1",
"@datashaper/schema": "^8.0.1",
"@datashaper/tables": "^5.2.3",
"@datashaper/utilities": "^2.3.9",
"@datashaper/workflow": "^19.1.0",
"@datashaper/workflow": "^19.1.1",
"@essex/components": "^3.1.0",
"@essex/hooks": "^4.0.13",
"@essex/webpack-config": "^21.0.8",
Expand Down
4 changes: 2 additions & 2 deletions javascript/app-wrangle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
},
"dependencies": {
"@datashaper/core": "^10.0.0",
"@datashaper/react": "^16.2.0",
"@datashaper/react": "^16.2.1",
"@datashaper/schema": "^8.0.1",
"@datashaper/tables": "^5.2.3",
"@datashaper/utilities": "^2.3.9",
"@datashaper/workflow": "^19.1.0",
"@datashaper/workflow": "^19.1.1",
"@essex-js-toolkit/hooks": "^4.0.3",
"@essex/components": "^3.1.0",
"@essex/hooks": "^4.0.13",
Expand Down
26 changes: 11 additions & 15 deletions javascript/app-wrangle/src/components/TableEditor.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
* Copyright (c) Microsoft. All rights reserved.
* Licensed under the MIT license. See LICENSE file in the project.
*/
import {
useHeaderCommandBarDefaults,
useWorkflowOutputListener,
} from '@datashaper/react'
import { useHeaderCommandBarDefaults } from '@datashaper/react'
import type { TableContainer } from '@datashaper/tables'
import type { DataTable, Workflow } from '@datashaper/workflow'
import type {
IColumn,
ICommandBarItemProps,
ICommandBarProps,
} from '@fluentui/react'
import { useDataTableOutput } from '@showwhy/app-common'
import { useCallback, useEffect, useMemo, useState } from 'react'

import {
Expand All @@ -26,17 +22,17 @@ export function useSelectedTable(
dataTable: DataTable,
selectedTableId: string | undefined,
): TableContainer | undefined {
const defaultValue = useDataTableOutput(dataTable)
const [outputs, setOutputs] = useState<TableContainer[]>([])
useWorkflowOutputListener(dataTable.workflow, setOutputs)

return useMemo((): TableContainer | undefined => {
return (
(defaultValue ? [defaultValue] : [])
.concat(outputs)
.find(x => x.id === selectedTableId) ?? defaultValue
)
}, [defaultValue, selectedTableId, outputs])
if (dataTable.name === selectedTableId) {
// if we select the original table name, use the workflow default input
return { table: dataTable.source, id: selectedTableId ?? '' }
} else {
// try to use the given table name to read the step, otherwise use the default output
const table = dataTable.workflow.read(selectedTableId)
const defaultOutput = dataTable.workflow.read()
return table ?? defaultOutput
}
}, [dataTable, selectedTableId])
}

export function useColumnState(): [
Expand Down
4 changes: 4 additions & 0 deletions javascript/app-wrangle/src/components/TableEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ import type { TableEditorProps } from './TableEditor.types.js'

export const TableEditor: React.FC<TableEditorProps> = memo(
function TableEditor({ dataTable }) {
// Primary State
const [isCollapsed, { toggle: toggleCollapsed }] = useBoolean(true)
const table = useDataTableOutput(dataTable)
const workflow = dataTable.workflow
const [selectedId, setSelectedId] = useState<string | undefined>(table?.id)
const [selectedColumn, onColumnClick] = useColumnState()

// Derived State
const inputNames = useInputTableNames(workflow)
const numSteps = useObservableState(workflow.length$, workflow.length)
const toolPanelHeader = useMemo(
Expand All @@ -62,10 +64,12 @@ export const TableEditor: React.FC<TableEditorProps> = memo(
const tableCommandProps = useTableCommandProps()
const toolPanelStyles = useToolPanelStyles()

// Event Handlers
const onSave = useOnSaveStep(workflow)
const onCreate = useOnCreateStep(onSave, setSelectedId)
const onDelete = useOnDeleteStep(workflow)

// Side Effects
useStepListener(workflow, setSelectedId, inputNames)

return selectedTable?.table == null ? null : (
Expand Down
2 changes: 1 addition & 1 deletion javascript/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@datashaper/schema": "^8.0.1",
"@datashaper/tables": "^5.2.3",
"@datashaper/utilities": "^2.3.9",
"@datashaper/workflow": "^19.1.0",
"@datashaper/workflow": "^19.1.1",
"@essex/components": "^3.1.0",
"@essex/hooks": "^4.0.13",
"@fluentui/font-icons-mdl2": "^8.5.2",
Expand Down
36 changes: 18 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2056,15 +2056,15 @@ __metadata:
languageName: node
linkType: hard

"@datashaper/react@npm:^16.2.0":
version: 16.2.0
resolution: "@datashaper/react@npm:16.2.0"
"@datashaper/react@npm:^16.2.1":
version: 16.2.1
resolution: "@datashaper/react@npm:16.2.1"
dependencies:
"@datashaper/schema": ^8.0.1
"@datashaper/tables": ^5.2.3
"@datashaper/utilities": ^2.3.9
"@datashaper/verb-guidance": ^0.1.22
"@datashaper/workflow": ^19.1.0
"@datashaper/workflow": ^19.1.1
"@essex/charts-react": ^1.1.2
"@essex/components": ^3.1.0
"@essex/styled-components": ^0.0.4
Expand Down Expand Up @@ -2092,7 +2092,7 @@ __metadata:
arquero: ^5.1.0
react: ^17.0.2
styled-components: ^5.3.0
checksum: a62226fc4927fb6f3b9881e312129f07b9eeff24e781ecc2cbcb8e6f5374fba91fc7aa71be7dbce592fb481ef56a63dbbd3275570e779594d8f68e020755a225
checksum: 021fbed9bae4db129ec1d511e2c83a43af018dd74c33180d55dfcd15135839b3ed701b8a90c93445db68a477f3205792d07e6b7c7a2bdc35924162025b8fd42d
languageName: node
linkType: hard

Expand Down Expand Up @@ -2150,9 +2150,9 @@ __metadata:
languageName: node
linkType: hard

"@datashaper/workflow@npm:^19.1.0":
version: 19.1.0
resolution: "@datashaper/workflow@npm:19.1.0"
"@datashaper/workflow@npm:^19.1.1":
version: 19.1.1
resolution: "@datashaper/workflow@npm:19.1.1"
dependencies:
"@datashaper/schema": ^8.0.1
"@datashaper/tables": ^5.2.3
Expand All @@ -2169,7 +2169,7 @@ __metadata:
peerDependenciesMeta:
"@types/node":
optional: true
checksum: 1655e3d5b755c2a303ace31e7f3c35ea0d03dc9a6fadff53181c60f51db29eee6bfe275c90d69f0410db2d982633ed528864354a1f42d9acc37f598b167954e3
checksum: 7757ee32c0b65b238e6c79140a9dd2987b3776115783040de004df361b48eab29d6c837a0421d83464240f3d75db2e34ec0601076362bcef79836a7e6551c47d
languageName: node
linkType: hard

Expand Down Expand Up @@ -3759,11 +3759,11 @@ __metadata:
version: 0.0.0-use.local
resolution: "@showwhy/app-common@workspace:javascript/app-common"
dependencies:
"@datashaper/react": ^16.2.0
"@datashaper/react": ^16.2.1
"@datashaper/schema": ^8.0.1
"@datashaper/tables": ^5.2.3
"@datashaper/utilities": ^2.3.9
"@datashaper/workflow": ^19.1.0
"@datashaper/workflow": ^19.1.1
"@essex/components": ^3.1.0
"@essex/scripts": ^22.1.0
"@fluentui/react": ^8.99.1
Expand Down Expand Up @@ -3798,11 +3798,11 @@ __metadata:
version: 0.0.0-use.local
resolution: "@showwhy/discover-app@workspace:javascript/app-discover"
dependencies:
"@datashaper/react": ^16.2.0
"@datashaper/react": ^16.2.1
"@datashaper/schema": ^8.0.1
"@datashaper/tables": ^5.2.3
"@datashaper/utilities": ^2.3.9
"@datashaper/workflow": ^19.1.0
"@datashaper/workflow": ^19.1.1
"@essex-js-toolkit/hooks": ^4.0.3
"@essex/components": ^3.1.0
"@essex/hooks": ^4.0.13
Expand Down Expand Up @@ -3938,11 +3938,11 @@ __metadata:
version: 0.0.0-use.local
resolution: "@showwhy/model-exposure-app@workspace:javascript/app-model-exposure"
dependencies:
"@datashaper/react": ^16.2.0
"@datashaper/react": ^16.2.1
"@datashaper/schema": ^8.0.1
"@datashaper/tables": ^5.2.3
"@datashaper/utilities": ^2.3.9
"@datashaper/workflow": ^19.1.0
"@datashaper/workflow": ^19.1.1
"@essex/components": ^3.1.0
"@essex/hooks": ^4.0.13
"@essex/scripts": ^22.1.0
Expand Down Expand Up @@ -4001,7 +4001,7 @@ __metadata:
"@datashaper/schema": ^8.0.1
"@datashaper/tables": ^5.2.3
"@datashaper/utilities": ^2.3.9
"@datashaper/workflow": ^19.1.0
"@datashaper/workflow": ^19.1.1
"@essex/components": ^3.1.0
"@essex/hooks": ^4.0.13
"@essex/scripts": ^22.1.0
Expand Down Expand Up @@ -4064,11 +4064,11 @@ __metadata:
resolution: "@showwhy/wrangle-app@workspace:javascript/app-wrangle"
dependencies:
"@datashaper/core": ^10.0.0
"@datashaper/react": ^16.2.0
"@datashaper/react": ^16.2.1
"@datashaper/schema": ^8.0.1
"@datashaper/tables": ^5.2.3
"@datashaper/utilities": ^2.3.9
"@datashaper/workflow": ^19.1.0
"@datashaper/workflow": ^19.1.1
"@essex-js-toolkit/hooks": ^4.0.3
"@essex/components": ^3.1.0
"@essex/hooks": ^4.0.13
Expand Down

0 comments on commit 0255461

Please sign in to comment.