mirror of
https://github.com/outline/outline.git
synced 2026-11-27 16:08:58 +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.
154 lines
4.6 KiB
TypeScript
154 lines
4.6 KiB
TypeScript
import { groupBy, sortBy } from "es-toolkit/compat";
|
|
import { observer } from "mobx-react";
|
|
import { BackIcon, PadlockIcon } from "outline-icons";
|
|
import { useCallback } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { useHistory } from "react-router-dom";
|
|
import styled from "styled-components";
|
|
import { Plan } from "@shared/types";
|
|
import type { PlanFeature } from "@shared/types";
|
|
import { s } from "@shared/styles";
|
|
import { PlanHelper } from "@shared/utils/PlanHelper";
|
|
import Flex from "~/components/Flex";
|
|
import Scrollable from "~/components/Scrollable";
|
|
import Tooltip from "~/components/Tooltip";
|
|
import useSettingsConfig from "~/hooks/useSettingsConfig";
|
|
import { useLocationSelector } from "~/hooks/useLocationSelector";
|
|
import { usePlanName } from "~/hooks/usePlanName";
|
|
import useStores from "~/hooks/useStores";
|
|
import isCloudHosted from "~/utils/isCloudHosted";
|
|
import { settingsPath } from "~/utils/routeHelpers";
|
|
import Sidebar from "./Sidebar";
|
|
import Header from "./components/Header";
|
|
import HistoryNavigation from "./components/HistoryNavigation";
|
|
import Section from "./components/Section";
|
|
import SidebarButton from "./components/SidebarButton";
|
|
import SidebarLink from "./components/SidebarLink";
|
|
import Version from "./components/Version";
|
|
|
|
function SettingsSidebar() {
|
|
const { integrations } = useStores();
|
|
const { t } = useTranslation();
|
|
const history = useHistory();
|
|
const pathname = useLocationSelector((location) => location.pathname);
|
|
const configs = useSettingsConfig();
|
|
|
|
const groupedConfig = groupBy(
|
|
// Locked upsell items sort to the end of their group.
|
|
sortBy(
|
|
configs.filter((item) =>
|
|
item.group === t("Integrations") && item.pluginId && !item.locked
|
|
? integrations.findByService(item.pluginId)
|
|
: true
|
|
),
|
|
(item) => (item.locked ? 1 : 0)
|
|
),
|
|
"group"
|
|
);
|
|
|
|
const returnToApp = useCallback(() => {
|
|
history.push("/home");
|
|
}, [history]);
|
|
|
|
return (
|
|
<Sidebar canCollapse={false}>
|
|
<SidebarButton
|
|
title={t("Back to app")}
|
|
image={<StyledBackIcon />}
|
|
onClick={returnToApp}
|
|
/>
|
|
|
|
<Flex auto column>
|
|
<Scrollable shadow>
|
|
{Object.keys(groupedConfig).map((header) => (
|
|
<Section key={header}>
|
|
<Header title={header}>
|
|
{groupedConfig[header].map((item) => (
|
|
<SidebarLink
|
|
key={item.path}
|
|
to={item.path}
|
|
onClickIntent={item.preload}
|
|
active={
|
|
item.path.startsWith(settingsPath("templates")) ||
|
|
item.path.startsWith(settingsPath("groups"))
|
|
? pathname.startsWith(item.path)
|
|
: undefined
|
|
}
|
|
icon={<item.icon />}
|
|
label={
|
|
item.locked && item.entitlement ? (
|
|
<UpsellLabel
|
|
name={item.name}
|
|
feature={item.entitlement}
|
|
/>
|
|
) : (
|
|
item.name
|
|
)
|
|
}
|
|
/>
|
|
))}
|
|
</Header>
|
|
</Section>
|
|
))}
|
|
{!isCloudHosted && (
|
|
<Section>
|
|
<Header title={t("Installation")} />
|
|
<Version />
|
|
</Section>
|
|
)}
|
|
</Scrollable>
|
|
</Flex>
|
|
<HistoryNavigation />
|
|
</Sidebar>
|
|
);
|
|
}
|
|
|
|
interface UpsellLabelProps {
|
|
/** The name of the settings page. */
|
|
name: string;
|
|
/** The plan feature that the page advertises. */
|
|
feature: PlanFeature;
|
|
}
|
|
|
|
function UpsellLabel({ name, feature }: UpsellLabelProps) {
|
|
const { t } = useTranslation();
|
|
const plan = PlanHelper.getMinimumPlan(feature) ?? Plan.Enterprise;
|
|
const planName = usePlanName(plan);
|
|
const description = t("Available on {{ planName }}", { planName });
|
|
|
|
return (
|
|
<UpsellLabelWrapper>
|
|
{name}
|
|
<Tooltip content={description}>
|
|
<Lock role="img" aria-label={description}>
|
|
<PadlockIcon size={16} />
|
|
</Lock>
|
|
</Tooltip>
|
|
</UpsellLabelWrapper>
|
|
);
|
|
}
|
|
|
|
const UpsellLabelWrapper = styled.span`
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 8px;
|
|
`;
|
|
|
|
const Lock = styled.span`
|
|
display: flex;
|
|
flex-shrink: 0;
|
|
color: ${s("textTertiary")};
|
|
opacity: 0.5;
|
|
`;
|
|
|
|
const StyledBackIcon = styled(BackIcon)`
|
|
margin-inline-start: 4px;
|
|
|
|
[dir="rtl"] & {
|
|
transform: rotate(180deg);
|
|
}
|
|
`;
|
|
|
|
export default observer(SettingsSidebar);
|