summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/redux/sagas/projects.js
blob: 96a4323c3c1e0db1185e56673d4d3ac8a8d6ed83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { call, getContext } from 'redux-saga/effects'
import { fetchAndStoreAllTopologiesOfProject } from './topology'
import { fetchAndStoreAllSchedulers, fetchAndStoreAllTraces } from './objects'
import { fetchPortfoliosOfProject } from './portfolios'
import { fetchProject } from '../../api/projects'

export function* onOpenProjectSucceeded(action) {
    try {
        const auth = yield getContext('auth')
        const queryClient = yield getContext('queryClient')
        const project = yield call(() =>
            queryClient.fetchQuery(`projects/${action.id}`, () => fetchProject(auth, action.id))
        )

        yield fetchAndStoreAllTopologiesOfProject(action.id, true)
        yield fetchPortfoliosOfProject(project)
        yield fetchAndStoreAllSchedulers()
        yield fetchAndStoreAllTraces()
    } catch (error) {
        console.error(error)
    }
}