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
Renamed Library to Synced Collection (#65447)
Nathan Voxlanda133b31fc42c
diff --git a/e2e/support/assets/example_library/collections/AF_m-cEw4pFjXYd90_tnj_library/AF_m-cEw4pFjXYd90_tnj_library.yaml b/e2e/support/assets/example_synced_collection/collections/AF_m-cEw4pFjXYd90_tnj_library/AF_m-cEw4pFjXYd90_tnj_library.yamlsimilarity index 81%rename from e2e/support/assets/example_library/collections/AF_m-cEw4pFjXYd90_tnj_library/AF_m-cEw4pFjXYd90_tnj_library.yamlrename to e2e/support/assets/example_synced_collection/collections/AF_m-cEw4pFjXYd90_tnj_library/AF_m-cEw4pFjXYd90_tnj_library.yamlindex cb31d051136..b19c6145a33 100644--- a/e2e/support/assets/example_library/collections/AF_m-cEw4pFjXYd90_tnj_library/AF_m-cEw4pFjXYd90_tnj_library.yaml+++ b/e2e/support/assets/example_synced_collection/collections/AF_m-cEw4pFjXYd90_tnj_library/AF_m-cEw4pFjXYd90_tnj_library.yaml@@ -1,9 +1,9 @@authority_level: nulldescription: nullarchived: false-slug: library+slug: synced_collectionarchive_operation_id: null-name: Library+name: Synced Collectionpersonal_owner_id: nulltype: remote-syncedis_sample: false@@ -11,7 +11,7 @@ parent_id: nullserdes/meta:- model: Collectionid: AF_m-cEw4pFjXYd90_tnj- label: library+ label: synced_collectionarchived_directly: nullentity_id: AF_m-cEw4pFjXYd90_tnjnamespace: nulldiff --git a/e2e/support/assets/example_library/collections/AF_m-cEw4pFjXYd90_tnj_library/cards/emoZpKzkmTi_zmyqeUB1O_remote_sync_test_question.yaml b/e2e/support/assets/example_synced_collection/collections/AF_m-cEw4pFjXYd90_tnj_library/cards/emoZpKzkmTi_zmyqeUB1O_remote_sync_test_question.yamlsimilarity index 100%rename from e2e/support/assets/example_library/collections/AF_m-cEw4pFjXYd90_tnj_library/cards/emoZpKzkmTi_zmyqeUB1O_remote_sync_test_question.yamlrename to e2e/support/assets/example_synced_collection/collections/AF_m-cEw4pFjXYd90_tnj_library/cards/emoZpKzkmTi_zmyqeUB1O_remote_sync_test_question.yamldiff --git a/e2e/support/helpers/e2e-remote-sync-helpers.ts b/e2e/support/helpers/e2e-remote-sync-helpers.tsindex 0a5eb3cf8da..ad13c78d63e 100644--- a/e2e/support/helpers/e2e-remote-sync-helpers.ts+++ b/e2e/support/helpers/e2e-remote-sync-helpers.ts@@ -14,22 +14,25 @@ import {export const LOCAL_GIT_PATH =Cypress.config("projectRoot") + "/e2e/tmp/test-repo";-export const LIBRARY_FIXTURE_PATH =- Cypress.config("projectRoot") + "/e2e/support/assets/example_library";+export const SYNCED_COLLECTION_FIXTURE_PATH =+ Cypress.config("projectRoot") ++ "/e2e/support/assets/example_synced_collection";-// Copy the sample library from the fixture folder to the working directory-export const copyLibraryFixture = () => {+// Copy the sample synced collection from the fixture folder to the working directory+export const copySyncedCollectionFixture = () => {cy.task("copyDirectory", {- source: LIBRARY_FIXTURE_PATH,+ source: SYNCED_COLLECTION_FIXTURE_PATH,destination: LOCAL_GIT_PATH,});};-export const checkoutLibraryBranch = (branch: string) => {+export const checkoutSyncedCollectionBranch = (branch: string) => {cy.exec("git -C " + LOCAL_GIT_PATH + ` checkout -b '${branch}'`);};-export const commitToLibrary = (message = "Adding content to library") => {+export const commitToRepo = (+ message = "Adding content to synced collection",+) => {cy.exec("git -C " +LOCAL_GIT_PATH +@@ -74,7 +77,7 @@ export const stashChanges = () => {};// function to examine the working directory and return an array of the files present-export const wrapLibraryFiles = (alias = "libraryFiles") => {+export const wrapSyncedCollectionFiles = (alias = "syncedCollectionFiles") => {stashChanges();cy.task("readDirectory", LOCAL_GIT_PATH).then((files) => {cy.wrap(@@ -85,22 +88,22 @@ export const wrapLibraryFiles = (alias = "libraryFiles") => {});};-// Wraps the library collection for use in tests-export const wrapLibraryCollection = (alias = "library", n = 0) => {+// Wraps the synced collection for use in tests+export const wrapSyncedCollection = (alias = "syncedCollection", n = 0) => {if (n > 3) {- throw new Error("Could not find library collection");+ throw new Error("Could not find Synced Collection");}cy.request("/api/collection").then(({ body: collections }) => {- const libraryCollection = collections.find(+ const syncedCollection = collections.find((c: Collection) => c.type === "remote-synced" && c.location === "/",);- if (libraryCollection) {- cy.wrap(libraryCollection).as(alias);+ if (syncedCollection) {+ cy.wrap(syncedCollection).as(alias);} else {cy.wait(500);- wrapLibraryCollection(alias, n + 1);+ wrapSyncedCollection(alias, n + 1);}});};@@ -113,11 +116,11 @@ export const updateRemoteQuestion = (assertionsFn?: (val: Record<string, any>) => void,commitMessage = "Local Update",) => {- wrapLibraryFiles();- cy.get("@libraryFiles").then((libraryFiles) => {- const questionFilePath = (libraryFiles as unknown as string[]).find(- (file) => file.includes("remote_sync_test_question.yaml"),- );+ wrapSyncedCollectionFiles();+ cy.get("@syncedCollectionFiles").then((syncedCollectionFiles) => {+ const questionFilePath = (+ syncedCollectionFiles as unknown as string[]+ ).find((file) => file.includes("remote_sync_test_question.yaml"));const fullPath = `${LOCAL_GIT_PATH}/${questionFilePath}`;@@ -134,7 +137,7 @@ export const updateRemoteQuestion = (});};-export const moveCollectionItemToLibrary = (name: string) => {+export const moveCollectionItemToSyncedCollection = (name: string) => {navigationSidebar().findByRole("treeitem", { name: /Our analytics/ }).click();@@ -144,21 +147,21 @@ export const moveCollectionItemToLibrary = (name: string) => {entityPickerModal().within(() => {cy.findAllByRole("tab", { name: /Browse|Collections/ }).click();- entityPickerModalItem(1, "Library").click();+ entityPickerModalItem(1, "Synced Collection").click();cy.button("Move").click();});getSyncStatusIndicators().should("have.length", 1);navigationSidebar()- .findByRole("treeitem", { name: /Library/ })+ .findByRole("treeitem", { name: /Synced Collection/ }).click();collectionTable().findByText(name).should("exist");};-export const goToLibrary = (opts?: Partial<Cypress.ClickOptions>) =>+export const goToSyncedCollection = (opts?: Partial<Cypress.ClickOptions>) =>navigationSidebar()- .findByRole("treeitem", { name: /Library/ })+ .findByRole("treeitem", { name: /Synced Collection/ }).click(opts);export const branchPicker = (opts?: Partial<MatcherOptions>) =>diff --git a/e2e/test/scenarios/admin/remote-sync.cy.spec.ts b/e2e/test/scenarios/admin/remote-sync.cy.spec.tsindex 08b3e8b1926..21f0b64e7d0 100644--- a/e2e/test/scenarios/admin/remote-sync.cy.spec.ts+++ b/e2e/test/scenarios/admin/remote-sync.cy.spec.ts@@ -27,16 +27,16 @@ H.describeWithSnowplowEE("Remote Sync", () => {describe("Development Mode", () => {it("can push and pull changes", () => {H.configureGit("development");- H.wrapLibraryCollection();+ H.wrapSyncedCollection();const UPDATED_REMOTE_QUESTION_NAME = "Updated Question Name";- cy.get("@library").then((libraryCollection) => {+ cy.get("@syncedCollection").then((syncedCollection) => {H.createQuestion({name: REMOTE_QUESTION_NAME,query: {"source-table": PRODUCTS_ID,},- collection_id: (libraryCollection as unknown as Collection)+ collection_id: (syncedCollection as unknown as Collection).id as number,});});@@ -46,7 +46,7 @@ H.describeWithSnowplowEE("Remote Sync", () => {// Ensure that status icon is presentH.getSyncStatusIndicators().should("have.length.greaterThan", 0);H.navigationSidebar()- .findByRole("link", { name: /Library/ })+ .findByRole("link", { name: /Synced Collection/ }).click();H.collectionTable().findByText(REMOTE_QUESTION_NAME).should("exist");@@ -66,7 +66,7 @@ H.describeWithSnowplowEE("Remote Sync", () => {});H.navigationSidebar()- .findByRole("link", { name: /Library/ })+ .findByRole("link", { name: /Synced Collection/ }).findByTestId("remote-sync-status").should("not.exist");@@ -95,9 +95,9 @@ H.describeWithSnowplowEE("Remote Sync", () => {.should("exist");});- it("should not allow you to move content to the library that references non library items", () => {+ it("should not allow you to move content to the Synced Collection that references non Synced Collection items", () => {H.configureGit("development");- H.wrapLibraryCollection();+ H.wrapSyncedCollection();cy.intercept("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`).as("updateDashboard",);@@ -111,7 +111,7 @@ H.describeWithSnowplowEE("Remote Sync", () => {H.entityPickerModal().within(() => {H.entityPickerModalTab("Collections").click();- H.entityPickerModalItem(1, "Library").click();+ H.entityPickerModalItem(1, "Synced Collection").click();cy.button("Move").click();});@@ -128,7 +128,7 @@ H.describeWithSnowplowEE("Remote Sync", () => {H.entityPickerModal().within(() => {H.entityPickerModalTab("Browse").click();- H.entityPickerModalItem(1, "Library").click();+ H.entityPickerModalItem(1, "Synced Collection").click();cy.button("Move").click();});@@ -137,15 +137,15 @@ H.describeWithSnowplowEE("Remote Sync", () => {it("should show a warning modal when you try to push but are out of date", () => {const NEW_BRANCH = `new-branch-${Date.now()}`;- H.copyLibraryFixture();- H.commitToLibrary();+ H.copySyncedCollectionFixture();+ H.commitToRepo();H.configureGit("development");- H.wrapLibraryCollection();+ H.wrapSyncedCollection();cy.visit("/collection/root");// Make a change in metabase- H.moveCollectionItemToLibrary("Orders");+ H.moveCollectionItemToSyncedCollection("Orders");// Make a change outside metabaseH.updateRemoteQuestion((doc) => {@@ -175,12 +175,12 @@ H.describeWithSnowplowEE("Remote Sync", () => {H.navigationSidebar().findByTestId("branch-picker-button").should("contain.text", NEW_BRANCH);- H.goToLibrary();+ H.goToSyncedCollection();H.collectionTable().within(() => {// Question we just movedcy.findByText("Orders");- // Question we previously had in the library+ // Question we previously had in the Synced Collectioncy.findByText("Remote Sync Test Question");});@@ -251,7 +251,7 @@ H.describeWithSnowplowEE("Remote Sync", () => {it("should allow you to create new branches and switch between them", () => {H.configureGit("development");- H.wrapLibraryCollection();+ H.wrapSyncedCollection();const NEW_BRANCH_1 = `new-branch-${Date.now()}`;const NEW_BRANCH_2 = `new-branch-${Date.now() + 1}`;@@ -259,24 +259,24 @@ H.describeWithSnowplowEE("Remote Sync", () => {cy.visit("/collection/root");H.navigationSidebar()- .findByRole("treeitem", { name: /Library/ })+ .findByRole("treeitem", { name: /Synced Collection/ }).click();- // Synced Library starts empty+ // Synced Synced Collection starts emptyH.collectionTable().should("not.exist");cy.findByTestId("collection-empty-state").should("exist");createNewBranch(NEW_BRANCH_1);- // Move something into Library for the new branch- H.moveCollectionItemToLibrary("Orders, Count");+ // Move something into Synced Collection for the new branch+ H.moveCollectionItemToSyncedCollection("Orders, Count");pushUpdates();// Go back to the main branchcreateNewBranch(NEW_BRANCH_2);- H.moveCollectionItemToLibrary("Orders Model");+ H.moveCollectionItemToSyncedCollection("Orders Model");H.collectionTable().findByText("Orders, Count").should("exist");H.collectionTable().findByText("Orders Model").should("exist");@@ -303,17 +303,17 @@ H.describeWithSnowplowEE("Remote Sync", () => {cy.visit("/collection/root");H.navigationSidebar()- .findByRole("treeitem", { name: /Library/ })+ .findByRole("treeitem", { name: /Synced Collection/ }).click();- // Synced Library starts empty+ // Synced Synced Collection starts emptyH.collectionTable().should("not.exist");cy.findByTestId("collection-empty-state").should("exist");createNewBranch(NEW_BRANCH);- // Move something into Library for the new branch- H.moveCollectionItemToLibrary("Orders, Count");+ // Move something into Synced Collection for the new branch+ H.moveCollectionItemToSyncedCollection("Orders, Count");// Attempt to go back to mainswitchToExistingBranch("main");@@ -349,17 +349,17 @@ H.describeWithSnowplowEE("Remote Sync", () => {describe("unsynced changes", () => {beforeEach(() => {- H.copyLibraryFixture();- H.commitToLibrary();+ H.copySyncedCollectionFixture();+ H.commitToRepo();H.configureGit("development");- H.wrapLibraryCollection();+ H.wrapSyncedCollection();cy.visit("/collection/root");// Make a change in metabase- H.moveCollectionItemToLibrary("Orders");+ H.moveCollectionItemToSyncedCollection("Orders");- H.goToLibrary();+ H.goToSyncedCollection();H.navigationSidebar().findByRole("button", { name: "Pull from Git" }).click();@@ -474,17 +474,19 @@ H.describeWithSnowplowEE("Remote Sync", () => {"exist",);cy.findByTestId("branch-picker-button").should("contain.text", "main");- cy.findByRole("treeitem", { name: /library/i }).should("exist");+ cy.findByRole("treeitem", { name: /Synced Collection/i }).should(+ "exist",+ );});});it("can set up production mode", () => {- // Set up a library to connect to, otherwise production mode will be empty+ // Set up a Synced Collection to connect to, otherwise production mode will be empty// Copy some files- H.copyLibraryFixture();+ H.copySyncedCollectionFixture();// Commit those files to the main branch- H.commitToLibrary();+ H.commitToRepo();cy.visit("/admin/settings/remote-sync");cy.findByLabelText(/repository url/i)@@ -506,7 +508,7 @@ H.describeWithSnowplowEE("Remote Sync", () => {);cy.findByTestId("branch-picker-button").should("not.exist");- cy.findByRole("treeitem", { name: /Library/ }).click();+ cy.findByRole("treeitem", { name: /Synced Collection/ }).click();});});@@ -530,8 +532,8 @@ H.describeWithSnowplowEE("Remote Sync", () => {});it("can deactivate remote sync", () => {- H.copyLibraryFixture();- H.commitToLibrary();+ H.copySyncedCollectionFixture();+ H.commitToRepo();H.configureGit("development");cy.visit("/admin/settings/remote-sync");@@ -560,7 +562,7 @@ H.describeWithSnowplowEE("Remote Sync", () => {cy.findByTestId("exit-admin").click();- ensureLibraryCollectionIsVisible();+ ensureSyncedCollectionIsVisible();});});@@ -575,19 +577,19 @@ H.describeWithSnowplowEE("Remote Sync", () => {it("can change branches", () => {const UPDATED_REMOTE_QUESTION_NAME = "New Name";- H.copyLibraryFixture();- H.commitToLibrary();+ H.copySyncedCollectionFixture();+ H.commitToRepo();H.configureGit("production");cy.visit("/");H.navigationSidebar()- .findByRole("treeitem", { name: /Library/ })+ .findByRole("treeitem", { name: /Synced Collection/ }).click();H.collectionTable().findByText(REMOTE_QUESTION_NAME);// Make a change, and commit it to the branch- H.checkoutLibraryBranch("test");+ H.checkoutSyncedCollectionBranch("test");H.updateRemoteQuestion((doc) => {doc.name = UPDATED_REMOTE_QUESTION_NAME;return doc;@@ -612,15 +614,15 @@ H.describeWithSnowplowEE("Remote Sync", () => {cy.visit("/");H.navigationSidebar()- .findByRole("treeitem", { name: /Library/ })+ .findByRole("treeitem", { name: /Synced Collection/ }).click();H.collectionTable().findByText(UPDATED_REMOTE_QUESTION_NAME);});});});-const ensureLibraryCollectionIsVisible = () => {+const ensureSyncedCollectionIsVisible = () => {H.navigationSidebar().within(() => {- cy.findByRole("treeitem", { name: /Library/ }).should("exist");+ cy.findByRole("treeitem", { name: /Synced Collection/ }).should("exist");});};diff --git a/src/metabase/collections/models/collection.clj b/src/metabase/collections/models/collection.cljindex 07463272258..983caae27ed 100644--- a/src/metabase/collections/models/collection.clj+++ b/src/metabase/collections/models/collection.clj@@ -132,7 +132,7 @@[](when-not (nil? (remote-synced-collection))(throw (ex-info "Remote-synced collection already exists" {})))- (t2/insert-returning-instance! :model/Collection {:name "Library"+ (t2/insert-returning-instance! :model/Collection {:name "Synced Collection":type remote-synced-collection-type:location "/"}))