Skip to content
Snippets Groups Projects
Unverified Commit 29595dfc authored by Alexander Polyankin's avatar Alexander Polyankin Committed by GitHub
Browse files

Show x-rays when there is no question and dashboard (#21579)

parent af8f043b
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ import SyncedParametersList from "metabase/parameters/components/SyncedParameter ...@@ -22,6 +22,7 @@ import SyncedParametersList from "metabase/parameters/components/SyncedParameter
import { getMetadata } from "metabase/selectors/metadata"; import { getMetadata } from "metabase/selectors/metadata";
import Collections from "metabase/entities/collections";
import Dashboards from "metabase/entities/dashboards"; import Dashboards from "metabase/entities/dashboards";
import * as Urls from "metabase/lib/urls"; import * as Urls from "metabase/lib/urls";
import * as MetabaseAnalytics from "metabase/lib/analytics"; import * as MetabaseAnalytics from "metabase/lib/analytics";
...@@ -48,6 +49,7 @@ const mapStateToProps = (state, props) => ({ ...@@ -48,6 +49,7 @@ const mapStateToProps = (state, props) => ({
const mapDispatchToProps = { const mapDispatchToProps = {
saveDashboard: Dashboards.actions.save, saveDashboard: Dashboards.actions.save,
invalidateCollections: Collections.actions.invalidateLists,
}; };
@connect(mapStateToProps, mapDispatchToProps) @connect(mapStateToProps, mapDispatchToProps)
...@@ -67,11 +69,17 @@ class AutomaticDashboardApp extends React.Component { ...@@ -67,11 +69,17 @@ class AutomaticDashboardApp extends React.Component {
} }
save = async () => { save = async () => {
const { dashboard, triggerToast, saveDashboard } = this.props; const {
dashboard,
triggerToast,
saveDashboard,
invalidateCollections,
} = this.props;
// remove the transient id before trying to save // remove the transient id before trying to save
const { payload: newDashboard } = await saveDashboard( const { payload: newDashboard } = await saveDashboard(
dissoc(dashboard, "id"), dissoc(dashboard, "id"),
); );
invalidateCollections();
triggerToast( triggerToast(
<div className="flex align-center"> <div className="flex align-center">
{t`Your dashboard was saved`} {t`Your dashboard was saved`}
......
...@@ -43,8 +43,8 @@ const isPopularSection = ({ ...@@ -43,8 +43,8 @@ const isPopularSection = ({
); );
}; };
const isRecentSection = ({ recentItems }: HomeContentProps): boolean => { const isRecentSection = ({ user, recentItems }: HomeContentProps): boolean => {
return recentItems.length > 0; return user.has_question_and_dashboard && recentItems.length > 0;
}; };
const isXraySection = ({ databases }: HomeContentProps): boolean => { const isXraySection = ({ databases }: HomeContentProps): boolean => {
......
...@@ -93,6 +93,22 @@ describe("HomeContent", () => { ...@@ -93,6 +93,22 @@ describe("HomeContent", () => {
expect(screen.getByText("XraySection")).toBeInTheDocument(); expect(screen.getByText("XraySection")).toBeInTheDocument();
}); });
it("should render x-rays for the installer when there is no question and dashboard", () => {
const props = getProps({
user: createMockUser({
is_installer: true,
has_question_and_dashboard: false,
first_login: "2020-01-10T00:00:00Z",
}),
databases: [createMockDatabase()],
recentItems: [createMockRecentItem()],
});
render(<HomeContent {...props} />);
expect(screen.getByText("XraySection")).toBeInTheDocument();
});
it("should render nothing if there are no databases", () => { it("should render nothing if there are no databases", () => {
const props = getProps({ const props = getProps({
user: createMockUser({ user: createMockUser({
......
...@@ -338,6 +338,11 @@ export function createEntity(def) { ...@@ -338,6 +338,11 @@ export function createEntity(def) {
}; };
}), }),
invalidateLists: compose(
withAction(INVALIDATE_LISTS_ACTION),
withEntityActionDecorators("invalidateLists"),
)(() => null),
// user defined actions should override defaults // user defined actions should override defaults
...entity.objectActions, ...entity.objectActions,
...(def.actions || {}), ...(def.actions || {}),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment