(dataset)
| 184 | }; |
| 185 | |
| 186 | const _onCreateFromDataset = async (dataset) => { |
| 187 | setCreatingDatasetId(dataset.id); |
| 188 | |
| 189 | let initialDataFetchStarted = false; |
| 190 | |
| 191 | try { |
| 192 | const datasetName = getDatasetDisplayName(dataset) || "Untitled dataset"; |
| 193 | const defaultBindings = getDefaultCdcBindings(dataset); |
| 194 | const chart = await _createChart(datasetName); |
| 195 | |
| 196 | await dispatch(createCdc({ |
| 197 | project_id: chart.project_id, |
| 198 | chart_id: chart.id, |
| 199 | data: { |
| 200 | dataset_id: dataset.id, |
| 201 | legend: datasetName, |
| 202 | datasetColor: chartColors.blue.hex, |
| 203 | fill: false, |
| 204 | order: 0, |
| 205 | ...defaultBindings, |
| 206 | }, |
| 207 | })).unwrap(); |
| 208 | |
| 209 | initialDataFetchStarted = true; |
| 210 | await dispatch(runQuery({ |
| 211 | project_id: chart.project_id, |
| 212 | chart_id: chart.id, |
| 213 | noSource: false, |
| 214 | skipParsing: false, |
| 215 | getCache: true, |
| 216 | })).unwrap(); |
| 217 | |
| 218 | navigate(`${chart.id}/edit`); |
| 219 | } catch (error) { |
| 220 | toast.error(initialDataFetchStarted |
| 221 | ? "We couldn't fetch data for this chart yet. Please check the dataset and try again." |
| 222 | : "Oups! Can't create the chart. Please try again."); |
| 223 | } finally { |
| 224 | setCreatingDatasetId(null); |
| 225 | } |
| 226 | }; |
| 227 | |
| 228 | const _onCreateDataset = async () => { |
| 229 | setCreatingNewDataset(true); |
nothing calls this directly
no test coverage detected