mirror of
https://github.com/outline/outline.git
synced 2026-11-22 05:51:43 +03:00
* Update Switch component onChange handler to use boolean callback - Remove synthetic event handling from Switch component - Update onChange signature to (checked: boolean) => void - Update all call points across the codebase: - PublicAccess.tsx: Updated handlers for indexing, showLastModified, and published switches - Security.tsx: Created individual handlers for all security preferences - Preferences.tsx: Created individual handlers for user preferences - CollectionForm.tsx: Added createSwitchRegister helper for react-hook-form compatibility - TemplatizeDialog: Updated publish handler - DocumentMenu.tsx: Added handlers for embeds and full-width toggles - Search.tsx: Updated SearchTitlesFilter handler - Application.tsx: Added createSwitchRegister helper - Details.tsx: Updated public branding handler - Features.tsx: Created individual handlers for seamless edit and commenting - OAuthClientForm.tsx: Added createSwitchRegister helper - Maintained backward compatibility with react-hook-form - Improved type safety and code clarity * Fix ESLint floating promise errors - Add void operator to onChange call in CollectionForm.tsx - Add void operator to document.save call in DocumentMenu.tsx These changes fix the @typescript-eslint/no-floating-promises errors while maintaining the existing functionality. * Fix Switch component onChange handlers in remaining files - Updated DocumentCopy.tsx handlers to use boolean parameter - Updated Notifications.tsx to use closure pattern for event types - Updated SlackListItem.tsx to use closure pattern for event names - All TypeScript errors resolved * Refactor createSwitchRegister into utils/forms - Created shared utility function in app/utils/forms.ts - Removed duplicate implementations from CollectionForm, Application, and OAuthClientForm - Updated all usage points to use the shared utility - Improved TypeScript typing with Record<string, unknown> - Fixed imports and removed unused variables - Maintained existing functionality while reducing code duplication * Fix TypeScript errors in createSwitchRegister utility - Updated generic constraint from Record<string, unknown> to FieldValues - Added Path import from react-hook-form for proper type safety - Fixed parameter type from keyof TFormData to Path<TFormData> - Improved type compatibility with react-hook-form's UseFormRegister Resolves TypeScript compilation errors in CI pipeline. * Remove unnecessary handlePublishChange callbacks - Removed handlePublishChange wrapper in DocumentCopy.tsx - Removed handlePublishChange wrapper in TemplatizeDialog/index.tsx - Updated Switch components to use setPublish directly - Simplified code by leveraging boolean callback from Switch component Since Switch now passes boolean directly, no need for intermediate callbacks. * Address review feedback: simplify callbacks and fix fullWidth behavior 1. DocumentCopy.tsx: - Remove handleRecursiveChange callback wrapper - Use setRecursive directly with Switch component 2. DocumentMenu.tsx: - Add void user.save() to persist user preference - Add document.fullWidth = checked for optimistic update behavior Both changes leverage the boolean callback from Switch component properly. * Update Security.tsx * i18n --------- Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com>
78 lines
2.4 KiB
TypeScript
78 lines
2.4 KiB
TypeScript
import { observer } from "mobx-react";
|
|
import { BeakerIcon } from "outline-icons";
|
|
import * as React from "react";
|
|
import { Trans, useTranslation } from "react-i18next";
|
|
import { toast } from "sonner";
|
|
import { TeamPreference } from "@shared/types";
|
|
import Heading from "~/components/Heading";
|
|
import Scene from "~/components/Scene";
|
|
import Switch from "~/components/Switch";
|
|
import Text from "~/components/Text";
|
|
import useCurrentTeam from "~/hooks/useCurrentTeam";
|
|
import SettingRow from "./components/SettingRow";
|
|
|
|
function Features() {
|
|
const team = useCurrentTeam();
|
|
const { t } = useTranslation();
|
|
|
|
const handleSeamlessEditChange = React.useCallback(
|
|
async (checked: boolean) => {
|
|
team.setPreference(TeamPreference.SeamlessEdit, !checked);
|
|
await team.save();
|
|
toast.success(t("Settings saved"));
|
|
},
|
|
[team, t]
|
|
);
|
|
|
|
const handleCommentingChange = React.useCallback(
|
|
async (checked: boolean) => {
|
|
team.setPreference(TeamPreference.Commenting, checked);
|
|
await team.save();
|
|
toast.success(t("Settings saved"));
|
|
},
|
|
[team, t]
|
|
);
|
|
|
|
return (
|
|
<Scene title={t("Features")} icon={<BeakerIcon />}>
|
|
<Heading>{t("Features")}</Heading>
|
|
<Text as="p" type="secondary">
|
|
<Trans>
|
|
Manage optional and beta features. Changing these settings will affect
|
|
the experience for all members of the workspace.
|
|
</Trans>
|
|
</Text>
|
|
<SettingRow
|
|
name={TeamPreference.SeamlessEdit}
|
|
label={t("Separate editing")}
|
|
description={t(
|
|
`When enabled documents have a separate editing mode by default instead of being always editable. This setting can be overridden by user preferences.`
|
|
)}
|
|
>
|
|
<Switch
|
|
id={TeamPreference.SeamlessEdit}
|
|
name={TeamPreference.SeamlessEdit}
|
|
checked={!team.getPreference(TeamPreference.SeamlessEdit)}
|
|
onChange={handleSeamlessEditChange}
|
|
/>
|
|
</SettingRow>
|
|
<SettingRow
|
|
name={TeamPreference.Commenting}
|
|
label={t("Commenting")}
|
|
description={t(
|
|
"When enabled team members can add comments to documents."
|
|
)}
|
|
>
|
|
<Switch
|
|
id={TeamPreference.Commenting}
|
|
name={TeamPreference.Commenting}
|
|
checked={team.getPreference(TeamPreference.Commenting)}
|
|
onChange={handleCommentingChange}
|
|
/>
|
|
</SettingRow>
|
|
</Scene>
|
|
);
|
|
}
|
|
|
|
export default observer(Features);
|