Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

refractor(AppLock):in-sidebar-moved-disabled-to-parent-button

Aswin Asokcaa046baa032
diff --git a/web/apps/photos/src/components/Sidebar.tsx b/web/apps/photos/src/components/Sidebar.tsx
index 84fd2a039e..18ed08399f 100644
--- a/web/apps/photos/src/components/Sidebar.tsx
+++ b/web/apps/photos/src/components/Sidebar.tsx
@@ -79,6 +79,7 @@ import { SessionsSettings } from "ente-new/photos/components/sidebar/SessionsSet
import { TwoFactorSettings } from "ente-new/photos/components/sidebar/TwoFactorSettings";
import { downloadAppDialogAttributes } from "ente-new/photos/components/utils/download";
import {
+ useAppLockSnapshot,
useHLSGenerationStatusSnapshot,
useSettingsSnapshot,
useUserDetailsSnapshot,
@@ -1161,6 +1162,7 @@ const Account: React.FC<AccountProps> = ({
const DesktopAppLockSettings: React.FC<
Pick<SidebarProps, "onAuthenticateUser"> & Pick<AccountProps, "onRootClose">
> = ({ onAuthenticateUser, onRootClose }) => {
+ const appLock = useAppLockSnapshot();
const { show, props } = useModalVisibility();
const handleOpen = useCallback(async () => {
@@ -1176,7 +1178,18 @@ const DesktopAppLockSettings: React.FC<
return (
<>
<RowButtonGroup>
- <RowButton label={t("app_lock")} onClick={handleOpen} />
+ <RowButton
+ label={t("app_lock")}
+ caption={
+ !appLock.supported
+ ? t("app_lock_not_supported", {
+ defaultValue: "App lock is not supported",
+ })
+ : undefined
+ }
+ disabled={!appLock.supported}
+ onClick={handleOpen}
+ />
</RowButtonGroup>
<AppLockSettings {...props} onRootClose={onRootClose} />
</>
diff --git a/web/packages/base/components/RowButton.tsx b/web/packages/base/components/RowButton.tsx
index 88686f0eee..a66bec3e42 100644
--- a/web/packages/base/components/RowButton.tsx
+++ b/web/packages/base/components/RowButton.tsx
@@ -323,10 +323,6 @@ interface RowSwitchProps {
* The state of the contained {@link EnteSwitch}.
*/
checked?: boolean;
- /**
- * If true, then the contained {@link EnteSwitch} will be disabled.
- */
- disabled?: boolean;
/**
* Called when the user activates the contained {@link EnteSwitch}.
*/
@@ -350,7 +346,6 @@ interface RowSwitchProps {
*/
export const RowSwitch: React.FC<RowSwitchProps> = ({
checked,
- disabled,
label,
onClick,
}) => (
@@ -364,17 +359,10 @@ export const RowSwitch: React.FC<RowSwitchProps> = ({
pr: "12px",
}}
>
- <Typography
- sx={{
- py: "14px",
- px: "2px",
- fontWeight: "medium",
- ...(disabled ? { color: "text.muted" } : undefined),
- }}
- >
+ <Typography sx={{ py: "14px", px: "2px", fontWeight: "medium" }}>
{label}
</Typography>
- <EnteSwitch {...{ checked, disabled, onClick }} />
+ <EnteSwitch {...{ checked, onClick }} />
</Stack>
);
diff --git a/web/packages/new/photos/components/sidebar/AppLockSettings.tsx b/web/packages/new/photos/components/sidebar/AppLockSettings.tsx
index c1cb255ae3..d7799379b3 100644
--- a/web/packages/new/photos/components/sidebar/AppLockSettings.tsx
+++ b/web/packages/new/photos/components/sidebar/AppLockSettings.tsx
@@ -13,7 +13,6 @@ import {
RowButtonDivider,
RowButtonEndActivityIndicator,
RowButtonGroup,
- RowButtonGroupHint,
RowSwitch,
} from "ente-base/components/RowButton";
import { errorDialogAttributes } from "ente-base/components/utils/dialog";
@@ -197,17 +196,9 @@ export const AppLockSettings: React.FC<NestedSidebarDrawerVisibilityProps> = ({
<RowSwitch
label={t("enabled")}
checked={state.enabled}
- disabled={!state.supported}
onClick={handleToggleEnabled}
/>
</RowButtonGroup>
- {!state.supported && (
- <RowButtonGroupHint>
- {t("app_lock_not_supported", {
- defaultValue: "App lock is not supported",
- })}
- </RowButtonGroupHint>
- )}
{state.enabled && (
<>