Skip to content
Snippets Groups Projects
Commit 33dfe92a authored by Sameer Al-Sakran's avatar Sameer Al-Sakran Committed by GitHub
Browse files

Merge pull request #5565 from metabase/fix_5417

Fix 5417
parents 595c2625 ca71a555
No related branches found
No related tags found
No related merge requests found
......@@ -146,6 +146,27 @@ export const fetchDatabases = createThunkAction(FETCH_DATABASES, (reload = false
};
});
export const FETCH_REAL_DATABASES = "metabase/metadata/FETCH_REAL_DATABASES";
export const fetchRealDatabases = createThunkAction(FETCH_REAL_DATABASES, (reload = false) => {
return async (dispatch, getState) => {
const requestStatePath = ["metadata", "databases"];
const existingStatePath = requestStatePath;
const getData = async () => {
const databases = await MetabaseApi.db_real_list_with_tables();
return normalize(databases, [DatabaseSchema]);
};
return await fetchData({
dispatch,
getState,
requestStatePath,
existingStatePath,
getData,
reload
});
};
});
export const FETCH_DATABASE_METADATA = "metabase/metadata/FETCH_DATABASE_METADATA";
export const fetchDatabaseMetadata = createThunkAction(FETCH_DATABASE_METADATA, function(dbId, reload = false) {
return async function(dispatch, getState) {
......
......@@ -10,7 +10,7 @@ import { CardApi } from 'metabase/services'
import {
FETCH_DATABASE_METADATA,
FETCH_DATABASES
FETCH_REAL_DATABASES
} from "metabase/redux/metadata";
import { END_LOADING } from "metabase/reference/reference"
......@@ -48,7 +48,7 @@ describe("The Reference Section", () => {
const store = await createTestStore()
store.pushPath("/reference/databases/");
var container = mount(store.connectContainer(<DatabaseListContainer />));
await store.waitForActions([FETCH_DATABASES, END_LOADING])
await store.waitForActions([FETCH_REAL_DATABASES, END_LOADING])
expect(container.find(ReferenceHeader).length).toBe(1)
expect(container.find(DatabaseList).length).toBe(1)
......@@ -58,6 +58,28 @@ describe("The Reference Section", () => {
expect(container.find(ListItem).length).toBeGreaterThanOrEqual(1)
})
// database list
it("should not see saved questions in the database list", async () => {
var card = await CardApi.create(cardDef)
const store = await createTestStore()
store.pushPath("/reference/databases/");
var container = mount(store.connectContainer(<DatabaseListContainer />));
await store.waitForActions([FETCH_REAL_DATABASES, END_LOADING])
expect(container.find(ReferenceHeader).length).toBe(1)
expect(container.find(DatabaseList).length).toBe(1)
expect(container.find(AdminAwareEmptyState).length).toBe(0)
expect(container.find(List).length).toBe(1)
expect(container.find(ListItem).length).toBe(1)
expect(card.name).toBe(cardDef.name);
await CardApi.delete({cardId: card.id})
})
// database detail
it("should see a the detail view for the sample database", async ()=>{
const store = await createTestStore()
......
......@@ -176,7 +176,7 @@ export const wrappedFetchMetricRevisions = async (props, metricID) => {
// }
export const wrappedFetchDatabases = (props) => {
fetchDataWrapper(props, props.fetchDatabases)({})
fetchDataWrapper(props, props.fetchRealDatabases)({})
}
export const wrappedFetchMetrics = (props) => {
fetchDataWrapper(props, props.fetchMetrics)({})
......
......@@ -95,6 +95,7 @@ export const LdapApi = {
export const MetabaseApi = {
db_list: GET("/api/database"),
db_list_with_tables: GET("/api/database?include_tables=true&include_cards=true"),
db_real_list_with_tables: GET("/api/database?include_tables=true&include_cards=false"),
db_create: POST("/api/database"),
db_add_sample_dataset: POST("/api/database/sample_dataset"),
db_get: GET("/api/database/:dbId"),
......
......@@ -135,7 +135,7 @@
[include_tables include_cards]
{include_tables (s/maybe su/BooleanString)
include_cards (s/maybe su/BooleanString)}
(or (dbs-list include_tables include_cards)
(or (dbs-list (Boolean/parseBoolean include_tables) (Boolean/parseBoolean include_cards))
[]))
......
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