Skip to content

Commit

Permalink
Merge branch 'master' of github.com:metabase/metabase into xray-async
Browse files Browse the repository at this point in the history
  • Loading branch information
sbelak committed Oct 12, 2017
2 parents e811f88 + 86ea54f commit 2bf6a37
Show file tree
Hide file tree
Showing 113 changed files with 2,542 additions and 1,241 deletions.
10 changes: 10 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
"env": {
"development": {
"presets": []
},
"extract": {
"plugins": [
["c-3po", {
"extract": {
"output": "locales/metabase-frontend.pot"
},
"discover": ["t", "jt"]
}]
]
}
}
}
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"flowtype/use-flow-type": 1
},
"globals": {
"pending": false
"pending": false,
"t": false
},
"env": {
"browser": true,
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ bin/release/aws-eb/metabase-aws-eb.zip
/build.xml
/test-report-*
/crate-*
*.po~
/locales/metabase-*.pot
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Metabase is the easy, open source way for everyone in your company to ask questi
[![NPM Dependencies Status](https://david-dm.org/metabase/metabase.svg)](https://david-dm.org/metabase/metabase)

# Features
- 5 minute [setup](http://www.metabase.com/docs/latest/setting-up-metabase) (We're not kidding)
- Let anyone on your team [ask questions](http://www.metabase.com/docs/latest/users-guide/04-asking-questions) without knowing SQL
- Rich beautiful [dashboards](http://www.metabase.com/docs/latest/users-guide/06-sharing-answers) with auto refresh and fullscreen
- 5 minute [setup](http://metabase.com/docs/latest/setting-up-metabase.html) (We're not kidding)
- Let anyone on your team [ask questions](http://metabase.com/docs/latest/users-guide/04-asking-questions.html) without knowing SQL
- Rich beautiful [dashboards](http://metabase.com/docs/latest/users-guide/06-sharing-answers.html) with auto refresh and fullscreen
- SQL Mode for analysts and data pros
- Create canonical [segments and metrics](http://www.metabase.com/docs/latest/administration-guide/07-segments-and-metrics) for your team to use
- Send data to Slack or email on a schedule with [Pulses](http://www.metabase.com/docs/latest/users-guide/10-pulses)
- View data in Slack anytime with [MetaBot](http://www.metabase.com/docs/latest/users-guide/11-metabot)
- [Humanize data](http://www.metabase.com/docs/latest/administration-guide/03-metadata-editing) for your team by renaming, annotating and hiding fields
- Create canonical [segments and metrics](http://metabase.com/docs/latest/administration-guide/07-segments-and-metrics.html) for your team to use
- Send data to Slack or email on a schedule with [Pulses](http://metabase.com/docs/latest/users-guide/10-pulses.html)
- View data in Slack anytime with [MetaBot](http://metabase.com/docs/latest/users-guide/11-metabot.html)
- [Humanize data](http://metabase.com/docs/latest/administration-guide/03-metadata-editing.html) for your team by renaming, annotating and hiding fields

For more information check out [metabase.com](http://www.metabase.com)

Expand Down
36 changes: 36 additions & 0 deletions bin/i18n/build-translation-frontend-resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env node

// This program compiles a ".po" translations file to a JSON version suitable for use on the frontend
// It removes strings that aren't used on the frontend, and other extraneous information like comments

const fs = require("fs");
const _ = require("underscore");
const gParser = require("gettext-parser");

if (process.argv.length !== 4) {
console.log("USAGE: build-translation-frontend-resource input.po output.json");
process.exit(1);
}

const inputFile = process.argv[2];
const outputFile = process.argv[3];

const translationObject = gParser.po.parse(fs.readFileSync(inputFile, "utf-8"));

// NOTE: unsure why the headers are duplicated in a translation for "", but we don't need it
delete translationObject.translations[""][""]

for (const id in translationObject.translations[""]) {
const translation = translationObject.translations[""][id];
if (!translation.comments.reference || _.any(translation.comments.reference.split("\n"), reference => reference.startsWith("frontend/"))) {
// remove comments:
delete translation.comments;
// NOTE: would be nice if we could remove the message id since it's redundant:
// delete translation.msgid;
} else {
// remove strings that aren't in the frontend
delete translationObject.translations[""][id];
}
}

fs.writeFileSync(outputFile, JSON.stringify(translationObject, null, 2), "utf-8");
43 changes: 43 additions & 0 deletions bin/i18n/build-translation-resources
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh

set -eu

# gettext installed via homebrew is "keg-only", add it to the PATH
if [ -d "/usr/local/opt/gettext/bin" ]; then
export PATH="/usr/local/opt/gettext/bin:$PATH"
fi

POT_NAME="locales/metabase.pot"
LOCALES=$(find locales -type f -name "*.po" -exec basename {} .po \;)
LOCALES_QUOTED=$(echo "$LOCALES" | awk '{ printf "\"%s\" ", $0 }')

FRONTEND_LANG_DIR="resources/frontend_client/app/locales"

# backend
# NOTE: include "en" even though we don't have a .po file for it because it's the default?
cat << EOF > "resources/locales.clj"
{
:locales #{"en" $LOCALES_QUOTED}
:packages ["metabase"]
:bundle "metabase.Messages"
}
EOF

mkdir -p "$FRONTEND_LANG_DIR"

for LOCALE in $LOCALES; do
LOCALE_FILE="locales/$LOCALE.po"
# frontend
# NOTE: just copy these for now, but eventially precompile from .po to .json
./bin/i18n/build-translation-frontend-resource \
"$LOCALE_FILE" \
"$FRONTEND_LANG_DIR/$LOCALE.json"

# backend
msgfmt \
--java2 \
-d "resources" \
-r "metabase.Messages" \
-l "$LOCALE" \
"$LOCALE_FILE"
done
22 changes: 22 additions & 0 deletions bin/i18n/update-translation
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

set -eu

# gettext installed via homebrew is "keg-only", add it to the PATH
if [ -d "/usr/local/opt/gettext/bin" ]; then
export PATH="/usr/local/opt/gettext/bin:$PATH"
fi

POT_NAME="locales/metabase.pot"
PO_NAME="locales/$1.po"

if [ $# -lt 1 ]; then
echo "USAGE: update-translation en_US"
exit 1
fi

if [ -f "$PO_NAME" ]; then
exec msgmerge -U "$PO_NAME" "$POT_NAME"
else
exec msginit -i "$POT_NAME" -o "$PO_NAME" -l "$1"
fi
54 changes: 54 additions & 0 deletions bin/i18n/update-translation-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/sh

set -eu

# gettext installed via homebrew is "keg-only", add it to the PATH
if [ -d "/usr/local/opt/gettext/bin" ]; then
export PATH="/usr/local/opt/gettext/bin:$PATH"
fi

# check xgettext is installed
if ! command -v xgettext > /dev/null; then
echo 'Please install the "xgettext" command (e.x. `brew install gettext`)'
exit 1
fi

POT_NAME="locales/metabase.pot"
POT_BACKEND_NAME="locales/metabase-backend.pot"
POT_FRONTEND_NAME="locales/metabase-frontend.pot"

mkdir -p "locales"

# update frontend pot

# NOTE: about twice as fast to call babel directly rather than a full webpack build
BABEL_ENV=extract ./node_modules/.bin/babel -q -x .js,.jsx -o /dev/null frontend/src
# BABEL_ENV=extract BABEL_DISABLE_CACHE=1 yarn run build

# update backend pot

# xgettext before 0.19 does not understand --add-location=file. Even CentOS
# 7 ships with an older gettext. We will therefore generate full location
# info on those systems, and only file names where xgettext supports it
LOC_OPT=$(xgettext --add-location=file -f - </dev/null >/dev/null 2>&1 && echo --add-location=file || echo --add-location)

find src -name "*.clj" | xgettext \
--from-code=UTF-8 \
--language=lisp \
--copyright-holder='Metabase <[email protected]>' \
--package-name="metabase" \
--msgid-bugs-address="[email protected]" \
-k \
-kmark:1 -ki18n/mark:1 \
-ktrs:1 -ki18n/trs:1 \
-ktru:1 -ki18n/tru:1 \
-ktrun:1,2 -ki18n/trun:1,2 \
-ktrsn:1,2 -ki18n/trsn:1,2 \
$LOC_OPT \
--add-comments --sort-by-file \
-o $POT_BACKEND_NAME -f -

sed -i "" -e 's/charset=CHARSET/charset=UTF-8/' "$POT_BACKEND_NAME"

# merge frontend and backend pots
msgcat "$POT_FRONTEND_NAME" "$POT_BACKEND_NAME" > "$POT_NAME"
7 changes: 7 additions & 0 deletions bin/i18n/update-translations
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

set -eu

./bin/i18n/update-translation-template

find locales -name "*.po" -exec sh -c './bin/i18n/update-translation $(basename {} .po)' \;
18 changes: 8 additions & 10 deletions docs/developers-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ For significant feature additions, it is expected that discussion will have take

We don't like getting sued, so before merging any pull request, we'll need each person contributing code to sign a Contributor License Agreement [here](https://docs.google.com/a/metabase.com/forms/d/1oV38o7b9ONFSwuzwmERRMi9SYrhYeOrkbmNaq9pOJ_E/viewform)

# Development on Windows

The development scripts are designed for Linux/Mac environment, so we recommend using the latest Windows 10 version with [WSL (Windows Subsystem for Linux)](https://msdn.microsoft.com/en-us/commandline/wsl/about) and [Ubuntu on Windows](https://www.microsoft.com/store/p/ubuntu/9nblggh4msv6). The Ubuntu Bash shell works well for both backend and frontend development.

If you have problems with your development environment, make sure that you are not using any development commands outside the Bash shell. As an example, Node dependencies installed in normal Windows environment will not work inside Ubuntu Bash environment.

# Install Prerequisites

Expand All @@ -24,6 +29,7 @@ These are the set of tools which are required in order to complete any build of
3. [Yarn package manager for Node.js](https://yarnpkg.com/)
3. [Leiningen (http://leiningen.org/)](http://leiningen.org/)

If you are developing on Windows, make sure to use Ubuntu on Windows and follow instructions for Ubuntu/Linux instead of installing ordinary Windows versions.

# Build Metabase

Expand Down Expand Up @@ -70,13 +76,6 @@ Start the frontend build process with

yarn run build-hot

Caveat - Yarn does not properly support `build-hot` on Windows 8/10. You will need to manually build the frontend client with

yarn run build

This will get you a full development server running on port :3000 by default.


## Frontend development
We use these technologies for our FE build process to allow us to use modules, es6 syntax, and css variables.

Expand Down Expand Up @@ -132,7 +131,7 @@ The way integration tests are written is a little unconventional so here is an e

```
import {
login,
useSharedAdminLogin,
createTestStore,
} from "__support__/integrated_tests";
import {
Expand All @@ -149,8 +148,7 @@ describe("Query builder", () => {
beforeAll(async () => {
// Usually you want to test stuff where user is already logged in
// so it is convenient to login before any test case.
// Remember `await` here!
await login()
useSharedAdminLogin()
})
it("should let you run a new query", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React from "react";

import Select from "metabase/components/Select.jsx";
import _ from "underscore";

const SettingSelect = ({ setting, updateSetting, disabled }) =>
<Select
className="full-width"
placeholder={setting.placeholder}
value={setting.value}
value={_.findWhere(setting.options, { value: setting.value }) || setting.value}
options={setting.options}
onChange={updateSetting}
optionNameFn={option => typeof option === "object" ? option.name : option }
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/metabase/admin/settings/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ const SECTIONS = [
note: "Not all databases support timezones, in which case this setting won't take effect.",
allowValueCollection: true
},
{
key: "site-locale",
display_name: "Language",
type: "select",
options: (MetabaseSettings.get("available_locales") || []).map(([value, name]) => ({ name, value })),
placeholder: "Select a language",
getHidden: () => MetabaseSettings.get("available_locales").length < 2
},
{
key: "anon-tracking-enabled",
display_name: "Anonymous Tracking",
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/metabase/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
import 'babel-polyfill';
import 'number-to-locale-string';

// make the i18n function "t" global so we don't have to import it in basically every file
import { t, jt } from "c-3po";
global.t = t;
global.jt = jt;

// set the locale before loading anything else
import { setLocalization } from "metabase/lib/i18n";
if (window.MetabaseLocalization) {
setLocalization(window.MetabaseLocalization)
}

import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
Expand Down
29 changes: 0 additions & 29 deletions frontend/src/metabase/components/AddButton.jsx

This file was deleted.

Loading

0 comments on commit 2bf6a37

Please sign in to comment.