Skip to content

Commit

Permalink
Dashboard: fix default cluster from navigation. (#1296)
Browse files Browse the repository at this point in the history
* Dashboard: fix default cluster from navigation.

* use hook in training job submission
  • Loading branch information
Gerhut committed Aug 19, 2020
1 parent f77cbd4 commit 5a28a1e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
11 changes: 9 additions & 2 deletions src/dashboard/src/pages/Submission/DataJob.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { DirectoryPathTextField } from './components/GPUCard'
import ClustersContext from '../../contexts/Clusters'
import UserContext from '../../contexts/User'
import TeamContext from '../../contexts/Team'
import { Link } from 'react-router-dom'
import { Link, useLocation } from 'react-router-dom'
import Slide from '@material-ui/core/Slide'
import { green } from '@material-ui/core/colors'
import useFetch from 'use-http'
Expand All @@ -42,6 +42,7 @@ const Transition = React.forwardRef<unknown, TransitionProps & { children?: Reac
})

const DataJob: React.FC = (props: any) => {
const location = useLocation()
const styles = useStyles()
const [azureDataStorage, setAzureDataStorage] = useState('')
const [nfsDataStorage, setNFSDataStorage] = useState('')
Expand All @@ -51,7 +52,13 @@ const DataJob: React.FC = (props: any) => {
const { email } = React.useContext(UserContext)
const { currentTeamId } = React.useContext(TeamContext)
const { clusters } = React.useContext(ClustersContext)
const [selectedCluster, saveSelectedCluster] = React.useState(() => clusters[0].id)
const [selectedCluster, saveSelectedCluster] = React.useState(() => {
const clusterId = location.state.cluster
if (clusters.some(({ id }) => id === clusterId)) {
return clusterId
}
return clusters[0].id
})
const [workStorage, setWorkStorage] = useState('')
const [dataStorage, setDataStorage] = useState('')

Expand Down
16 changes: 12 additions & 4 deletions src/dashboard/src/pages/Submission/Training.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from '@material-ui/core'
import Tooltip from '@material-ui/core/Tooltip'
import { Info, Delete, Add } from '@material-ui/icons'
import { withRouter } from 'react-router-dom'
import { useHistory, useLocation } from 'react-router-dom'
import IconButton from '@material-ui/core/IconButton'
import useFetch from 'use-http'
import { join } from 'path'
Expand Down Expand Up @@ -56,9 +56,17 @@ const sanitizePath = (path: string) => {
path = join('.', path)
return path
}
const Training: React.ComponentClass = withRouter(({ history }) => {
const Training: React.FunctionComponent = () => {
const history = useHistory()
const location = useLocation()
const { clusters } = React.useContext(ClustersContext)
const [selectedCluster, saveSelectedCluster] = React.useState(() => clusters[0].id)
const [selectedCluster, saveSelectedCluster] = React.useState(() => {
const clusterId = location.state.cluster
if (clusters.some(({ id }) => id === clusterId)) {
return clusterId
}
return clusters[0].id
})
const { email } = React.useContext(UserContext)
const { currentTeamId } = React.useContext(TeamContext)
// const team = 'platform';
Expand Down Expand Up @@ -1330,6 +1338,6 @@ const Training: React.ComponentClass = withRouter(({ history }) => {
/>
</Container>
)
})
}

export default Training

0 comments on commit 5a28a1e

Please sign in to comment.