Skip to content
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

fix: check if owners are actually being updated in PUT /datasets/<id> #16941

Merged
merged 5 commits into from
Oct 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions superset-frontend/src/SqlLab/components/ResultSet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,17 @@ enum LIMITING_FACTOR {

const LOADING_STYLES: CSSProperties = { position: 'relative', minHeight: 100 };

interface DatasetOwner {
first_name: string;
id: number;
last_name: string;
username: string;
}

interface DatasetOptionAutocomplete {
value: string;
datasetId: number;
owners: [DatasetOwner];
}

interface ResultSetProps {
Expand Down Expand Up @@ -142,13 +150,15 @@ const updateDataset = async (
datasetId: number,
sql: string,
columns: Array<Record<string, any>>,
owners: [number],
overrideColumns: boolean,
) => {
const endpoint = `api/v1/dataset/${datasetId}?override_columns=${overrideColumns}`;
const headers = { 'Content-Type': 'application/json' };
const body = JSON.stringify({
sql,
columns,
owners,
});

const data: JsonResponse = await SupersetClient.put({
Expand Down Expand Up @@ -269,6 +279,7 @@ export default class ResultSet extends React.PureComponent<
datasetToOverwrite.datasetId,
sql,
results.selected_columns.map(d => ({ column_name: d.name })),
datasetToOverwrite.owners.map((o: DatasetOwner) => o.id),
true,
);

Expand Down Expand Up @@ -405,10 +416,13 @@ export default class ResultSet extends React.PureComponent<
endpoint: '/api/v1/dataset',
})(`q=${queryParams}`);

return response.result.map((r: { table_name: string; id: number }) => ({
value: r.table_name,
datasetId: r.id,
}));
return response.result.map(
(r: { table_name: string; id: number; owners: [DatasetOwner] }) => ({
value: r.table_name,
datasetId: r.id,
owners: r.owners,
}),
);
}

return null;
Expand Down