mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
fix
This commit is contained in:
@@ -14,4 +14,6 @@ export const Feature = {
|
|||||||
SCIM: 'scim',
|
SCIM: 'scim',
|
||||||
PAGE_VERIFICATION: 'page:verification',
|
PAGE_VERIFICATION: 'page:verification',
|
||||||
AUDIT_LOGS: 'audit:logs',
|
AUDIT_LOGS: 'audit:logs',
|
||||||
|
RETENTION: 'retention',
|
||||||
|
SHARING_CONTROLS: 'sharing:controls',
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ function DisablePublicSharingToggle() {
|
|||||||
const [checked, setChecked] = useState(
|
const [checked, setChecked] = useState(
|
||||||
workspace?.settings?.sharing?.disabled === true,
|
workspace?.settings?.sharing?.disabled === true,
|
||||||
);
|
);
|
||||||
const hasAccess = useHasFeature(Feature.SECURITY_SETTINGS);
|
const hasSharingControls = useHasFeature(Feature.SHARING_CONTROLS);
|
||||||
const upgradeLabel = useUpgradeLabel();
|
const upgradeLabel = useUpgradeLabel();
|
||||||
|
|
||||||
const applyChange = async (value: boolean) => {
|
const applyChange = async (value: boolean) => {
|
||||||
@@ -75,11 +75,11 @@ function DisablePublicSharingToggle() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip label={upgradeLabel} disabled={hasAccess} refProp="rootRef">
|
<Tooltip label={upgradeLabel} disabled={hasSharingControls} refProp="rootRef">
|
||||||
<Switch
|
<Switch
|
||||||
checked={checked}
|
checked={checked}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
disabled={!hasAccess}
|
disabled={!hasSharingControls}
|
||||||
aria-label={t("Toggle public sharing")}
|
aria-label={t("Toggle public sharing")}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export function EnforceSsoToggle({ size, label }: EnforceSsoToggleProps) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
||||||
const [checked, setChecked] = useState(workspace?.enforceSso);
|
const [checked, setChecked] = useState(workspace?.enforceSso);
|
||||||
const hasAccess = useHasFeature(Feature.SECURITY_SETTINGS);
|
const hasAccess = useHasFeature(Feature.SSO_CUSTOM);
|
||||||
const upgradeLabel = useUpgradeLabel();
|
const upgradeLabel = useUpgradeLabel();
|
||||||
|
|
||||||
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import React, { useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { ISpace } from "@/features/space/types/space.types.ts";
|
import { ISpace } from "@/features/space/types/space.types.ts";
|
||||||
import { useUpdateSpaceMutation } from "@/features/space/queries/space-query.ts";
|
import { useUpdateSpaceMutation } from "@/features/space/queries/space-query.ts";
|
||||||
|
import { useHasFeature } from "@/ee/hooks/use-feature.ts";
|
||||||
|
import { Feature } from "@/ee/features.ts";
|
||||||
|
import { useUpgradeLabel } from "@/ee/hooks/use-upgrade-label.ts";
|
||||||
|
|
||||||
type SpacePublicSharingToggleProps = {
|
type SpacePublicSharingToggleProps = {
|
||||||
space: ISpace;
|
space: ISpace;
|
||||||
@@ -17,6 +20,9 @@ export default function SpacePublicSharingToggle({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [workspace] = useAtom(workspaceAtom);
|
const [workspace] = useAtom(workspaceAtom);
|
||||||
const workspaceDisabled = workspace?.settings?.sharing?.disabled === true;
|
const workspaceDisabled = workspace?.settings?.sharing?.disabled === true;
|
||||||
|
const hasSharingControls = useHasFeature(Feature.SHARING_CONTROLS);
|
||||||
|
const upgradeLabel = useUpgradeLabel();
|
||||||
|
const isDisabled = !hasSharingControls || workspaceDisabled;
|
||||||
const [checked, setChecked] = useState(
|
const [checked, setChecked] = useState(
|
||||||
space.settings?.sharing?.disabled === true,
|
space.settings?.sharing?.disabled === true,
|
||||||
);
|
);
|
||||||
@@ -68,14 +74,14 @@ export default function SpacePublicSharingToggle({
|
|||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
label={t("Public sharing is disabled at the workspace level")}
|
label={!hasSharingControls ? upgradeLabel : t("Public sharing is disabled at the workspace level")}
|
||||||
disabled={!workspaceDisabled}
|
disabled={!isDisabled}
|
||||||
refProp="rootRef"
|
refProp="rootRef"
|
||||||
>
|
>
|
||||||
<Switch
|
<Switch
|
||||||
checked={checked}
|
checked={checked}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
disabled={workspaceDisabled}
|
disabled={isDisabled}
|
||||||
aria-label={t("Toggle space public sharing")}
|
aria-label={t("Toggle space public sharing")}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ function retentionToDays(amount: number, unit: RetentionUnit): number {
|
|||||||
|
|
||||||
export default function TrashRetention() {
|
export default function TrashRetention() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const hasAccess = useHasFeature(Feature.SECURITY_SETTINGS);
|
const hasRetention = useHasFeature(Feature.RETENTION);
|
||||||
const upgradeLabel = useUpgradeLabel();
|
const upgradeLabel = useUpgradeLabel();
|
||||||
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
const [workspace, setWorkspace] = useAtom(workspaceAtom);
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ export default function TrashRetention() {
|
|||||||
{t("Pages in trash will be permanently deleted after this period.")}
|
{t("Pages in trash will be permanently deleted after this period.")}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Tooltip label={upgradeLabel} disabled={hasAccess}>
|
<Tooltip label={upgradeLabel} disabled={hasRetention}>
|
||||||
<Group gap="xs" wrap="nowrap" maw={320}>
|
<Group gap="xs" wrap="nowrap" maw={320}>
|
||||||
<NumberInput
|
<NumberInput
|
||||||
value={retentionAmount}
|
value={retentionAmount}
|
||||||
@@ -116,7 +116,7 @@ export default function TrashRetention() {
|
|||||||
hideControls
|
hideControls
|
||||||
size="sm"
|
size="sm"
|
||||||
w={60}
|
w={60}
|
||||||
disabled={!hasAccess}
|
disabled={!hasRetention}
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
data={[
|
data={[
|
||||||
@@ -132,13 +132,13 @@ export default function TrashRetention() {
|
|||||||
}}
|
}}
|
||||||
size="sm"
|
size="sm"
|
||||||
style={{ flex: 1 }}
|
style={{ flex: 1 }}
|
||||||
disabled={!hasAccess}
|
disabled={!hasRetention}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={handleSave}
|
onClick={handleSave}
|
||||||
loading={saving}
|
loading={saving}
|
||||||
disabled={!hasAccess || !isDirty}
|
disabled={!hasRetention || !isDirty}
|
||||||
>
|
>
|
||||||
{t("Save")}
|
{t("Save")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -18,7 +18,9 @@ import { Feature } from "@/ee/features";
|
|||||||
export default function Security() {
|
export default function Security() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { isAdmin } = useUserRole();
|
const { isAdmin } = useUserRole();
|
||||||
const hasSecurityAccess = useHasFeature(Feature.SECURITY_SETTINGS);
|
const hasCustomSso = useHasFeature(Feature.SSO_CUSTOM);
|
||||||
|
const hasRetention = useHasFeature(Feature.RETENTION);
|
||||||
|
const hasSharingControls = useHasFeature(Feature.SHARING_CONTROLS);
|
||||||
|
|
||||||
if (!isAdmin) {
|
if (!isAdmin) {
|
||||||
return null;
|
return null;
|
||||||
@@ -35,39 +37,27 @@ export default function Security() {
|
|||||||
|
|
||||||
<Divider my="lg" />
|
<Divider my="lg" />
|
||||||
|
|
||||||
{(!isCloud() || hasSecurityAccess) && (
|
|
||||||
<>
|
|
||||||
<DisablePublicSharing />
|
<DisablePublicSharing />
|
||||||
<Divider my="lg" />
|
<Divider my="lg" />
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!isCloud() && (
|
|
||||||
<>
|
|
||||||
<TrashRetention />
|
<TrashRetention />
|
||||||
<Divider my="lg" />
|
<Divider my="lg" />
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Title order={4} my="lg">
|
<Title order={4} my="lg">
|
||||||
Single sign-on (SSO)
|
Single sign-on (SSO)
|
||||||
</Title>
|
</Title>
|
||||||
|
|
||||||
{hasSecurityAccess && (
|
|
||||||
<>
|
|
||||||
<EnforceSso />
|
<EnforceSso />
|
||||||
<Divider my="lg" />
|
<Divider my="lg" />
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{(isCloud() || hasSecurityAccess) && (
|
{(isCloud() || hasCustomSso) && (
|
||||||
<>
|
<>
|
||||||
<AllowedDomains />
|
<AllowedDomains />
|
||||||
<Divider my="lg" />
|
<Divider my="lg" />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{hasSecurityAccess && (
|
{hasCustomSso && (
|
||||||
<>
|
<>
|
||||||
<CreateSsoProvider />
|
<CreateSsoProvider />
|
||||||
<Divider size={0} my="lg" />
|
<Divider size={0} my="lg" />
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ import {
|
|||||||
ResponsiveSettingsRow,
|
ResponsiveSettingsRow,
|
||||||
} from "@/components/ui/responsive-settings-row.tsx";
|
} from "@/components/ui/responsive-settings-row.tsx";
|
||||||
import SpacePublicSharingToggle from "@/ee/security/components/space-public-sharing-toggle.tsx";
|
import SpacePublicSharingToggle from "@/ee/security/components/space-public-sharing-toggle.tsx";
|
||||||
import { useHasFeature } from "@/ee/hooks/use-feature";
|
|
||||||
import { Feature } from "@/ee/features";
|
|
||||||
|
|
||||||
interface SpaceDetailsProps {
|
interface SpaceDetailsProps {
|
||||||
spaceId: string;
|
spaceId: string;
|
||||||
@@ -29,8 +27,7 @@ interface SpaceDetailsProps {
|
|||||||
export default function SpaceDetails({ spaceId, readOnly }: SpaceDetailsProps) {
|
export default function SpaceDetails({ spaceId, readOnly }: SpaceDetailsProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { data: space, isLoading, refetch } = useSpaceQuery(spaceId);
|
const { data: space, isLoading, refetch } = useSpaceQuery(spaceId);
|
||||||
const hasEnterpriseAccess = useHasFeature(Feature.SECURITY_SETTINGS);
|
const showSharingToggle = !readOnly;
|
||||||
const showSharingToggle = !readOnly && hasEnterpriseAccess;
|
|
||||||
const [exportOpened, { open: openExportModal, close: closeExportModal }] =
|
const [exportOpened, { open: openExportModal, close: closeExportModal }] =
|
||||||
useDisclosure(false);
|
useDisclosure(false);
|
||||||
const [isIconUploading, setIsIconUploading] = useState(false);
|
const [isIconUploading, setIsIconUploading] = useState(false);
|
||||||
|
|||||||
+1
-1
Submodule apps/server/src/ee updated: 44300c3d8e...8b21c6e32e
Reference in New Issue
Block a user