The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Add completion checks for creating models in embedding hub (#63661)
Phoomparin Manof65c0fb194de
diff --git a/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts b/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.tsindex 30871db0382..a57777b7512 100644--- a/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts+++ b/e2e/test/scenarios/embedding/embedding-hub/embedding-hub.cy.spec.ts@@ -110,17 +110,37 @@ describe("scenarios - embedding hub", () => {.should("be.visible");});- it('"Create models" link should navigate correctly', () => {- cy.visit("/admin/embedding/setup-guide");+ [+ { dbId: 1, dbName: "sample db" },+ { dbId: 2, dbName: "sqlite db" },+ ].forEach(({ dbId, dbName }) => {+ it(`"Create models" step should be marked in ${dbName} as done after creating a model`, () => {+ if (dbId === 2) {+ H.addSqliteDatabase(dbName);+ }++ cy.log("Create a native query model via API");+ H.createNativeQuestion(+ {+ name: "Test Model",+ type: "model",+ database: dbId,+ native: { query: "SELECT 1 as t" },+ },+ { visitQuestion: true },+ );- cy.log("Find and click on 'Create models' link");- cy.findByTestId("admin-layout-content")- .findByText("Create models")- .first()- .click();+ cy.log("Navigate to embedding setup guide");+ cy.visit("/admin/embedding/setup-guide");- cy.log("Should navigate to model creation page");- cy.url().should("include", "/model/new");+ cy.log("'Create models' should now be marked as done");+ cy.findByTestId("admin-layout-content")+ .findByText("Create models")+ .closest("button")+ .scrollIntoView()+ .findByText("Done", { timeout: 10_000 })+ .should("be.visible");+ });});it('"Embed in your code" card should take you to the embed flow', () => {diff --git a/enterprise/backend/src/metabase_enterprise/embedding_hub/api.clj b/enterprise/backend/src/metabase_enterprise/embedding_hub/api.cljindex a177759d734..437a0ef02c8 100644--- a/enterprise/backend/src/metabase_enterprise/embedding_hub/api.clj+++ b/enterprise/backend/src/metabase_enterprise/embedding_hub/api.clj@@ -40,9 +40,20 @@(or (and (premium-features/has-feature? :sso-jwt) (sso-settings/jwt-enabled) (sso-settings/jwt-configured))(and (premium-features/has-feature? :sso-saml) (sso-settings/saml-enabled) (sso-settings/saml-configured))))+(defn- has-user-created-models? []+ (t2/exists? :model/Card {:where [:and+ [:= :type "model"]+ [:= :archived false]+ [:or+ [:not-in :collection_id [(:id (audit/default-audit-collection)) {:select :id+ :from [(t2/table-name :model/Collection)]+ :where [:= :is_sample true]}]]+ [:is :collection_id nil]]]}))+(defn- embedding-hub-checklist []{"add-data" (has-user-added-database?)"create-dashboard" (has-user-created-dashboard?)+ "create-models" (has-user-created-models?)"configure-row-column-security" (has-configured-sandboxes?)"create-test-embed" (embedding.settings/embedding-hub-test-embed-snippet-created)"embed-production" (embedding.settings/embedding-hub-production-embed-snippet-created)diff --git a/frontend/src/metabase/api/embedding-hub.ts b/frontend/src/metabase/api/embedding-hub.tsindex 8a3247276eb..57a27ac277c 100644--- a/frontend/src/metabase/api/embedding-hub.ts+++ b/frontend/src/metabase/api/embedding-hub.ts@@ -5,6 +5,7 @@ import { listTag } from "./tags";type CheckListApiStep =| "create-dashboard"| "add-data"+ | "create-models"| "configure-row-column-security"| "create-test-embed"| "embed-production"diff --git a/frontend/src/metabase/embedding/embedding-hub/hooks/use-completed-embedding-hub-steps.ts b/frontend/src/metabase/embedding/embedding-hub/hooks/use-completed-embedding-hub-steps.tsindex 440463d8299..64d7f46e998 100644--- a/frontend/src/metabase/embedding/embedding-hub/hooks/use-completed-embedding-hub-steps.ts+++ b/frontend/src/metabase/embedding/embedding-hub/hooks/use-completed-embedding-hub-steps.ts@@ -29,7 +29,7 @@ export const useCompletedEmbeddingHubSteps = (): {};}- return { "create-models": false, ...embeddingHubChecklist };+ return embeddingHubChecklist;}, [embeddingHubChecklist, isLoading]);return { data, isLoading };