Skip to content

Commit

Permalink
fix: check if owners are actually being updated in `PUT /datasets/<id…
Browse files Browse the repository at this point in the history
…>` (apache#16941)

* check if owners are actually being updated

* move logic to FE

* fix

* fix

(cherry picked from commit 40861b3)
  • Loading branch information
hughhhh authored and sadpandajoe committed Oct 13, 2021
1 parent 83ad74f commit 824111f
Showing 1 changed file with 18 additions and 4 deletions.
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

0 comments on commit 824111f

Please sign in to comment.