Changing language single source of truth from TEAM to USER

This commit is contained in:
André Glatzl committed 2020-11-13 12:18:08 +01:00
1 parent aa7dedb114
commit adb7ab482f
25 files changed
+85 -150

No files matched your search

-1
View File
@@ -5,7 +5,6 @@ import BaseModel from "./BaseModel";
class Team extends BaseModel {
id: string;
name: string;
language: string;
avatarUrl: string;
slackConnected: boolean;
googleConnected: boolean;
+1
View File
@@ -10,6 +10,7 @@ class User extends BaseModel {
lastActiveAt: string;
isSuspended: boolean;
createdAt: string;
language: string;
}
export default User;
-18
View File
@@ -11,7 +11,6 @@ import CenteredContent from "components/CenteredContent";
import Flex from "components/Flex";
import HelpText from "components/HelpText";
import Input, { LabelText } from "components/Input";
import InputSelect from "components/InputSelect";
import PageTitle from "components/PageTitle";
import ImageUpload from "./components/ImageUpload";
import env from "env";
@@ -27,7 +26,6 @@ class Details extends React.Component<Props> {
form: ?HTMLFormElement;
@observable name: string;
@observable language: string;
@observable subdomain: ?string;
@observable avatarUrl: ?string;
@@ -35,7 +33,6 @@ class Details extends React.Component<Props> {
const { team } = this.props.auth;
if (team) {
this.name = team.name;
this.language = team.language;
this.subdomain = team.subdomain;
}
}
@@ -52,7 +49,6 @@ class Details extends React.Component<Props> {
try {
await this.props.auth.updateTeam({
name: this.name,
language: this.language,
avatarUrl: this.avatarUrl,
subdomain: this.subdomain,
});
@@ -66,10 +62,6 @@ class Details extends React.Component<Props> {
this.name = ev.target.value;
};
handleLanguageChange = (ev: SyntheticInputEvent<*>) => {
this.language = ev.target.value;
};
handleSubdomainChange = (ev: SyntheticInputEvent<*>) => {
this.subdomain = ev.target.value.toLowerCase();
};
@@ -127,16 +119,6 @@ class Details extends React.Component<Props> {
required
short
/>
<InputSelect
label="Language"
options={[
{ label: "English (US)", value: "en_US" },
{ label: "German (Germany)", value: "de_DE" },
]}
value={this.language}
onChange={this.handleLanguageChange}
short
/>
{env.SUBDOMAINS_ENABLED && (
<>
<Input
+36 -13
View File
@@ -4,6 +4,7 @@ import { observer, inject } from "mobx-react";
import * as React from "react";
import styled from "styled-components";
import { t } from "shared/translations/i18n";
import AuthStore from "stores/AuthStore";
import UiStore from "stores/UiStore";
import UserDelete from "scenes/UserDelete";
@@ -11,6 +12,7 @@ import Button from "components/Button";
import CenteredContent from "components/CenteredContent";
import Flex from "components/Flex";
import Input, { LabelText } from "components/Input";
import InputSelect from "components/InputSelect";
import PageTitle from "components/PageTitle";
import ImageUpload from "./components/ImageUpload";
@@ -27,10 +29,12 @@ class Profile extends React.Component<Props> {
@observable name: string;
@observable avatarUrl: ?string;
@observable showDeleteModal: boolean = false;
@observable language: string;
componentDidMount() {
if (this.props.auth.user) {
this.name = this.props.auth.user.name;
this.language = this.props.auth.user.language;
}
}
@@ -44,8 +48,12 @@ class Profile extends React.Component<Props> {
await this.props.auth.updateUser({
name: this.name,
avatarUrl: this.avatarUrl,
language: this.language,
});
this.props.ui.showToast("Profile saved");
this.props.ui.showToast(t("Profile saved"));
setTimeout(function () {
window.location.reload();
}, 1000);
};
handleNameChange = (ev: SyntheticInputEvent<*>) => {
@@ -58,11 +66,15 @@ class Profile extends React.Component<Props> {
await this.props.auth.updateUser({
avatarUrl: this.avatarUrl,
});
this.props.ui.showToast("Profile picture updated");
this.props.ui.showToast(t("Profile picture updated"));
};
handleAvatarError = (error: ?string) => {
this.props.ui.showToast(error || "Unable to upload new avatar");
this.props.ui.showToast(error || t("Unable to upload new avatar"));
};
handleLanguageChange = (ev: SyntheticInputEvent<*>) => {
this.language = ev.target.value;
};
toggleDeleteAccount = () => {
@@ -80,10 +92,10 @@ class Profile extends React.Component<Props> {
return (
<CenteredContent>
<PageTitle title="Profile" />
<h1>Profile</h1>
<PageTitle title={t("Profile")} />
<h1>{t("Profile")}</h1>
<ProfilePicture column>
<LabelText>Photo</LabelText>
<LabelText>{t("Photo")}</LabelText>
<AvatarContainer>
<ImageUpload
onSuccess={this.handleAvatarUpload}
@@ -91,31 +103,42 @@ class Profile extends React.Component<Props> {
>
<Avatar src={avatarUrl} />
<Flex auto align="center" justify="center">
Upload
{t("Upload")}
</Flex>
</ImageUpload>
</AvatarContainer>
</ProfilePicture>
<form onSubmit={this.handleSubmit} ref={(ref) => (this.form = ref)}>
<Input
label="Full name"
label={t("Full name")}
autoComplete="name"
value={this.name}
onChange={this.handleNameChange}
required
short
/>
<InputSelect
label={t("Language")}
options={[
{ label: "English (US)", value: "en_US" },
{ label: "Deutsch (Deutschland)", value: "de_DE" },
]}
value={this.language}
onChange={this.handleLanguageChange}
short
/>
<Button type="submit" disabled={isSaving || !this.isValid}>
{isSaving ? "Saving…" : "Save"}
{isSaving ? t("Saving…") : t("Save")}
</Button>
</form>
<DangerZone>
<LabelText>Delete Account</LabelText>
<LabelText>{t("Delete Account")}</LabelText>
<p>
You may delete your account at any time, note that this is
unrecoverable.{" "}
<a onClick={this.toggleDeleteAccount}>Delete account</a>.
{t(
"You may delete your account at any time, note that this is unrecoverable"
)}
. <a onClick={this.toggleDeleteAccount}>{t("Delete account")}</a>.
</p>
</DangerZone>
{this.showDeleteModal && (
+1 -1
View File
@@ -126,7 +126,7 @@ export default class AuthStore {
this.user = new User(user);
this.team = new Team(team);
i18n.changeLanguage(this.team.language);
i18n.changeLanguage(this.user.language);
if (window.Sentry) {
window.Sentry.configureScope(function (scope) {
+1 -1
View File
@@ -17,7 +17,7 @@ module.exports = {
keepRemoved: false,
// Keep keys from the catalog that are no longer in code
keySeparator: '$',
keySeparator: false,
// Key separator used in your translation keys
// If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance.
+1 -1
View File
@@ -185,8 +185,8 @@
"eslint-plugin-react-hooks": "^4.1.0",
"fetch-test-server": "^1.1.0",
"flow-bin": "^0.104.0",
"i18next-parser": "^3.3.0",
"html-webpack-plugin": "3.2.0",
"i18next-parser": "^3.3.0",
"jest-cli": "^26.0.0",
"koa-webpack-dev-middleware": "^1.4.5",
"koa-webpack-hot-middleware": "^1.0.3",
-2
View File
@@ -12,7 +12,6 @@ const router = new Router();
router.post("team.update", auth(), async (ctx) => {
const {
name,
language,
avatarUrl,
subdomain,
sharing,
@@ -28,7 +27,6 @@ router.post("team.update", auth(), async (ctx) => {
}
if (name) team.name = name;
if (language) team.language = language;
if (sharing !== undefined) team.sharing = sharing;
if (documentEmbeds !== undefined) team.documentEmbeds = documentEmbeds;
if (guestSignin !== undefined) team.guestSignin = guestSignin;
+2 -1
View File
@@ -62,10 +62,11 @@ router.post("users.info", auth(), async (ctx) => {
router.post("users.update", auth(), async (ctx) => {
const { user } = ctx.state;
const { name, avatarUrl } = ctx.body;
const { name, avatarUrl, language } = ctx.body;
if (name) user.name = name;
if (avatarUrl) user.avatarUrl = avatarUrl;
if (language) user.language = language;
await user.save();
+2 -2
View File
@@ -2,13 +2,13 @@
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn('teams', 'language', {
await queryInterface.addColumn('users', 'language', {
type: Sequelize.STRING,
defaultValue: process.env.DEFAULT_LANGUAGE,
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn('teams', 'language');
await queryInterface.removeColumn('users', 'language');
}
};
+7 -14
View File
@@ -4,7 +4,6 @@ import path from "path";
import { URL } from "url";
import util from "util";
import uuid from "uuid";
import { t } from "../../shared/translations/i18n";
import {
stripSubdomain,
RESERVED_SUBDOMAINS,
@@ -28,10 +27,6 @@ const Team = sequelize.define(
primaryKey: true,
},
name: DataTypes.STRING,
language: {
type: DataTypes.STRING,
defaultValue: process.env.DEFAULT_LANGUAGE,
},
subdomain: {
type: DataTypes.STRING,
allowNull: true,
@@ -144,10 +139,9 @@ Team.prototype.provisionSubdomain = async function (subdomain) {
Team.prototype.provisionFirstCollection = async function (userId) {
const collection = await Collection.create({
name: t("Welcome"),
description: t(
"This collection is a quick guide to what Outline is all about. Feel free to delete this collection once your team is up to speed with the basics!"
),
name: "Welcome",
description:
"This collection is a quick guide to what Outline is all about. Feel free to delete this collection once your team is up to speed with the basics!",
type: "atlas",
teamId: this.id,
creatorId: userId,
@@ -156,10 +150,10 @@ Team.prototype.provisionFirstCollection = async function (userId) {
// For the first collection we go ahead and create some intitial documents to get
// the team started. You can edit these in /server/onboarding/x.md
const onboardingDocs = [
t("Support"),
t("Integrations & API"),
t("Our Editor"),
t("What is Outline"),
"Support",
"Integrations & API",
"Our Editor",
"What is Outline",
];
for (const title of onboardingDocs) {
const text = await readFile(
@@ -170,7 +164,6 @@ Team.prototype.provisionFirstCollection = async function (userId) {
"..",
"server",
"onboarding",
process.env.DEFAULT_LANGUAGE,
`${title}.md`
),
"utf8"
+4
View File
@@ -36,6 +36,10 @@ const User = sequelize.define(
lastSigninEmailSentAt: DataTypes.DATE,
suspendedAt: DataTypes.DATE,
suspendedById: DataTypes.UUID,
language: {
type: DataTypes.STRING,
defaultValue: process.env.DEFAULT_LANGUAGE,
},
},
{
paranoid: true,
File renamed without changes.
File renamed without changes.
@@ -1,29 +0,0 @@
## Integrations
Outline supports many of the most popular tools on the market without any additional settings or configuration. Just paste links to a YouTube video, Figma file, or Google Spreadsheet to get instant live-embeds in your documents. Take a look at the [integrations directory](https://www.getoutline.com/integrations) for a list of all of the tools that are supported.
Our integration code is also [open-source](https://github.com/outline/outline) and we encourage third party developers and the community to build support for additional tools!
:::info
Most integrations work by simply pasting a link from a supported service into a document.
:::
## Slack
If your team is using Slack to communicate then you’ll definitely want to enable our [Slack Integration](/settings/integrations/slack) to get instant link unfurling for Outline documents and access to the `/outline` slash command to search your knowledge base directly from Slack.
## API
Have some technical skills? Outline is built on a fully featured RPC-style [API](https://www.getoutline.com/developers). Create (or even append to) documents, collections, provision users, and more programmatically. All documents are edited and stored in markdown format – try out this example CURL request to get started:
```bash
curl -XPOST -H "Content-type: application/json" -d '{
"title": "My first document",
"text": "Hello from the API 👋",
"collectionId": "COLLECTION_ID", // find the collection id in the URL bar
"token": "API_TOKEN", // get an API token from https://www.getoutline.com/settings/tokens
"publish": true
}' 'https://www.getoutline.com/api/documents.create'
```
-24
View File
@@ -1,24 +0,0 @@
Das Herzstück von Outline ist der Dokumenteditor. Wir lassen Sie nach Belieben schreiben - sei es Markdown, WYSIWYG oder die vielen Tastenkombinationen.
## Abschrift
Wenn Sie mit dem Schreiben von Markdowns vertraut sind, werden alle gewohnten Verknüpfungen unterstützt. Geben Sie beispielsweise \ * \ * fett \ * \ * ein, um sofort fett gedruckten Text zu erstellen. Wenn Sie eine Syntax vergessen haben oder nach einer kurzen Auffrischung auf das Tastatursymbol in der unteren rechten Ecke klicken, um unsere Anleitung zu erhalten. Wenn Sie einige der wichtigsten Markdown-Verknüpfungen kennenlernen, wird die Verwendung von Outline schneller und angenehmer!
! [Die Formatierungssymbolleiste] (/ images / Screenshots / formatating-toolbar.png)
:::die Info
Sie können Markdown oder HTML auch von einer anderen Stelle direkt in ein Dokument einfügen.
:::
## Reichhaltige Dokumente
Der Editor unterstützt eine Vielzahl von Inhaltsblöcken, darunter Bilder, Tabellen, Listen, Zitate, Videos und mehr. Geben Sie "/" in eine leere Zeile ein oder klicken Sie auf das Symbol "+", um das Menü zum Einfügen von Blöcken auszulösen. Sie können weiter tippen, um es herauszufiltern.
Sie können Bilder auch ziehen und ablegen, um sie in Ihr Dokument aufzunehmen, oder einen Link einfügen, um Inhalte aus einer der vielen unterstützten [Integrationen] einzubetten (https://www.getoutline.com/integrations).
! [Das Blockmenü] (/ images / reviewshots / block-menu.png)
## Verweise
Durch das Verknüpfen mit einem anderen Dokument werden automatisch Backlinks erstellt, die auf dem neuesten Stand gehalten und am unteren Rand des Dokuments angezeigt werden. Sie können also eine Bibliothek mit verknüpften Informationen erstellen und die Frage "Welche anderen Dokumente verlinken hier?" Einfach beantworten.
@@ -1,17 +0,0 @@
Outline is a place to build your team knowledge base, you could think of it like your team’s shared library – a place for important documentation, notes, and ideas to live and be discovered. Some things you might want to keep in Outline:
- Documentation
- Sales playbooks
- Support scripts
- Onboarding
- HR documents
- Meeting notes
- …and more
## Structure
Outline allows you to organize documents in "collections", for example these could represent topics like Sales, Product, or HR. Within collections documents can be interlinked and deeply nested to easily build relationships within your knowledge base.
## Search
Outline is built from the ground up to be really fast, and that includes [search](/search). You can start searching from anywhere with the `CMD+K` shortcut – then filter by time, author, and more to find the information you need. Or you can search from within Slack with the `/outline` slash command.
-9
View File
@@ -1,9 +0,0 @@
We hate bugs as much as you and do everything possible to keep the application bug-free and performant. If you see any problems with Outline please get in touch with the team – you can email [hello@getoutline.com](mailto:hello@getoutline.com) directly and we’ll get back to you (hopefully with a fix!) as soon as possible.
## GitHub
If you have a GitHub account then you can also submit bugs directly to the development team on our public [issue tracker](https://github.com/outline/outline/issues).
## Ideas
We’d love to hear your ideas about how Outline can be improved and features you would like to see built. The best place to let the team know is through [GitHub discussions](https://github.com/outline/outline/discussions).
-1
View File
@@ -5,7 +5,6 @@ export default function present(team: Team) {
return {
id: team.id,
name: team.name,
language: team.language,
avatarUrl: team.logoUrl,
slackConnected: !!team.slackId,
googleConnected: !!team.googleId,
+2
View File
@@ -12,6 +12,7 @@ type UserPresentation = {
email?: string,
isAdmin: boolean,
isSuspended: boolean,
language: string,
};
export default (user: User, options: Options = {}): ?UserPresentation => {
@@ -23,6 +24,7 @@ export default (user: User, options: Options = {}): ?UserPresentation => {
userData.isAdmin = user.isAdmin;
userData.isSuspended = user.isSuspended;
userData.avatarUrl = user.avatarUrl;
userData.language = user.language;
if (options.includeDetails) {
userData.email = user.email;
+14 -10
View File
@@ -3,13 +3,17 @@
"Recently updated": "Zuletzt geändert",
"Recently viewed": "Zuletzt gesehen",
"Created by me": "Von mir erstellt",
"Welcome": "Willkommen",
"This collection is a quick guide to what Outline is all about. Feel free to delete this collection once your team is up to speed with the basics!": "Diese Sammlung ist eine Kurzanleitung für Outline. Fühlen Sie sich frei, diese Sammlung zu löschen, sobald Ihr Team mit den Grundlagen vertraut ist!",
"Support": "Support",
"Integrations & API": "Integrationen & API",
"Our Editor": "Unser Editor",
"What is Outline": "Was ist Outline",
"Our team’s knowledge base": "Die Wissensbasis unseres Teams",
"Team wiki, documentation, meeting notes, playbooks, onboarding, work logs, brainstorming, & more…": "Team-Wiki, Dokumentation, Besprechungsnotizen, Spielbücher, Onboarding, Arbeitsprotokolle, Brainstorming und mehr…"
}
"Profile saved": "Profil gespeichert",
"Profile picture updated": "Profilfoto wurde aktualisiert.",
"Unable to upload new avatar": "Neuer Avatar kann nicht hochgeladen werden.",
"Profile": "Profil",
"Photo": "Foto",
"Upload": "Hochladen",
"Full name": "Vorname",
"Language": "Sprache",
"Saving…": "Am speichern…",
"Save": "Speichern",
"Delete Account": "Konto löschen",
"You may delete your account at any time, note that this is unrecoverable": "Sie können Ihr Konto jederzeit löschen. Beachten Sie, dass dies nicht wiederherstellbar ist",
"Delete account": "Konto löschen"
}
+13 -6
View File
@@ -3,10 +3,17 @@
"Recently updated": "Recently updated",
"Recently viewed": "Recently viewed",
"Created by me": "Created by me",
"Welcome": "Welcome",
"This collection is a quick guide to what Outline is all about. Feel free to delete this collection once your team is up to speed with the basics!": "This collection is a quick guide to what Outline is all about. Feel free to delete this collection once your team is up to speed with the basics!",
"Support": "Support",
"Integrations & API": "Integrations & API",
"Our Editor": "Our Editor",
"What is Outline": "What is Outline"
"Profile saved": "Profile saved",
"Profile picture updated": "Profile picture updated",
"Unable to upload new avatar": "Unable to upload new avatar",
"Profile": "Profile",
"Photo": "Photo",
"Upload": "Upload",
"Full name": "Full name",
"Language": "Language",
"Saving…": "Saving…",
"Save": "Save",
"Delete Account": "Delete Account",
"You may delete your account at any time, note that this is unrecoverable": "You may delete your account at any time, note that this is unrecoverable",
"Delete account": "Delete account"
}
+1
View File
@@ -13,6 +13,7 @@ i18n.use(initReactI18next).init({
useSuspense: false,
},
lng: process.env.DEFAULT_LANGUAGE,
debug: process.env.NODE_ENV !== "production",
resources: {
en_US: {
translation: en_US,