-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(api v1): Deprecate datasource/save and datasource/get endpoints #23678
Changes from all commits
29d5be4
a67be31
e0c0105
99a0873
81e52de
5ab4fc1
6da1bb9
37f53b2
1ffdc96
1002ce6
83cf76c
8c37492
a372dba
1dbc15d
bbe1ab8
8470eac
d37b126
d504856
ce23c54
6140fb1
389ce01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,39 +96,81 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({ | |
currentDatasource.schema; | ||
|
||
setIsSaving(true); | ||
SupersetClient.post({ | ||
endpoint: '/datasource/save/', | ||
postPayload: { | ||
data: { | ||
...currentDatasource, | ||
cache_timeout: | ||
currentDatasource.cache_timeout === '' | ||
? null | ||
: currentDatasource.cache_timeout, | ||
schema, | ||
metrics: currentDatasource?.metrics?.map( | ||
(metric: Record<string, unknown>) => ({ | ||
...metric, | ||
SupersetClient.put({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to save a new dataset in this modal or only update? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only update, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, perfect. |
||
endpoint: `/api/v1/dataset/${currentDatasource.id}`, | ||
jsonPayload: { | ||
table_name: currentDatasource.table_name, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we not spreading as we were before? same with metric and column below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old endpoint didn't have a rigid structure it accepted as a payload; it would just take a JSON string, parse it, and then set all keys that it was able to set on the target dataset, ignoring irrelevant keys. The new endpoint is different; it accepts the payload defined by the |
||
database_id: currentDatasource.database?.id, | ||
sql: currentDatasource.sql, | ||
filter_select_enabled: currentDatasource.filter_select_enabled, | ||
fetch_values_predicate: currentDatasource.fetch_values_predicate, | ||
schema, | ||
description: currentDatasource.description, | ||
main_dttm_col: currentDatasource.main_dttm_col, | ||
offset: currentDatasource.offset, | ||
default_endpoint: currentDatasource.default_endpoint, | ||
cache_timeout: | ||
currentDatasource.cache_timeout === '' | ||
? null | ||
: currentDatasource.cache_timeout, | ||
is_sqllab_view: currentDatasource.is_sqllab_view, | ||
template_params: currentDatasource.template_params, | ||
extra: currentDatasource.extra, | ||
is_managed_externally: currentDatasource.is_managed_externally, | ||
external_url: currentDatasource.external_url, | ||
metrics: currentDatasource?.metrics?.map( | ||
(metric: Record<string, unknown>) => { | ||
const metricBody: any = { | ||
expression: metric.expression, | ||
description: metric.description, | ||
metric_name: metric.metric_name, | ||
metric_type: metric.metric_type, | ||
d3format: metric.d3format, | ||
verbose_name: metric.verbose_name, | ||
warning_text: metric.warning_text, | ||
uuid: metric.uuid, | ||
extra: buildExtraJsonObject(metric), | ||
}), | ||
), | ||
columns: currentDatasource?.columns?.map( | ||
(column: Record<string, unknown>) => ({ | ||
...column, | ||
extra: buildExtraJsonObject(column), | ||
}), | ||
), | ||
type: currentDatasource.type || currentDatasource.datasource_type, | ||
owners: currentDatasource.owners.map( | ||
(o: Record<string, number>) => o.value || o.id, | ||
), | ||
}, | ||
}; | ||
if (!Number.isNaN(Number(metric.id))) { | ||
metricBody.id = metric.id; | ||
} | ||
return metricBody; | ||
}, | ||
), | ||
columns: currentDatasource?.columns?.map( | ||
(column: Record<string, unknown>) => ({ | ||
id: column.id, | ||
column_name: column.column_name, | ||
type: column.type, | ||
advanced_data_type: column.advanced_data_type, | ||
verbose_name: column.verbose_name, | ||
description: column.description, | ||
expression: column.expression, | ||
filterable: column.filterable, | ||
groupby: column.groupby, | ||
is_active: column.is_active, | ||
is_dttm: column.is_dttm, | ||
python_date_format: column.python_date_format, | ||
uuid: column.uuid, | ||
extra: buildExtraJsonObject(column), | ||
}), | ||
), | ||
owners: currentDatasource.owners.map( | ||
(o: Record<string, number>) => o.value || o.id, | ||
), | ||
}, | ||
}) | ||
.then(({ json }) => { | ||
.then(() => { | ||
addSuccessToast(t('The dataset has been saved')); | ||
return SupersetClient.get({ | ||
endpoint: `/api/v1/dataset/${currentDatasource?.id}`, | ||
}); | ||
}) | ||
.then(({ json }) => { | ||
// eslint-disable-next-line no-param-reassign | ||
json.result.type = 'table'; | ||
onDatasourceSave({ | ||
...json, | ||
...json.result, | ||
owners: currentDatasource.owners, | ||
}); | ||
onHide(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this was a typo, the backend returns
column_formats