chore: prioritize access policies in system settings
This commit is contained in:
parent
191ec01d11
commit
245e5e3a3e
6 changed files with 62 additions and 47 deletions
|
|
@ -122,27 +122,30 @@ const InstanceSection = () => {
|
||||||
{t("common.edit")}
|
{t("common.edit")}
|
||||||
</Button>
|
</Button>
|
||||||
</SettingListItem>
|
</SettingListItem>
|
||||||
|
|
||||||
|
<SettingListItem label={t("setting.instance.week-start-day")} description={t("setting.instance.week-start-day-description")}>
|
||||||
|
<Select
|
||||||
|
value={instanceGeneralSetting.weekStartDayOffset.toString()}
|
||||||
|
items={weekStartDayOptions}
|
||||||
|
onValueChange={(value) => {
|
||||||
|
updatePartialSetting({ weekStartDayOffset: parseInt(value) || 0 });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="min-w-fit">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{weekStartDayOptions.map((option) => (
|
||||||
|
<SelectItem key={option.value} value={option.value}>
|
||||||
|
{option.label}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</SettingListItem>
|
||||||
</SettingList>
|
</SettingList>
|
||||||
</SettingGroup>
|
</SettingGroup>
|
||||||
|
|
||||||
<SettingGroup title={t("setting.system.custom-code-title")} description={t("setting.system.custom-code-description")} showSeparator>
|
|
||||||
<SettingCodeEditor
|
|
||||||
label={t("setting.system.additional-style")}
|
|
||||||
description={t("setting.system.additional-style-description")}
|
|
||||||
placeholder={t("setting.system.additional-style-placeholder")}
|
|
||||||
value={instanceGeneralSetting.additionalStyle}
|
|
||||||
onChange={(additionalStyle) => updatePartialSetting({ additionalStyle })}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<SettingCodeEditor
|
|
||||||
label={t("setting.system.additional-script")}
|
|
||||||
description={t("setting.system.additional-script-description")}
|
|
||||||
placeholder={t("setting.system.additional-script-placeholder")}
|
|
||||||
value={instanceGeneralSetting.additionalScript}
|
|
||||||
onChange={(additionalScript) => updatePartialSetting({ additionalScript })}
|
|
||||||
/>
|
|
||||||
</SettingGroup>
|
|
||||||
|
|
||||||
<SettingGroup title={t("setting.instance.access-title")} description={t("setting.instance.access-description")} showSeparator>
|
<SettingGroup title={t("setting.instance.access-title")} description={t("setting.instance.access-description")} showSeparator>
|
||||||
<SettingList>
|
<SettingList>
|
||||||
<SettingListItem
|
<SettingListItem
|
||||||
|
|
@ -197,30 +200,27 @@ const InstanceSection = () => {
|
||||||
onCheckedChange={(checked) => updatePartialSetting({ disallowChangeNickname: checked })}
|
onCheckedChange={(checked) => updatePartialSetting({ disallowChangeNickname: checked })}
|
||||||
/>
|
/>
|
||||||
</SettingListItem>
|
</SettingListItem>
|
||||||
|
|
||||||
<SettingListItem label={t("setting.instance.week-start-day")} description={t("setting.instance.week-start-day-description")}>
|
|
||||||
<Select
|
|
||||||
value={instanceGeneralSetting.weekStartDayOffset.toString()}
|
|
||||||
items={weekStartDayOptions}
|
|
||||||
onValueChange={(value) => {
|
|
||||||
updatePartialSetting({ weekStartDayOffset: parseInt(value) || 0 });
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<SelectTrigger className="min-w-fit">
|
|
||||||
<SelectValue />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
{weekStartDayOptions.map((option) => (
|
|
||||||
<SelectItem key={option.value} value={option.value}>
|
|
||||||
{option.label}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</SettingListItem>
|
|
||||||
</SettingList>
|
</SettingList>
|
||||||
</SettingGroup>
|
</SettingGroup>
|
||||||
|
|
||||||
|
<SettingGroup title={t("setting.system.custom-code-title")} description={t("setting.system.custom-code-description")} showSeparator>
|
||||||
|
<SettingCodeEditor
|
||||||
|
label={t("setting.system.additional-style")}
|
||||||
|
description={t("setting.system.additional-style-description")}
|
||||||
|
placeholder={t("setting.system.additional-style-placeholder")}
|
||||||
|
value={instanceGeneralSetting.additionalStyle}
|
||||||
|
onChange={(additionalStyle) => updatePartialSetting({ additionalStyle })}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<SettingCodeEditor
|
||||||
|
label={t("setting.system.additional-script")}
|
||||||
|
description={t("setting.system.additional-script-description")}
|
||||||
|
placeholder={t("setting.system.additional-script-placeholder")}
|
||||||
|
value={instanceGeneralSetting.additionalScript}
|
||||||
|
onChange={(additionalScript) => updatePartialSetting({ additionalScript })}
|
||||||
|
/>
|
||||||
|
</SettingGroup>
|
||||||
|
|
||||||
<div className="w-full flex justify-end">
|
<div className="w-full flex justify-end">
|
||||||
<Button disabled={!hasUnsavedChanges} onClick={handleSaveSettings}>
|
<Button disabled={!hasUnsavedChanges} onClick={handleSaveSettings}>
|
||||||
{t("common.save")}
|
{t("common.save")}
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@
|
||||||
"saturday": "Saturday",
|
"saturday": "Saturday",
|
||||||
"sunday": "Sunday",
|
"sunday": "Sunday",
|
||||||
"week-start-day": "Week start day",
|
"week-start-day": "Week start day",
|
||||||
"access-description": "Control anonymous browsing, sign-up, authentication, profile editing, and calendar defaults for this instance.",
|
"access-description": "Control anonymous browsing, sign-up, authentication, and profile editing for this instance.",
|
||||||
"access-title": "Access and policies",
|
"access-title": "Access and policies",
|
||||||
"disallow-change-nickname-description": "Prevent users from changing their display name.",
|
"disallow-change-nickname-description": "Prevent users from changing their display name.",
|
||||||
"disallow-change-username-description": "Prevent users from changing their login username.",
|
"disallow-change-username-description": "Prevent users from changing their login username.",
|
||||||
|
|
@ -613,7 +613,7 @@
|
||||||
"title": "General",
|
"title": "General",
|
||||||
"additional-script-description": "Inject JavaScript into every web page. Use only trusted code.",
|
"additional-script-description": "Inject JavaScript into every web page. Use only trusted code.",
|
||||||
"additional-style-description": "Inject CSS into the web app to adjust instance-wide presentation.",
|
"additional-style-description": "Inject CSS into the web app to adjust instance-wide presentation.",
|
||||||
"basic-description": "Configure the public identity shown by this instance.",
|
"basic-description": "Configure the public identity and calendar defaults for this instance.",
|
||||||
"custom-code-description": "Optional instance-wide CSS and JavaScript applied to the frontend.",
|
"custom-code-description": "Optional instance-wide CSS and JavaScript applied to the frontend.",
|
||||||
"custom-code-title": "Custom code"
|
"custom-code-title": "Custom code"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -606,7 +606,7 @@
|
||||||
"transcription-warning-no-key": "The selected provider has no API key set. Edit the integration above to add one."
|
"transcription-warning-no-key": "The selected provider has no API key set. Edit the integration above to add one."
|
||||||
},
|
},
|
||||||
"instance": {
|
"instance": {
|
||||||
"access-description": "Control anonymous browsing, sign-up, authentication, profile editing, and calendar defaults for this instance.",
|
"access-description": "Control anonymous browsing, sign-up, authentication, and profile editing for this instance.",
|
||||||
"access-title": "Access and policies",
|
"access-title": "Access and policies",
|
||||||
"allow-public-access-description": "Allow signed-out visitors to browse public memos. Shared memo links remain available when this is disabled.",
|
"allow-public-access-description": "Allow signed-out visitors to browse public memos. Shared memo links remain available when this is disabled.",
|
||||||
"allow-public-access": "Allow public access",
|
"allow-public-access": "Allow public access",
|
||||||
|
|
@ -941,7 +941,7 @@
|
||||||
"additional-style-description": "Inject CSS into the web app to adjust instance-wide presentation.",
|
"additional-style-description": "Inject CSS into the web app to adjust instance-wide presentation.",
|
||||||
"additional-style-placeholder": "Additional CSS code",
|
"additional-style-placeholder": "Additional CSS code",
|
||||||
"allow-user-signup": "Allow user signup",
|
"allow-user-signup": "Allow user signup",
|
||||||
"basic-description": "Configure the public identity shown by this instance.",
|
"basic-description": "Configure the public identity and calendar defaults for this instance.",
|
||||||
"customize-server": {
|
"customize-server": {
|
||||||
"description": "Description",
|
"description": "Description",
|
||||||
"icon-url": "Icon URL",
|
"icon-url": "Icon URL",
|
||||||
|
|
|
||||||
|
|
@ -657,7 +657,7 @@
|
||||||
"additional-style-description": "向前端应用注入 CSS,用于调整实例范围内的显示效果。",
|
"additional-style-description": "向前端应用注入 CSS,用于调整实例范围内的显示效果。",
|
||||||
"additional-style-placeholder": "自定义 CSS 代码",
|
"additional-style-placeholder": "自定义 CSS 代码",
|
||||||
"allow-user-signup": "允许用户注册",
|
"allow-user-signup": "允许用户注册",
|
||||||
"basic-description": "配置该实例对外展示的身份信息。",
|
"basic-description": "配置该实例对外展示的身份信息和日历默认行为。",
|
||||||
"customize-server": {
|
"customize-server": {
|
||||||
"description": "描述",
|
"description": "描述",
|
||||||
"icon-url": "图标链接",
|
"icon-url": "图标链接",
|
||||||
|
|
@ -722,7 +722,7 @@
|
||||||
"username-note": "用于登录"
|
"username-note": "用于登录"
|
||||||
},
|
},
|
||||||
"instance": {
|
"instance": {
|
||||||
"access-description": "控制该实例的注册、登录、资料编辑和日历默认行为。",
|
"access-description": "控制该实例的公开访问、注册、登录和资料编辑。",
|
||||||
"access-title": "访问和策略",
|
"access-title": "访问和策略",
|
||||||
"disallow-change-nickname-description": "阻止用户修改显示昵称。",
|
"disallow-change-nickname-description": "阻止用户修改显示昵称。",
|
||||||
"disallow-change-nickname": "禁止修改用户昵称",
|
"disallow-change-nickname": "禁止修改用户昵称",
|
||||||
|
|
|
||||||
|
|
@ -611,7 +611,7 @@
|
||||||
"transcription-warning-no-key": "所選服務供應商尚未設定 API 金鑰。請編輯上方的整合以新增。"
|
"transcription-warning-no-key": "所選服務供應商尚未設定 API 金鑰。請編輯上方的整合以新增。"
|
||||||
},
|
},
|
||||||
"instance": {
|
"instance": {
|
||||||
"access-description": "控制此實例的註冊、身分驗證、個人檔案編輯和日曆預設值。",
|
"access-description": "控制此實例的公開存取、註冊、身分驗證和個人檔案編輯。",
|
||||||
"access-title": "存取與政策",
|
"access-title": "存取與政策",
|
||||||
"allow-public-access": "允許公開存取",
|
"allow-public-access": "允許公開存取",
|
||||||
"allow-public-access-description": "允許未登入的訪客瀏覽公開備忘錄。停用此選項後,共享的備忘錄連結仍可使用。",
|
"allow-public-access-description": "允許未登入的訪客瀏覽公開備忘錄。停用此選項後,共享的備忘錄連結仍可使用。",
|
||||||
|
|
@ -946,7 +946,7 @@
|
||||||
"additional-style-description": "在網頁應用程式中注入 CSS 以調整實例範圍的呈現方式。",
|
"additional-style-description": "在網頁應用程式中注入 CSS 以調整實例範圍的呈現方式。",
|
||||||
"additional-style-placeholder": "自訂 CSS 代碼",
|
"additional-style-placeholder": "自訂 CSS 代碼",
|
||||||
"allow-user-signup": "允許使用者註冊",
|
"allow-user-signup": "允許使用者註冊",
|
||||||
"basic-description": "設定此實例顯示的公開身分資訊。",
|
"basic-description": "設定此實例顯示的公開身分資訊和日曆預設值。",
|
||||||
"customize-server": {
|
"customize-server": {
|
||||||
"description": "說明",
|
"description": "說明",
|
||||||
"icon-url": "圖示網址",
|
"icon-url": "圖示網址",
|
||||||
|
|
|
||||||
|
|
@ -58,4 +58,19 @@ describe("<InstanceSection> access setting", () => {
|
||||||
expect(setting.value.value.accessMode).toBe(InstanceAccessMode.PUBLIC);
|
expect(setting.value.value.accessMode).toBe(InstanceAccessMode.PUBLIC);
|
||||||
expect(instance.fetchSetting).not.toHaveBeenCalled();
|
expect(instance.fetchSetting).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("orders general settings before access policies and custom code", () => {
|
||||||
|
render(<InstanceSection />);
|
||||||
|
|
||||||
|
const groupHeadings = screen.getAllByRole("heading", { level: 4 });
|
||||||
|
expect(groupHeadings.map((heading) => heading.textContent)).toEqual([
|
||||||
|
"common.basic",
|
||||||
|
"setting.instance.access-title",
|
||||||
|
"setting.system.custom-code-title",
|
||||||
|
]);
|
||||||
|
|
||||||
|
const weekStartDay = screen.getByText("setting.instance.week-start-day");
|
||||||
|
const accessHeading = screen.getByRole("heading", { level: 4, name: "setting.instance.access-title" });
|
||||||
|
expect(weekStartDay.compareDocumentPosition(accessHeading) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue