Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webui get config called only on create repository #917

Merged
merged 1 commit into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cmd/lakefs/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import (
"syscall"
"time"

"github.com/treeverse/lakefs/export"
"github.com/treeverse/lakefs/parade"

"github.com/dlmiddlecote/sqlstats"
"github.com/golang-migrate/migrate/v4"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/cobra"
"github.com/treeverse/lakefs/api"
Expand All @@ -25,10 +23,12 @@ import (
"github.com/treeverse/lakefs/config"
"github.com/treeverse/lakefs/db"
"github.com/treeverse/lakefs/dedup"
"github.com/treeverse/lakefs/export"
"github.com/treeverse/lakefs/gateway"
"github.com/treeverse/lakefs/gateway/simulator"
"github.com/treeverse/lakefs/httputil"
"github.com/treeverse/lakefs/logging"
"github.com/treeverse/lakefs/parade"
"github.com/treeverse/lakefs/retention"
"github.com/treeverse/lakefs/stats"
)
Expand Down Expand Up @@ -58,6 +58,8 @@ var runCmd = &cobra.Command{

if err := db.ValidateSchemaUpToDate(dbParams); errors.Is(err, db.ErrSchemaNotCompatible) {
logger.WithError(err).Fatal("Migration version mismatch")
} else if errors.Is(err, migrate.ErrNilVersion) {
logger.Debug("No migration, setup required")
} else if err != nil {
logger.WithError(err).Warn("Failed on schema validation")
}
Expand Down
18 changes: 3 additions & 15 deletions webui/src/App.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
import React, {useEffect} from 'react';

import React from 'react';
import {connect} from 'react-redux';
import Navbar from 'react-bootstrap/Navbar';
import Container from "react-bootstrap/Container";
import {BrowserRouter as Router, Switch, Route, Redirect, useLocation, useHistory, Link} from "react-router-dom";




import LoginForm from "./components/Login";
import SetupPage from "./components/SetupPage";
import NavDropdown from "react-bootstrap/NavDropdown";
import { logout, redirected } from './actions/auth';
import {getConfig} from "./actions/config";
import {IndexPage} from "./components/IndexPage";

// css imports
import 'bootswatch/dist/lumen/bootstrap.css';
import './App.css';
import Nav from "react-bootstrap/Nav";


const NavUserInfo = connect(
({ auth }) => ({ user: auth.user }),
( dispatch ) => ({ logout: () => { dispatch(logout()); } }),
Expand Down Expand Up @@ -97,12 +90,7 @@ const TopBar = ({ user }) => {
}


const App = ({ user, redirectTo, redirected, getConfig }) => {

useEffect(() => {
getConfig();
}, [getConfig]);

const App = ({ user, redirectTo, redirected }) => {
return (
<Router className="App">
<TopBar user={user}/>
Expand All @@ -127,4 +115,4 @@ export default connect(
({ auth }) => ({
user: auth.user,
redirectTo: auth.redirectTo,
}), ({ redirected, getConfig }))(App);
}), ({ redirected }))(App);
19 changes: 11 additions & 8 deletions webui/src/components/RepositoryCreateForm.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import React, {useRef, useState} from 'react';
import React, {useRef, useState, useEffect} from 'react';

import Form from "react-bootstrap/Form";
import Alert from "react-bootstrap/Alert";
import Button from "react-bootstrap/Button";
import Row from "react-bootstrap/Row";
import Col from "react-bootstrap/Col";
import {connect} from "react-redux";
import {getConfig} from "../actions/config";


const DEFAULT_BLOCKSTORE_TYPE = "s3";

export const RepositoryCreateForm = connect(
({ repositories, config }) => {
const {create} = repositories;
return {
create,
config: config.config,
};
})(({ error, onSubmit, onCancel, create, sm = 6, config }) => {
return {create, config: config.config};
}, {getConfig})(({ error, onSubmit, onCancel, create, config, getConfig, sm = 6 }) => {
const fieldNameOffset = 3;
const repoValidityRegex = /^[a-z0-9][a-z0-9-]{2,62}$/;
const storageNamespaceValidityRegex = /^(s3|gs|mem|local|transient):\/.*$/;
Expand Down Expand Up @@ -47,8 +46,12 @@ export const RepositoryCreateForm = connect(
setFormValid(isBranchValid && storageNamespaceValid && repoValid);
};

let blockstoreType = config.payload == null ? DEFAULT_BLOCKSTORE_TYPE : config.payload['blockstore.type']
useEffect(() => {
getConfig()
}, [getConfig]);

const blockstoreType = config.payload ? config.payload['blockstore.type'] : DEFAULT_BLOCKSTORE_TYPE;
const storageNamespaceExample = `e.g. ${blockstoreType}://example-bucket/`;
return (
<Form className={"mt-5"} onSubmit={(e) => {
e.preventDefault();
Expand Down Expand Up @@ -76,7 +79,7 @@ export const RepositoryCreateForm = connect(
<Form.Group as={Row}>
<Form.Label column sm={fieldNameOffset}>Storage Namespace</Form.Label>
<Col sm={sm}>
<Form.Control type="text" ref={storageNamespaceField} placeholder={`e.g. ${blockstoreType}://example-bucket/`} onChange={checkStorageNamespaceValidity}/>
<Form.Control type="text" ref={storageNamespaceField} placeholder={storageNamespaceExample} onChange={checkStorageNamespaceValidity}/>
{!storageNamespaceValid &&
<Form.Text className="text-danger">
Invalid Storage Namespace.
Expand Down