diff --git a/src/connection/database/index.js b/src/connection/database/index.js index 1aba5cb29..86c69cdb2 100644 --- a/src/connection/database/index.js +++ b/src/connection/database/index.js @@ -9,6 +9,7 @@ import { import { dataFns } from '../../utils/data_utils'; import sync from '../../sync'; import trim from 'trim'; +import { defaultDirectory } from '../../core/tenant'; const { get, initNS, tget, tset } = dataFns(["database"]); @@ -224,7 +225,9 @@ export function defaultDatabaseConnectionName(m) { } export function databaseConnection(m) { - return defaultDatabaseConnection(m) || l.connection(m, "database"); + return defaultDirectory(m) || + defaultDatabaseConnection(m) || + l.connection(m, "database"); } export function databaseConnectionName(m) { diff --git a/src/core/tenant/index.js b/src/core/tenant/index.js index dace0c29c..9e0b4d5d6 100644 --- a/src/core/tenant/index.js +++ b/src/core/tenant/index.js @@ -1,5 +1,6 @@ import Immutable, { List, Map } from 'immutable'; import { dataFns } from '../../utils/data_utils'; +import * as l from '../index'; const { initNS, get } = dataFns(["client"]); @@ -39,7 +40,8 @@ export function initTenant(m, client_id, client) { function formatTenant(client_id, o) { return new Immutable.fromJS({ - connections: formatTenantConnections(client_id, o) + connections: formatTenantConnections(client_id, o), + default_directory: o.default_directory || null }) } @@ -94,3 +96,12 @@ function formatTenantConnection(connectionType, connection) { export function tenantConnections(m) { return get(m, "connections", emptyConnections); } + +export function defaultDirectory(m) { + const name = defaultDirectoryName(m); + return name && l.findConnection(m, name); +} + +export function defaultDirectoryName(m) { + return get(m, "default_directory", null); +} diff --git a/src/engine/classic.js b/src/engine/classic.js index b8b48470e..f40c45ebb 100644 --- a/src/engine/classic.js +++ b/src/engine/classic.js @@ -25,6 +25,7 @@ import { isInCorpNetwork, quickAuthConnection } from '../connection/enterprise'; +import { defaultDirectory, defaultDirectoryName } from '../core/tenant'; import { initSocial, useBigButtons } from '../connection/social/index'; import { setEmail } from '../field/email'; import { setUsername } from '../field/username'; @@ -77,6 +78,10 @@ function validateAllowedConnections(m) { m = l.stop(m, error); } + if (defaultDirectoryName(m) && !defaultDirectory(m)) { + l.error(m, `The account's default directory "${defaultDirectoryName(m)}" is not enabled.`); + } + if (defaultDatabaseConnectionName(m) && !defaultDatabaseConnection(m)) { l.warn(m, `The provided default database connection "${defaultDatabaseConnectionName(m)}" is not enabled.`); }