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
import { getMetadata } from "metabase/selectors/metadata";
import Collections from "metabase/entities/collections";
import Dashboards from "metabase/entities/dashboards";
import * as Urls from "metabase/lib/urls";
import * as MetabaseAnalytics from "metabase/lib/analytics";
......@@ -48,6 +49,7 @@ const mapStateToProps = (state, props) => ({
const mapDispatchToProps = {
saveDashboard: Dashboards.actions.save,
invalidateCollections: Collections.actions.invalidateLists,
};
@connect(mapStateToProps, mapDispatchToProps)
......@@ -67,11 +69,17 @@ class AutomaticDashboardApp extends React.Component {
}
save = async () => {
const { dashboard, triggerToast, saveDashboard } = this.props;
const {
dashboard,
triggerToast,
saveDashboard,
invalidateCollections,
} = this.props;
// remove the transient id before trying to save
const { payload: newDashboard } = await saveDashboard(
dissoc(dashboard, "id"),
);
invalidateCollections();
triggerToast(
<div className="flex align-center">
{t`Your dashboard was saved`}
......
......@@ -43,8 +43,8 @@ const isPopularSection = ({
);
};
const isRecentSection = ({ recentItems }: HomeContentProps): boolean => {
return recentItems.length > 0;
const isRecentSection = ({ user, recentItems }: HomeContentProps): boolean => {
return user.has_question_and_dashboard && recentItems.length > 0;
};
const isXraySection = ({ databases }: HomeContentProps): boolean => {
......
......@@ -93,6 +93,22 @@ describe("HomeContent", () => {
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", () => {
const props = getProps({
user: createMockUser({
......
......@@ -338,6 +338,11 @@ export function createEntity(def) {
};
}),
invalidateLists: compose(
withAction(INVALIDATE_LISTS_ACTION),
withEntityActionDecorators("invalidateLists"),
)(() => null),
// user defined actions should override defaults
...entity.objectActions,
...(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