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 bug where error at import dashboard fails to show toast in "welcome" app #9714

Merged
merged 13 commits into from
May 8, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,17 @@ fetchMock.get(dashboardsEndpoint, {
dashboard_count: 3,
});

const common = {
pkdotson marked this conversation as resolved.
Show resolved Hide resolved
config: {},
feature_flags: {},
language_pack: {},
local: '',
flash_messages: [],
}

describe('DashboardList', () => {
const mockedProps = {};
const wrapper = mount(<DashboardList {...mockedProps} />, {
const wrapper = mount(<DashboardList {...mockedProps} common={common}/>, {
context: { store },
});

Expand Down
9 changes: 8 additions & 1 deletion superset-frontend/src/views/dashboardList/DashboardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ const PAGE_SIZE = 25;
interface Props {
addDangerToast: (msg: string) => void;
addSuccessToast: (msg: string) => void;
common: {
flash_messages: any[];
pkdotson marked this conversation as resolved.
Show resolved Hide resolved
};
}

interface State {
Expand Down Expand Up @@ -82,6 +85,11 @@ class DashboardList extends React.PureComponent<Props, State> {
};

componentDidMount() {
let messages = this.props.common.flash_messages;
if(messages.length > 0){
pkdotson marked this conversation as resolved.
Show resolved Hide resolved
let text = messages[0][1]
this.props.addDangerToast(text)
pkdotson marked this conversation as resolved.
Show resolved Hide resolved
}
Promise.all([
SupersetClient.get({
endpoint: `/api/v1/dashboard/_info`,
Expand Down Expand Up @@ -461,7 +469,6 @@ class DashboardList extends React.PureComponent<Props, State> {
filters,
dashboardToEdit,
} = this.state;

return (
<div className="container welcome">
<Panel>
Expand Down
6 changes: 3 additions & 3 deletions superset-frontend/src/welcome/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const container = document.getElementById('app');
const bootstrap = JSON.parse(container.getAttribute('data-bootstrap'));
const user = { ...bootstrap.user };
const menu = { ...bootstrap.common.menu_data };

const common = {...bootstrap.common}
initFeatureFlags(bootstrap.common.feature_flags);

const store = createStore(
Expand All @@ -56,7 +56,7 @@ const store = createStore(
{},
compose(applyMiddleware(thunk), initEnhancer(false)),
);

console.log('store', store)
pkdotson marked this conversation as resolved.
Show resolved Hide resolved
const App = () => (
<Provider store={store}>
<ThemeProvider theme={supersetTheme}>
Expand All @@ -68,7 +68,7 @@ const App = () => (
<Welcome user={user} />
</Route>
<Route path="/dashboard/list/">
<DashboardList user={user} />
<DashboardList user={user} common={common} />
pkdotson marked this conversation as resolved.
Show resolved Hide resolved
</Route>
<Route path="/chart/list/">
<ChartList user={user} />
Expand Down