mirror of
https://github.com/outline/outline.git
synced 2026-11-21 21:44:30 +03:00
* Add enterprise upsell plugin with placeholder settings pages Introduces a new client-only `upsell` plugin that surfaces Enterprise-only features as placeholder settings pages in the community edition, encouraging self-hosted users to upgrade. The plugin is gated to non-cloud deployments since the cloud edition already ships these features. Adds: - UpsellScene: a reusable upsell page (header, pitch, upgrade CTAs, and a preview of the locked settings). - UpsellSettingRow: an upsell variant of SettingRow that renders an Enterprise-only setting in a locked, non-interactive state. - EnterpriseBadge: a small badge denoting Enterprise-only features. - Placeholder pages for Audit Log, Data Attributes, and Glean. - A pricing URL on UrlHelper for the upgrade call to action. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ca46gcmqU5HGgoK8SFHUx * Add Security upsell rows and Collections upsell page Surfaces more Enterprise-only features in the community edition: - Adds locked upsell rows to the Security settings page for two-factor authentication, automatic sign-out, and an IP allowlist. These only render on self-hosted instances, where the real settings are not available. - Adds a Collections placeholder page to the upsell plugin advertising workspace-wide collection administration. Relocates the shared EnterpriseBadge and UpsellSettingRow components from the plugin into app/scenes/Settings/components so core settings pages and the plugin can both consume them without inverting the app/plugin dependency. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ca46gcmqU5HGgoK8SFHUx * Show plan requirement on upsell pages and sidebar Replace the placeholder Enterprise rows with a single callout that names the minimum plan for each feature, mark upsell items in the settings sidebar with a muted lock, and sync PlanHelper with the plan entitlements. * Hide entitled upsells, show Glean upsell, fix billing link * Render upsell for settings pages without the entitlement Settings items can declare the plan feature they need. Without it, the page shows the upsell scene in place of the real one, and upsell plugin placeholders give way to a real page for the same feature.
326 lines
9.6 KiB
TypeScript
326 lines
9.6 KiB
TypeScript
import {
|
|
EmailIcon,
|
|
ProfileIcon,
|
|
PadlockIcon,
|
|
CodeIcon,
|
|
UserIcon,
|
|
GroupIcon,
|
|
GlobeIcon,
|
|
ShieldIcon,
|
|
TeamIcon,
|
|
SparklesIcon,
|
|
SettingsIcon,
|
|
ExportIcon,
|
|
ImportIcon,
|
|
ShapesIcon,
|
|
PlusIcon,
|
|
InternetIcon,
|
|
SmileyIcon,
|
|
BrowserIcon,
|
|
} from "outline-icons";
|
|
import { useEffect } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import type { PlanFeature } from "@shared/types";
|
|
import { integrationSettingsPath } from "@shared/utils/routeHelpers";
|
|
import { createLazyComponent as lazy } from "~/components/LazyLoad";
|
|
import { Hook, PluginManager } from "~/utils/PluginManager";
|
|
import { settingsPath } from "~/utils/routeHelpers";
|
|
import { useComputed } from "./useComputed";
|
|
import useCurrentTeam from "./useCurrentTeam";
|
|
import useCurrentUser from "./useCurrentUser";
|
|
import usePolicy from "./usePolicy";
|
|
import useStores from "./useStores";
|
|
|
|
const AI = lazy(() => import("~/scenes/Settings/AI"));
|
|
const ApiKeys = lazy(() => import("~/scenes/Settings/ApiKeys"));
|
|
const Applications = lazy(() => import("~/scenes/Settings/Applications"));
|
|
const APIAndAccess = lazy(() => import("~/scenes/Settings/APIAndAccess"));
|
|
const Authentication = lazy(() => import("~/scenes/Settings/Authentication"));
|
|
const Details = lazy(() => import("~/scenes/Settings/Details"));
|
|
const Export = lazy(() => import("~/scenes/Settings/Export"));
|
|
const Groups = lazy(() => import("~/scenes/Settings/Groups"));
|
|
const Import = lazy(() => import("~/scenes/Settings/Import"));
|
|
const Integrations = lazy(() => import("~/scenes/Settings/Integrations"));
|
|
const Users = lazy(() => import("~/scenes/Settings/Users"));
|
|
const Notifications = lazy(() => import("~/scenes/Settings/Notifications"));
|
|
const Preferences = lazy(() => import("~/scenes/Settings/Preferences"));
|
|
const Profile = lazy(() => import("~/scenes/Settings/Profile"));
|
|
const Security = lazy(() => import("~/scenes/Settings/Security"));
|
|
const Shares = lazy(() => import("~/scenes/Settings/Shares"));
|
|
const Templates = lazy(() => import("~/scenes/Settings/Templates"));
|
|
const CustomEmojis = lazy(() => import("~/scenes/Settings/CustomEmojis"));
|
|
const Embeds = lazy(() => import("~/scenes/Settings/Embeds"));
|
|
|
|
export type ConfigItem = {
|
|
name: string;
|
|
path: string;
|
|
icon: React.FC<{
|
|
size?: number;
|
|
fill?: string;
|
|
monochrome?: boolean;
|
|
}>;
|
|
component: React.ComponentType;
|
|
description?: string;
|
|
preload?: () => void;
|
|
enabled: boolean;
|
|
group: string;
|
|
pluginId?: string;
|
|
/** The plan feature needed for this page. Without it, an upsell page shows instead. */
|
|
entitlement?: PlanFeature;
|
|
/** Whether the page is only an upsell, removed when a real page needs the same entitlement. */
|
|
placeholder?: boolean;
|
|
/** Whether the team does not have the entitlement for this page. */
|
|
locked?: boolean;
|
|
};
|
|
|
|
const useSettingsConfig = () => {
|
|
const { integrations } = useStores();
|
|
const user = useCurrentUser();
|
|
const team = useCurrentTeam();
|
|
const can = usePolicy(team);
|
|
const { t } = useTranslation();
|
|
|
|
useEffect(() => {
|
|
void integrations.fetchAllIfNeeded();
|
|
}, [integrations]);
|
|
|
|
const config = useComputed(() => {
|
|
const items: ConfigItem[] = [
|
|
// Account
|
|
{
|
|
name: t("Profile"),
|
|
path: settingsPath(),
|
|
component: Profile.Component,
|
|
preload: Profile.preload,
|
|
enabled: true,
|
|
group: t("Account"),
|
|
icon: ProfileIcon,
|
|
},
|
|
{
|
|
name: t("Preferences"),
|
|
path: settingsPath("preferences"),
|
|
component: Preferences.Component,
|
|
preload: Preferences.preload,
|
|
enabled: true,
|
|
group: t("Account"),
|
|
icon: SettingsIcon,
|
|
},
|
|
{
|
|
name: t("Notifications"),
|
|
path: settingsPath("notifications"),
|
|
component: Notifications.Component,
|
|
preload: Notifications.preload,
|
|
enabled: true,
|
|
group: t("Account"),
|
|
icon: EmailIcon,
|
|
},
|
|
{
|
|
name: t("API & Access"),
|
|
path: settingsPath("api-and-access"),
|
|
component: APIAndAccess.Component,
|
|
preload: APIAndAccess.preload,
|
|
enabled: true,
|
|
group: t("Account"),
|
|
icon: CodeIcon,
|
|
},
|
|
// Workspace
|
|
{
|
|
name: t("General"),
|
|
path: settingsPath("details"),
|
|
component: Details.Component,
|
|
preload: Details.preload,
|
|
enabled: can.update,
|
|
group: t("Workspace"),
|
|
icon: TeamIcon,
|
|
},
|
|
{
|
|
name: t("Users"),
|
|
path: settingsPath("users"),
|
|
component: Users.Component,
|
|
preload: Users.preload,
|
|
enabled: can.listUsers,
|
|
group: t("Workspace"),
|
|
icon: UserIcon,
|
|
},
|
|
{
|
|
name: t("Groups"),
|
|
path: settingsPath("groups"),
|
|
component: Groups.Component,
|
|
preload: Groups.preload,
|
|
enabled: can.listGroups,
|
|
group: t("Workspace"),
|
|
icon: GroupIcon,
|
|
},
|
|
{
|
|
name: t("Authentication"),
|
|
path: settingsPath("authentication"),
|
|
component: Authentication.Component,
|
|
preload: Authentication.preload,
|
|
enabled: can.update,
|
|
group: t("Workspace"),
|
|
icon: PadlockIcon,
|
|
},
|
|
{
|
|
name: t("Security"),
|
|
path: settingsPath("security"),
|
|
component: Security.Component,
|
|
preload: Security.preload,
|
|
enabled: can.update,
|
|
group: t("Workspace"),
|
|
icon: ShieldIcon,
|
|
},
|
|
{
|
|
name: t("Templates"),
|
|
path: settingsPath("templates"),
|
|
component: Templates.Component,
|
|
preload: Templates.preload,
|
|
enabled: can.readTemplate,
|
|
group: t("Workspace"),
|
|
icon: ShapesIcon,
|
|
},
|
|
{
|
|
name: t("Emojis"),
|
|
path: settingsPath("emojis"),
|
|
component: CustomEmojis.Component,
|
|
preload: CustomEmojis.preload,
|
|
enabled: can.update,
|
|
group: t("Workspace"),
|
|
icon: SmileyIcon,
|
|
},
|
|
{
|
|
name: t("AI"),
|
|
path: settingsPath("ai"),
|
|
component: AI.Component,
|
|
preload: AI.preload,
|
|
enabled: can.update,
|
|
group: t("Workspace"),
|
|
icon: SparklesIcon,
|
|
},
|
|
{
|
|
name: t("Shared links"),
|
|
path: settingsPath("shares"),
|
|
component: Shares.Component,
|
|
preload: Shares.preload,
|
|
enabled: can.listShares,
|
|
group: t("Workspace"),
|
|
icon: GlobeIcon,
|
|
},
|
|
{
|
|
name: t("Import"),
|
|
path: settingsPath("import"),
|
|
component: Import.Component,
|
|
preload: Import.preload,
|
|
enabled: can.createImport,
|
|
group: t("Workspace"),
|
|
icon: ImportIcon,
|
|
},
|
|
{
|
|
name: t("Export"),
|
|
path: settingsPath("export"),
|
|
component: Export.Component,
|
|
preload: Export.preload,
|
|
enabled: can.createExport,
|
|
group: t("Workspace"),
|
|
icon: ExportIcon,
|
|
},
|
|
// Integrations
|
|
{
|
|
name: t("Embeds"),
|
|
path: integrationSettingsPath("embeds"),
|
|
component: Embeds.Component,
|
|
preload: Embeds.preload,
|
|
description: t(
|
|
"Configure which embed providers are available in the editor."
|
|
),
|
|
enabled: can.update,
|
|
group: t("Integrations"),
|
|
icon: BrowserIcon,
|
|
},
|
|
{
|
|
name: `${t("Install")}…`,
|
|
path: settingsPath("integrations"),
|
|
component: Integrations.Component,
|
|
preload: Integrations.preload,
|
|
enabled: can.update,
|
|
group: t("Integrations"),
|
|
icon: PlusIcon,
|
|
},
|
|
// Developer
|
|
{
|
|
name: t("API keys"),
|
|
path: settingsPath("api-keys"),
|
|
component: ApiKeys.Component,
|
|
preload: ApiKeys.preload,
|
|
enabled: can.listApiKeys,
|
|
group: t("Developer"),
|
|
icon: CodeIcon,
|
|
},
|
|
{
|
|
name: t("Applications"),
|
|
path: settingsPath("applications"),
|
|
component: Applications.Component,
|
|
preload: Applications.preload,
|
|
enabled: can.listOAuthClients,
|
|
group: t("Developer"),
|
|
icon: InternetIcon,
|
|
},
|
|
];
|
|
|
|
// Plugins
|
|
PluginManager.getHooks(Hook.Settings).forEach((plugin) => {
|
|
const group = plugin.value.group ?? "Integrations";
|
|
const insertIndex = plugin.value.after
|
|
? items.findIndex((i) => i.name === t(plugin.value.after!)) + 1
|
|
: items.findIndex((i) => i.group === t(group));
|
|
items.splice(insertIndex, 0, {
|
|
name: t(plugin.name),
|
|
path:
|
|
group === "Integrations"
|
|
? integrationSettingsPath(plugin.id)
|
|
: settingsPath(plugin.id),
|
|
group: t(group),
|
|
pluginId: plugin.id,
|
|
description: plugin.value.description,
|
|
component: plugin.value.component.Component,
|
|
preload: plugin.value.component.preload,
|
|
enabled: plugin.value.enabled
|
|
? plugin.value.enabled(team, user)
|
|
: can.update,
|
|
icon: plugin.value.icon,
|
|
entitlement: plugin.value.entitlement,
|
|
placeholder: plugin.value.placeholder,
|
|
} as ConfigItem);
|
|
});
|
|
|
|
return items
|
|
.filter(
|
|
(item) =>
|
|
!item.placeholder ||
|
|
!items.some(
|
|
(other) =>
|
|
!other.placeholder && other.entitlement === item.entitlement
|
|
)
|
|
)
|
|
.map((item): ConfigItem => {
|
|
if (!item.entitlement) {
|
|
return item;
|
|
}
|
|
|
|
const locked = !team.hasEntitlement(item.entitlement);
|
|
if (item.placeholder && !locked) {
|
|
return { ...item, enabled: false };
|
|
}
|
|
|
|
return {
|
|
...item,
|
|
locked,
|
|
preload: locked && !item.placeholder ? undefined : item.preload,
|
|
};
|
|
});
|
|
}, [t, can.createApiKey, can.update, can.createImport, can.createExport]);
|
|
|
|
return config.filter((item) => item.enabled);
|
|
};
|
|
|
|
export default useSettingsConfig;
|