Skip to content

Commit

Permalink
fix user reference
Browse files Browse the repository at this point in the history
  • Loading branch information
hughhhh committed Apr 29, 2022
1 parent e6bdf93 commit c409a23
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ export const PRIMARY_COLOR = { r: 0, g: 122, b: 135, a: 1 };
const ROW_LIMIT_OPTIONS = [10, 50, 100, 250, 500, 1000, 5000, 10000, 50000];
const SERIES_LIMITS = [5, 10, 25, 50, 100, 500];

const appContainer = document.getElementById('app');
const { user } = JSON.parse(
appContainer?.getAttribute('data-bootstrap') || '{}',
);

type Control = {
savedMetrics?: Metric[] | null;
default?: unknown;
Expand Down Expand Up @@ -167,6 +172,7 @@ const datasourceControl: SharedControlConfig<'DatasourceControl'> = {
mapStateToProps: ({ datasource, form_data }) => ({
datasource,
form_data,
user,
}),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
import DatasourceControl from 'src/explore/components/controls/DatasourceControl';
import Icons from 'src/components/Icons';
import { Tooltip } from 'src/components/Tooltip';
import { user } from 'src/SqlLab/fixtures';

const defaultProps = {
name: 'datasource',
Expand All @@ -52,6 +53,7 @@ const defaultProps = {
setDatasource: sinon.spy(),
},
onChange: sinon.spy(),
user,
};

describe('DatasourceControl', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,9 @@ class DatasourceControl extends React.PureComponent {
}
}

console.log(this.props);
const isSqlSupported = datasource.type === 'table';
const appContainer = document.getElementById('app');
const { user } = JSON.parse(
appContainer?.getAttribute('data-bootstrap') || '{}',
);
const { user } = this.props;
const allowEdit =
datasource.owners.map(o => o.id).includes(user.userId) ||
isUserAdmin(user);
Expand Down

0 comments on commit c409a23

Please sign in to comment.