chore: Syncs changes that were erroneously made in enterprise repo (#1949)

This commit is contained in:
Tom Moor
2021-03-10 14:56:34 -08:00
committed by GitHub
parent d530edcc2f
commit dc967be4fc
9 changed files with 34 additions and 11 deletions

View File

@ -6,7 +6,7 @@ import HelpText from "components/HelpText";
export type Props = {| export type Props = {|
checked?: boolean, checked?: boolean,
label?: string, label?: React.Node,
labelHidden?: boolean, labelHidden?: boolean,
className?: string, className?: string,
name?: string, name?: string,
@ -26,6 +26,7 @@ const LabelText = styled.span`
const Wrapper = styled.div` const Wrapper = styled.div`
padding-bottom: 8px; padding-bottom: 8px;
${(props) => (props.small ? "font-size: 14px" : "")}; ${(props) => (props.small ? "font-size: 14px" : "")};
width: 100%;
`; `;
const Label = styled.label` const Label = styled.label`

View File

@ -42,6 +42,7 @@ const RealInput = styled.input`
const Wrapper = styled.div` const Wrapper = styled.div`
flex: ${(props) => (props.flex ? "1" : "0")}; flex: ${(props) => (props.flex ? "1" : "0")};
width: ${(props) => (props.short ? "49%" : "auto")};
max-width: ${(props) => (props.short ? "350px" : "100%")}; max-width: ${(props) => (props.short ? "350px" : "100%")};
min-height: ${({ minHeight }) => (minHeight ? `${minHeight}px` : "0")}; min-height: ${({ minHeight }) => (minHeight ? `${minHeight}px` : "0")};
max-height: ${({ maxHeight }) => (maxHeight ? `${maxHeight}px` : "initial")}; max-height: ${({ maxHeight }) => (maxHeight ? `${maxHeight}px` : "initial")};
@ -55,7 +56,6 @@ const IconWrapper = styled.span`
`; `;
export const Outline = styled(Flex)` export const Outline = styled(Flex)`
display: flex;
flex: 1; flex: 1;
margin: ${(props) => margin: ${(props) =>
props.margin !== undefined ? props.margin : "0 0 16px"}; props.margin !== undefined ? props.margin : "0 0 16px"};
@ -64,7 +64,7 @@ export const Outline = styled(Flex)`
border-style: solid; border-style: solid;
border-color: ${(props) => border-color: ${(props) =>
props.hasError props.hasError
? "red" ? props.theme.danger
: props.focused : props.focused
? props.theme.inputBorderFocused ? props.theme.inputBorderFocused
: props.theme.inputBorder}; : props.theme.inputBorder};
@ -81,7 +81,7 @@ export const LabelText = styled.div`
`; `;
export type Props = {| export type Props = {|
type?: "text" | "email" | "checkbox" | "search", type?: "text" | "email" | "checkbox" | "search" | "textarea",
value?: string, value?: string,
label?: string, label?: string,
className?: string, className?: string,
@ -97,8 +97,11 @@ export type Props = {|
autoComplete?: boolean | string, autoComplete?: boolean | string,
readOnly?: boolean, readOnly?: boolean,
required?: boolean, required?: boolean,
disabled?: boolean,
placeholder?: string, placeholder?: string,
onChange?: (ev: SyntheticInputEvent<HTMLInputElement>) => mixed, onChange?: (
ev: SyntheticInputEvent<HTMLInputElement | HTMLTextAreaElement>
) => mixed,
onFocus?: (ev: SyntheticEvent<>) => void, onFocus?: (ev: SyntheticEvent<>) => void,
onBlur?: (ev: SyntheticEvent<>) => void, onBlur?: (ev: SyntheticEvent<>) => void,
|}; |};

View File

@ -452,7 +452,9 @@ class DocumentScene extends React.Component<Props> {
</MaxWidth> </MaxWidth>
</Container> </Container>
</Background> </Background>
{isShare && !isCustomDomain() && <Branding />} {isShare && !isCustomDomain() && (
<Branding href="//www.getoutline.com" />
)}
{!isShare && <KeyboardShortcutsButton />} {!isShare && <KeyboardShortcutsButton />}
</ErrorBoundary> </ErrorBoundary>
); );

View File

@ -9,11 +9,11 @@ import env from "env";
type Props = { type Props = {
scopes?: string[], scopes?: string[],
redirectUri: string, redirectUri: string,
state: string, state?: string,
label?: string, label?: string,
}; };
function SlackButton({ state, scopes, redirectUri, label }: Props) { function SlackButton({ state = "", scopes, redirectUri, label }: Props) {
const handleClick = () => const handleClick = () =>
(window.location.href = slackAuth( (window.location.href = slackAuth(
state, state,

View File

@ -174,7 +174,7 @@ export default class AuthStore {
runInAction("AuthStore#updateUser", () => { runInAction("AuthStore#updateUser", () => {
this.addPolicies(res.policies); this.addPolicies(res.policies);
this.user = res.data; this.user = new User(res.data);
}); });
} finally { } finally {
this.isSaving = false; this.isSaving = false;

View File

@ -48,6 +48,12 @@ export default function validation() {
} }
}; };
ctx.assertValueInArray = (value, values, message) => {
if (!values.includes(value)) {
throw new ValidationError(message);
}
};
return next(); return next();
}; };
} }

View File

@ -95,6 +95,8 @@ const Document = sequelize.define(
}, },
getterMethods: { getterMethods: {
url: function () { url: function () {
if (!this.title) return `/doc/untitled-${this.urlId}`;
const slugifiedTitle = slugify(this.title); const slugifiedTitle = slugify(this.title);
return `/doc/${slugifiedTitle}-${this.urlId}`; return `/doc/${slugifiedTitle}-${this.urlId}`;
}, },

View File

@ -60,11 +60,12 @@ const User = sequelize.define(
return original; return original;
} }
const initial = this.name ? this.name[0] : "?";
const hash = crypto const hash = crypto
.createHash("md5") .createHash("md5")
.update(this.email || "") .update(this.email || "")
.digest("hex"); .digest("hex");
return `${DEFAULT_AVATAR_HOST}/avatar/${hash}/${this.name[0]}.png`; return `${DEFAULT_AVATAR_HOST}/avatar/${hash}/${initial}.png`;
}, },
}, },
} }

View File

@ -69,7 +69,15 @@ export async function getUserForEmailSigninToken(token: string): Promise<User> {
} }
} }
const user = await User.findByPk(payload.id); const user = await User.findByPk(payload.id, {
include: [
{
model: Team,
as: "team",
required: true,
},
],
});
// if user has signed in at all since the token was created then // if user has signed in at all since the token was created then
// it's no longer valid, they'll need a new one. // it's no longer valid, they'll need a new one.