mirror of
https://github.com/outline/outline.git
synced 2026-12-04 18:34:54 +03:00
feat: Add screen to provision workspace (#9355)
* wip * refactor * lint
This commit is contained in:
1 parent
66209c4ee8
commit
82dc24040c
4 files changed
+89
-55
No files matched your search
@@ -38,6 +38,7 @@ import { BackButton } from "./components/BackButton";
|
||||
import { Background } from "./components/Background";
|
||||
import { Centered } from "./components/Centered";
|
||||
import { Notices } from "./components/Notices";
|
||||
import WorkspaceSetup from "./components/WorkspaceSetup";
|
||||
import { getRedirectUrl, navigateToSubdomain } from "./urls";
|
||||
|
||||
type Props = {
|
||||
@@ -191,12 +192,18 @@ function Login({ children, onBack }: Props) {
|
||||
);
|
||||
}
|
||||
|
||||
const firstRun =
|
||||
config.providers.length === 0 && !isCloudHosted && !config.name;
|
||||
const hasMultipleProviders = config.providers.length > 1;
|
||||
const defaultProvider = find(
|
||||
config.providers,
|
||||
(provider) => provider.id === auth.lastSignedIn && !isCreate
|
||||
);
|
||||
|
||||
if (firstRun) {
|
||||
return <WorkspaceSetup onBack={onBack} />;
|
||||
}
|
||||
|
||||
if (emailLinkSentTo) {
|
||||
return (
|
||||
<Background>
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import * as React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import styled from "styled-components";
|
||||
import { s } from "@shared/styles";
|
||||
import ButtonLarge from "~/components/ButtonLarge";
|
||||
import ChangeLanguage from "~/components/ChangeLanguage";
|
||||
import Flex from "~/components/Flex";
|
||||
import Heading from "~/components/Heading";
|
||||
import Input from "~/components/Input";
|
||||
import Text from "~/components/Text";
|
||||
import { detectLanguage } from "~/utils/language";
|
||||
import { BackButton } from "./BackButton";
|
||||
import { Background } from "./Background";
|
||||
import { Centered } from "./Centered";
|
||||
|
||||
const WorkspaceSetup = ({ onBack }: { onBack?: () => void }) => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Background>
|
||||
<BackButton onBack={onBack} />
|
||||
<ChangeLanguage locale={detectLanguage()} />
|
||||
<Centered
|
||||
as="form"
|
||||
action="/api/installation.create"
|
||||
method="POST"
|
||||
gap={12}
|
||||
>
|
||||
<StyledHeading centered>{t("Create workspace")}</StyledHeading>
|
||||
<Content>
|
||||
{t(
|
||||
"Setup your workspace by providing a name and details for admin login. You can change these later."
|
||||
)}
|
||||
</Content>
|
||||
<Flex column gap={12} style={{ width: "100%" }}>
|
||||
<Input
|
||||
name="teamName"
|
||||
type="text"
|
||||
label={t("Workspace name")}
|
||||
placeholder="Acme, Inc"
|
||||
required
|
||||
autoFocus
|
||||
flex
|
||||
/>
|
||||
<Input
|
||||
name="userName"
|
||||
type="text"
|
||||
label={t("Admin name")}
|
||||
required
|
||||
flex
|
||||
/>
|
||||
<Input
|
||||
name="userEmail"
|
||||
type="email"
|
||||
label={t("Admin email")}
|
||||
required
|
||||
flex
|
||||
/>
|
||||
</Flex>
|
||||
<ButtonLarge type="submit" fullwidth>
|
||||
{t("Continue")} →
|
||||
</ButtonLarge>
|
||||
</Centered>
|
||||
</Background>
|
||||
);
|
||||
};
|
||||
|
||||
const StyledHeading = styled(Heading)`
|
||||
margin: 0;
|
||||
`;
|
||||
|
||||
const Content = styled(Text)`
|
||||
color: ${s("textSecondary")};
|
||||
text-align: center;
|
||||
margin-top: -8px;
|
||||
`;
|
||||
|
||||
export default WorkspaceSetup;
|
||||
@@ -1,54 +0,0 @@
|
||||
import "./bootstrap";
|
||||
import { UserRole } from "@shared/types";
|
||||
import { parseEmail } from "@shared/utils/email";
|
||||
import teamCreator from "@server/commands/teamCreator";
|
||||
import env from "@server/env";
|
||||
import { Team, User } from "@server/models";
|
||||
import { sequelize } from "@server/storage/database";
|
||||
|
||||
const email = process.argv[2];
|
||||
|
||||
export default async function main(exit = false) {
|
||||
const teamCount = await Team.count();
|
||||
if (teamCount === 0) {
|
||||
const name = parseEmail(email).local;
|
||||
const user = await sequelize.transaction(async (transaction) => {
|
||||
const team = await teamCreator({
|
||||
name: "Wiki",
|
||||
subdomain: "wiki",
|
||||
authenticationProviders: [],
|
||||
transaction,
|
||||
ip: "127.0.0.1",
|
||||
});
|
||||
|
||||
return await User.create(
|
||||
{
|
||||
teamId: team.id,
|
||||
name,
|
||||
email,
|
||||
role: UserRole.Admin,
|
||||
},
|
||||
{
|
||||
transaction,
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
console.log(
|
||||
"email",
|
||||
`✅ Seed done – sign-in link: ${
|
||||
env.URL
|
||||
}/auth/email.callback?token=${user.getEmailSigninToken()}`
|
||||
);
|
||||
} else {
|
||||
console.log("Team already exists, aborting");
|
||||
}
|
||||
|
||||
if (exit) {
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== "test") {
|
||||
void main(true);
|
||||
}
|
||||
@@ -830,6 +830,11 @@
|
||||
"Sorry, an unknown error occurred.": "Sorry, an unknown error occurred.",
|
||||
"Choose a workspace": "Choose a workspace",
|
||||
"Choose an {{ appName }} workspace or login to continue connecting this app": "Choose an {{ appName }} workspace or login to continue connecting this app",
|
||||
"Create workspace": "Create workspace",
|
||||
"Setup your workspace by providing a name and details for admin login. You can change these later.": "Setup your workspace by providing a name and details for admin login. You can change these later.",
|
||||
"Workspace name": "Workspace name",
|
||||
"Admin name": "Admin name",
|
||||
"Admin email": "Admin email",
|
||||
"Login": "Login",
|
||||
"Error": "Error",
|
||||
"Failed to load configuration.": "Failed to load configuration.",
|
||||
@@ -1134,7 +1139,6 @@
|
||||
"Confirmation code": "Confirmation code",
|
||||
"Deleting the <1>{{workspaceName}}</1> workspace will destroy all collections, documents, users, and associated data. You will be immediately logged out of {{appName}}.": "Deleting the <1>{{workspaceName}}</1> workspace will destroy all collections, documents, users, and associated data. You will be immediately logged out of {{appName}}.",
|
||||
"Please note that workspaces are completely separated. They can have a different domain, settings, users, and billing.": "Please note that workspaces are completely separated. They can have a different domain, settings, users, and billing.",
|
||||
"Workspace name": "Workspace name",
|
||||
"You are creating a new workspace using your current account — <em>{{email}}</em>": "You are creating a new workspace using your current account — <em>{{email}}</em>",
|
||||
"To create a workspace under another email please sign up from the homepage": "To create a workspace under another email please sign up from the homepage",
|
||||
"Trash emptied": "Trash emptied",
|
||||
|
||||
Reference in new issue
Block a user