Skip to content

Commit

Permalink
Merge branch 'main' of github.com:outline/outline into feat/replace-w…
Browse files Browse the repository at this point in the history
…ebpack-with-vite
  • Loading branch information
tommoor committed Feb 15, 2023
2 parents e9dd7d5 + 490d05b commit b73cc76
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 43 deletions.
4 changes: 1 addition & 3 deletions app/hooks/useKeyDown.ts
Expand Up @@ -28,9 +28,7 @@ const createKeyPredicate = (keyFilter: KeyFilter) =>
typeof keyFilter === "function"
? keyFilter
: typeof keyFilter === "string"
? (event: KeyboardEvent) =>
event.key === keyFilter ||
event.code === `Key${keyFilter.toUpperCase()}`
? (event: KeyboardEvent) => event.key === keyFilter
: keyFilter
? (_event: KeyboardEvent) => true
: (_event: KeyboardEvent) => false;
Expand Down
16 changes: 10 additions & 6 deletions app/utils/Analytics.ts
Expand Up @@ -14,13 +14,17 @@ export default class Analytics {
metadata?: Record<string, string>
) => {
// GA3
ga?.("send", "event", event, action);
if (window.ga) {
window.ga("send", "event", event, action);
}

// GA4
window.dataLayer?.push({
event,
action,
...metadata,
});
if (window.dataLayer) {
window.dataLayer.push({
event,
action,
...metadata,
});
}
};
}
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -101,7 +101,7 @@
"focus-visible": "^5.2.0",
"fractional-index": "^1.0.0",
"framer-motion": "^4.1.17",
"fs-extra": "^4.0.2",
"fs-extra": "^11.1.0",
"fuzzy-search": "^3.2.1",
"gemoji": "6.x",
"glob": "^8.1.0",
Expand Down Expand Up @@ -183,7 +183,7 @@
"react-dropzone": "^11.3.2",
"react-helmet": "^6.1.0",
"react-hook-form": "^7.41.5",
"react-i18next": "^12.1.1",
"react-i18next": "^12.1.5",
"react-merge-refs": "^2.0.1",
"react-portal": "^4.2.0",
"react-router-dom": "^5.2.0",
Expand Down Expand Up @@ -244,7 +244,7 @@
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/express-useragent": "^1.0.2",
"@types/formidable": "^2.0.5",
"@types/fs-extra": "^9.0.13",
"@types/fs-extra": "^11.0.1",
"@types/fuzzy-search": "^2.1.2",
"@types/glob": "^8.0.1",
"@types/google.analytics": "^0.0.42",
Expand Down
4 changes: 2 additions & 2 deletions server/routes/api/apiKeys/apiKeys.ts
Expand Up @@ -15,7 +15,7 @@ router.post(
auth({ member: true }),
validate(T.APIKeysCreateSchema),
async (ctx: APIContext<T.APIKeysCreateReq>) => {
const { name } = ctx.request.body;
const { name } = ctx.input.body;
const { user } = ctx.state.auth;

authorize(user, "createApiKey", user.team);
Expand Down Expand Up @@ -68,7 +68,7 @@ router.post(
auth({ member: true }),
validate(T.APIKeysDeleteSchema),
async (ctx: APIContext<T.APIKeysDeleteReq>) => {
const { id } = ctx.request.body;
const { id } = ctx.input.body;
const { user } = ctx.state.auth;

const key = await ApiKey.findByPk(id);
Expand Down
@@ -1,26 +1,27 @@
import Router from "koa-router";
import { sequelize } from "@server/database/sequelize";
import auth from "@server/middlewares/authentication";
import validate from "@server/middlewares/validate";
import { AuthenticationProvider, Event } from "@server/models";
import { authorize } from "@server/policies";
import {
presentAuthenticationProvider,
presentPolicies,
} from "@server/presenters";
import { APIContext } from "@server/types";
import { assertUuid, assertPresent } from "@server/validation";
import allAuthenticationProviders from "../auth/providers";
import allAuthenticationProviders from "../../auth/providers";
import * as T from "./schema";

const router = new Router();

router.post(
"authenticationProviders.info",
auth({ admin: true }),
async (ctx: APIContext) => {
const { id } = ctx.request.body;
assertUuid(id, "id is required");

validate(T.AuthenticationProvidersInfoSchema),
async (ctx: APIContext<T.AuthenticationProvidersInfoReq>) => {
const { id } = ctx.input.body;
const { user } = ctx.state.auth;

const authenticationProvider = await AuthenticationProvider.findByPk(id);
authorize(user, "read", authenticationProvider);

Expand All @@ -34,10 +35,9 @@ router.post(
router.post(
"authenticationProviders.update",
auth({ admin: true }),
async (ctx: APIContext) => {
const { id, isEnabled } = ctx.request.body;
assertUuid(id, "id is required");
assertPresent(isEnabled, "isEnabled is required");
validate(T.AuthenticationProvidersUpdateSchema),
async (ctx: APIContext<T.AuthenticationProvidersUpdateReq>) => {
const { id, isEnabled } = ctx.input.body;
const { user } = ctx.state.auth;

const authenticationProvider = await sequelize.transaction(
Expand Down
1 change: 1 addition & 0 deletions server/routes/api/authenticationProviders/index.ts
@@ -0,0 +1 @@
export { default } from "./authenticationProviders";
27 changes: 27 additions & 0 deletions server/routes/api/authenticationProviders/schema.ts
@@ -0,0 +1,27 @@
import { z } from "zod";
import BaseSchema from "@server/routes/api/BaseSchema";

export const AuthenticationProvidersInfoSchema = BaseSchema.extend({
body: z.object({
/** Authentication Provider Id */
id: z.string().uuid(),
}),
});

export type AuthenticationProvidersInfoReq = z.infer<
typeof AuthenticationProvidersInfoSchema
>;

export const AuthenticationProvidersUpdateSchema = BaseSchema.extend({
body: z.object({
/** Authentication Provider Id */
id: z.string().uuid(),

/** Whether the Authentication Provider is enabled or not */
isEnabled: z.boolean(),
}),
});

export type AuthenticationProvidersUpdateReq = z.infer<
typeof AuthenticationProvidersUpdateSchema
>;
37 changes: 18 additions & 19 deletions yarn.lock
Expand Up @@ -1058,7 +1058,7 @@
core-js-pure "^3.0.0"
regenerator-runtime "^0.13.4"

"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.5", "@babel/runtime@^7.13.10", "@babel/runtime@^7.14.5", "@babel/runtime@^7.15.4", "@babel/runtime@^7.17.8", "@babel/runtime@^7.20.6", "@babel/runtime@^7.6.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2":
"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.1", "@babel/runtime@^7.12.5", "@babel/runtime@^7.13.10", "@babel/runtime@^7.15.4", "@babel/runtime@^7.17.8", "@babel/runtime@^7.20.6", "@babel/runtime@^7.6.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2":
version "7.20.7"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.20.7.tgz#fcb41a5a70550e04a7b708037c7c32f7f356d8fd"
integrity sha512-UF0tvkUtxwAgZ5W/KrkHf0Rn0fdnLDU9ScxBrEVNUprE/MzirjK4MJUX1/BVDv00Sv8cljtukVK1aky++X1SjQ==
Expand Down Expand Up @@ -2731,11 +2731,12 @@
dependencies:
"@types/node" "*"

"@types/fs-extra@^9.0.13":
version "9.0.13"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-9.0.13.tgz#7594fbae04fe7f1918ce8b3d213f74ff44ac1f45"
integrity sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==
"@types/fs-extra@^11.0.1":
version "11.0.1"
resolved "https://registry.yarnpkg.com/@types/fs-extra/-/fs-extra-11.0.1.tgz#f542ec47810532a8a252127e6e105f487e0a6ea5"
integrity sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA==
dependencies:
"@types/jsonfile" "*"
"@types/node" "*"

"@types/fuzzy-search@^2.1.2":
Expand Down Expand Up @@ -2851,6 +2852,13 @@
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=

"@types/jsonfile@*":
version "6.1.1"
resolved "https://registry.yarnpkg.com/@types/jsonfile/-/jsonfile-6.1.1.tgz#ac84e9aefa74a2425a0fb3012bdea44f58970f1b"
integrity sha512-GSgiRCVeapDN+3pqA35IkQwasaCh/0YFH5dEF6S88iDvEn901DjOeH3/QPY+XYP1DFzDZPvIvfeEgk+7br5png==
dependencies:
"@types/node" "*"

"@types/jsonwebtoken@^8.5.8":
version "8.5.8"
resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-8.5.8.tgz#01b39711eb844777b7af1d1f2b4cf22fda1c0c44"
Expand Down Expand Up @@ -7212,15 +7220,6 @@ fs-extra@^3.0.1:
jsonfile "^3.0.0"
universalify "^0.1.0"

fs-extra@^4.0.2:
version "4.0.3"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94"
integrity sha512-q6rbdDd1o2mAnQreO7YADIxf/Whx4AHBiRf6d+/cVT8h44ss+lHgxf1FemcqDnQt9X3ct4McHr+JMGlYSsK7Cg==
dependencies:
graceful-fs "^4.1.2"
jsonfile "^4.0.0"
universalify "^0.1.0"

fs-extra@^8.0.1, fs-extra@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
Expand Down Expand Up @@ -11680,12 +11679,12 @@ react-hook-form@^7.41.5:
resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.41.5.tgz#dcd0e7438c15044eadc99df6deb889da5858a03b"
integrity sha512-DAKjSJ7X9f16oQrP3TW2/eD9N6HOgrmIahP4LOdFphEWVfGZ2LulFd6f6AQ/YS/0cx/5oc4j8a1PXxuaurWp/Q==

react-i18next@^12.1.1:
version "12.1.1"
resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-12.1.1.tgz#2626cdbfe6bcb76ef833861c0184a5c4e5e3c089"
integrity sha512-mFdieOI0LDy84q3JuZU6Aou1DoWW2fhapcTGeBS8+vWSJuViuoCLQAMYSb0QoHhXS8B0WKUOPpx4cffAP7r/aA==
react-i18next@^12.1.5:
version "12.1.5"
resolved "https://registry.yarnpkg.com/react-i18next/-/react-i18next-12.1.5.tgz#b65f5733dd2f96188a9359c009b7dbe27443f009"
integrity sha512-7PQAv6DA0TcStG96fle+8RfTwxVbHVlZZJPoEszwUNvDuWpGldJmNWa3ZPesEsZQZGF6GkzwvEh6p57qpFD2gQ==
dependencies:
"@babel/runtime" "^7.14.5"
"@babel/runtime" "^7.20.6"
html-parse-stringify "^3.0.1"

react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.6:
Expand Down

0 comments on commit b73cc76

Please sign in to comment.