Skip to content
Snippets Groups Projects
Commit afa4bc6a authored by Allen Gilliland's avatar Allen Gilliland
Browse files

provide information about our `:engines` through our main MetabaseSettings...

provide information about our `:engines` through our main MetabaseSettings which simplifies some things and removes the need for a /api/database/form_input endpoint.
parent a7136251
No related branches found
No related tags found
No related merge requests found
......@@ -36,7 +36,6 @@ function createThunkAction(actionType, actionThunkCreator) {
// // resource wrappers
const SetupApi = new AngularResourceProxy("Setup", ["create", "validate_db"]);
const UtilApi = new AngularResourceProxy("Util", ["password_check"]);
const MetabaseApi = new AngularResourceProxy("Metabase", ["db_form_input"]);
// action constants
......@@ -48,7 +47,6 @@ export const VALIDATE_DATABASE = 'VALIDATE_DATABASE';
export const VALIDATE_PASSWORD = 'VALIDATE_PASSWORD';
export const SUBMIT_SETUP = 'SUBMIT_SETUP';
export const COMPLETE_SETUP = 'COMPLETE_SETUP';
export const FETCH_ENGINES = 'FETCH_ENGINES';
// action creators
......@@ -111,10 +109,3 @@ export const completeSetup = createAction(COMPLETE_SETUP, function(apiResponse)
return true;
});
export const fetchEngines = createThunkAction(FETCH_ENGINES, function() {
return async function(dispatch, getState) {
let formInput = await MetabaseApi.db_form_input();
return formInput.engines;
};
});
......@@ -4,6 +4,7 @@ import _ from "underscore";
import DatabaseDetailsForm from "metabase/components/database/DatabaseDetailsForm.jsx";
import FormField from "metabase/components/form/FormField.jsx";
import MetabaseAnalytics from "metabase/lib/analytics";
import MetabaseSettings from "metabase/lib/settings";
import StepTitle from './StepTitle.jsx'
import CollapsedStep from "./CollapsedStep.jsx";
......@@ -18,7 +19,6 @@ export default class DatabaseStep extends Component {
static propTypes = {
dispatch: PropTypes.func.isRequired,
engines: PropTypes.object.isRequired,
stepNumber: PropTypes.number.isRequired
}
......@@ -92,7 +92,7 @@ export default class DatabaseStep extends Component {
}
renderEngineSelect() {
let { engines } = this.props;
let engines = MetabaseSettings.get('engines');
let { engine } = this.state,
engineNames = _.keys(engines).sort();
......@@ -107,8 +107,9 @@ export default class DatabaseStep extends Component {
}
render() {
let { activeStep, databaseDetails, dispatch, engines, stepNumber } = this.props;
let { activeStep, databaseDetails, dispatch, stepNumber } = this.props;
let { engine, formError } = this.state;
let engines = MetabaseSettings.get('engines');
let stepText = 'Add your data';
if (activeStep > stepNumber) {
......
......@@ -8,7 +8,7 @@ import UserStep from './UserStep.jsx';
import DatabaseStep from './DatabaseStep.jsx';
import PreferencesStep from './PreferencesStep.jsx';
import { setActiveStep, fetchEngines } from '../actions';
import { setActiveStep } from '../actions';
const WELCOME_STEP_NUMBER = 0;
const USER_STEP_NUMBER = 1;
......@@ -21,10 +21,6 @@ export default class Setup extends Component {
dispatch: PropTypes.func.isRequired
}
componentDidMount() {
this.props.dispatch(fetchEngines());
}
completeWelcome() {
this.props.dispatch(setActiveStep(USER_STEP_NUMBER));
MetabaseAnalytics.trackEvent('Setup', 'Welcome');
......
......@@ -6,8 +6,7 @@ import {
SET_DATABASE_DETAILS,
SET_ALLOW_TRACKING,
SUBMIT_SETUP,
COMPLETE_SETUP,
FETCH_ENGINES
COMPLETE_SETUP
} from './actions';
......@@ -36,7 +35,3 @@ export const setupError = handleActions({
export const setupComplete = handleActions({
[COMPLETE_SETUP]: { next: (state, { payload }) => true }
}, false);
export const engines = handleActions({
[FETCH_ENGINES]: { next: (state, { payload }) => payload }
}, {});
......@@ -7,11 +7,10 @@ const databaseDetailsSelector = state => state.databaseDetails;
const allowTrackingSelector = state => state.allowTracking;
const setupErrorSelector = state => state.setupError;
const setupCompleteSelector = state => state.setupComplete;
const enginesSelector = state => state.engines;
// our master selector which combines all of our partial selectors above
export const setupSelectors = createSelector(
[activeStepSelector, userDetailsSelector, databaseDetailsSelector, allowTrackingSelector, setupErrorSelector, setupCompleteSelector, enginesSelector],
(activeStep, userDetails, databaseDetails, allowTracking, setupError, setupComplete, engines) => ({activeStep, userDetails, databaseDetails, allowTracking, setupError, setupComplete, engines})
[activeStepSelector, userDetailsSelector, databaseDetailsSelector, allowTrackingSelector, setupErrorSelector, setupCompleteSelector],
(activeStep, userDetails, databaseDetails, allowTracking, setupError, setupComplete) => ({activeStep, userDetails, databaseDetails, allowTracking, setupError, setupComplete})
);
......@@ -42,17 +42,6 @@
(sample-data/add-sample-dataset!)
(sel :one Database :is_sample true))
(defn form-input
"`GET /api/database/form_input`
Values of options for the create/edit `Database` UI.
This is defined *without* using `defendpoint` because we don't want it to be included in `routes`, which would make
it subject to the `+auth` requirements we use for those endpoints."
[_]
{:status 200
:body {:timezones metabase.models.common/timezones
:engines @driver/available-drivers}})
;; Stub function that will eventually validate a connection string
(defendpoint POST "/validate"
"Validate that we can connect to a `Database`."
......
......@@ -28,26 +28,25 @@
middleware/enforce-authentication)
(defroutes routes
(context "/activity" [] (+auth activity/routes))
(context "/card" [] (+auth card/routes))
(context "/dashboard" [] (+auth dashboard/routes))
(GET "/database/form_input" [] database/form-input) ; this endpoint included separately so it's not subject to +auth
(context "/database" [] (+auth database/routes))
(context "/dataset" [] (+auth dataset/routes))
(context "/field" [] (+auth field/routes))
(context "/foreignkey" [] (+auth fk/routes))
(GET "/health" [] (if ((resolve 'metabase.core/initialized?))
(context "/activity" [] (+auth activity/routes))
(context "/card" [] (+auth card/routes))
(context "/dashboard" [] (+auth dashboard/routes))
(context "/database" [] (+auth database/routes))
(context "/dataset" [] (+auth dataset/routes))
(context "/field" [] (+auth field/routes))
(context "/foreignkey" [] (+auth fk/routes))
(GET "/health" [] (if ((resolve 'metabase.core/initialized?))
{:status 200 :body {:status "ok"}}
{:status 503 :body {:status "initializing" :progress ((resolve 'metabase.core/initialization-progress))}}))
(context "/notify" [] (+apikey notify/routes))
(context "/revision" [] (+auth revision/routes))
(context "/session" [] session/routes)
(context "/setting" [] (+auth setting/routes))
(context "/setup" [] setup/routes)
(context "/table" [] (+auth table/routes))
(context "/tiles" [] (+auth tiles/routes))
(context "/user" [] (+auth user/routes))
(context "/util" [] util/routes)
(context "/notify" [] (+apikey notify/routes))
(context "/revision" [] (+auth revision/routes))
(context "/session" [] session/routes)
(context "/setting" [] (+auth setting/routes))
(context "/setup" [] setup/routes)
(context "/table" [] (+auth table/routes))
(context "/tiles" [] (+auth tiles/routes))
(context "/user" [] (+auth user/routes))
(context "/util" [] util/routes)
(route/not-found (fn [{:keys [request-method uri]}]
{:status 404
:body (str (.toUpperCase (name request-method)) " " uri " is not yet implemented.")})))
......@@ -155,7 +155,8 @@
(defn public-settings
"Return a simple map of key/value pairs which represent the public settings for the front-end application."
[]
{:ga_code "UA-60817802-1"
{:engines (deref @(ns-resolve 'metabase.driver 'available-drivers))
:ga_code "UA-60817802-1"
:password_complexity (password/active-password-complexity)
:setup_token (setup/token-value)
:timezones common/timezones
......
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