Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web][photos] Remove obsolete feature flags that are now always enabled

Anand Baburajanf09523c7b77b
diff --git a/web/apps/photos/src/components/Collections/CollectionHeader.tsx b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
index eb44473d5b..8c587e6343 100644
--- a/web/apps/photos/src/components/Collections/CollectionHeader.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionHeader.tsx
@@ -157,7 +157,7 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({
}) => {
const { showMiniDialog, onGenericError } = useBaseContext();
const { showLoadingBar, hideLoadingBar } = usePhotosAppContext();
- const { mapEnabled, isShareePinEnabled } = useSettingsSnapshot();
+ const { mapEnabled } = useSettingsSnapshot();
const overflowMenuIconRef = useRef<SVGSVGElement | null>(null);
const { show: showSortOrderMenu, props: sortOrderMenuVisibilityProps } =
@@ -488,28 +488,24 @@ const CollectionHeaderOptions: React.FC<CollectionHeaderProps> = ({
case "sharedIncoming":
menuOptions = [
- // Pin/Unpin for shared incoming collections (behind feature flag)
- ...(isShareePinEnabled
- ? [
- collectionSummary.attributes.has("shareePinned") ? (
- <OverflowMenuOption
- key="unpin"
- onClick={unpinSharedAlbum}
- startIcon={<PushPinOutlinedIcon />}
- >
- {t("unpin_album")}
- </OverflowMenuOption>
- ) : (
- <OverflowMenuOption
- key="pin"
- onClick={pinSharedAlbum}
- startIcon={<PushPinIcon />}
- >
- {t("pin_album")}
- </OverflowMenuOption>
- ),
- ]
- : []),
+ // Pin/Unpin for shared incoming collections
+ collectionSummary.attributes.has("shareePinned") ? (
+ <OverflowMenuOption
+ key="unpin"
+ onClick={unpinSharedAlbum}
+ startIcon={<PushPinOutlinedIcon />}
+ >
+ {t("unpin_album")}
+ </OverflowMenuOption>
+ ) : (
+ <OverflowMenuOption
+ key="pin"
+ onClick={pinSharedAlbum}
+ startIcon={<PushPinIcon />}
+ >
+ {t("pin_album")}
+ </OverflowMenuOption>
+ ),
collectionSummary.attributes.has("archived") ? (
<OverflowMenuOption
key="unarchive"
diff --git a/web/apps/photos/src/components/Collections/CollectionShare.tsx b/web/apps/photos/src/components/Collections/CollectionShare.tsx
index f3711cb14d..e6ca60803c 100644
--- a/web/apps/photos/src/components/Collections/CollectionShare.tsx
+++ b/web/apps/photos/src/components/Collections/CollectionShare.tsx
@@ -121,8 +121,6 @@ export const CollectionShare: React.FC<CollectionShareProps> = ({
setBlockingLoad,
onRemotePull,
}) => {
- const settings = useSettingsSnapshot();
- const { isAdminRoleEnabled, isSurfacePublicLinkEnabled } = settings;
const { onGenericError } = useBaseContext();
const { showLoadingBar, hideLoadingBar } = usePhotosAppContext();
@@ -175,13 +173,11 @@ export const CollectionShare: React.FC<CollectionShareProps> = ({
);
const isOwner = user.id == collection?.owner?.id;
const isAdmin = currentSharee?.role == "ADMIN";
- const canManageParticipants = isOwner || (isAdminRoleEnabled && isAdmin);
+ const canManageParticipants = isOwner || isAdmin;
const isSharedIncoming = collectionSummary?.type == "sharedIncoming";
const showEmailSection = !isSharedIncoming || canManageParticipants;
const hasPublicLink = collection?.publicURLs.length > 0;
- const showPublicShare =
- isOwner ||
- (isSharedIncoming && hasPublicLink && isSurfacePublicLinkEnabled);
+ const showPublicShare = isOwner || (isSharedIncoming && hasPublicLink);
// Use a ref to track if we've already fetched for this dialog session
const hasFetchedForSession = useRef(false);
@@ -303,8 +299,6 @@ const SharingDetails: React.FC<SharingDetailsProps> = ({
collectionSummary,
emailByUserID,
}) => {
- const settings = useSettingsSnapshot();
- const { isAdminRoleEnabled } = settings;
const isOwner = user.id == collection.owner?.id;
const currentSharee = collection.sharees.find(
(sharee) => sharee.id == user.id,
@@ -314,20 +308,14 @@ const SharingDetails: React.FC<SharingDetailsProps> = ({
const ownerEmail = isOwner ? user?.email : collection.owner?.email;
const collaborators = collection.sharees
- .filter(
- (sharee) =>
- sharee.role == "COLLABORATOR" ||
- (!isAdminRoleEnabled && sharee.role == "ADMIN"),
- )
+ .filter((sharee) => sharee.role == "COLLABORATOR")
.map((sharee) => sharee.email)
.filter((email) => email !== undefined);
- const admins = isAdminRoleEnabled
- ? collection.sharees
- .filter((sharee) => sharee.role == "ADMIN")
- .map((sharee) => sharee.email)
- .filter((email) => email !== undefined)
- : [];
+ const admins = collection.sharees
+ .filter((sharee) => sharee.role == "ADMIN")
+ .map((sharee) => sharee.email)
+ .filter((email) => email !== undefined);
const viewers = collection.sharees
.filter((sharee) => sharee.role == "VIEWER")
@@ -337,7 +325,7 @@ const SharingDetails: React.FC<SharingDetailsProps> = ({
const userOrEmail = (email: string) =>
email == user.email ? t("you") : email;
- if (isAdminRoleEnabled && !isOwner && isAdmin) {
+ if (!isOwner && isAdmin) {
return (
<Stack>
<RowButtonGroupTitle icon={<AdminPanelSettingsIcon />}>
@@ -376,7 +364,7 @@ const SharingDetails: React.FC<SharingDetailsProps> = ({
/>
</RowButtonGroup>
</Stack>
- {isAdminRoleEnabled && admins.length > 0 && (
+ {admins.length > 0 && (
<Stack>
<RowButtonGroupTitle icon={<AdminPanelSettingsIcon />}>
{t("admins", { defaultValue: "Admins" })}
@@ -482,9 +470,6 @@ const EmailShare: React.FC<EmailShareProps> = ({
const { show: showManageEmail, props: manageEmailVisibilityProps } =
useModalVisibility();
- const settings = useSettingsSnapshot();
- const { isAdminRoleEnabled } = settings;
-
const [participantRole, setParticipantRole] =
// Initial value is arbitrary, it always gets reset before
// `showAddParticipant` is called.
@@ -511,7 +496,7 @@ const EmailShare: React.FC<EmailShareProps> = ({
);
const isOwner = user.id == collection.owner?.id;
const isAdmin = currentSharee?.role == "ADMIN";
- const canManageParticipants = isOwner || (isAdminRoleEnabled && isAdmin);
+ const canManageParticipants = isOwner || isAdmin;
return (
<>
@@ -556,18 +541,14 @@ const EmailShare: React.FC<EmailShareProps> = ({
onClick={showAddCollaborator}
label={t("add_collaborators")}
/>
- {isAdminRoleEnabled ? (
- <>
- <RowButtonDivider />
- <RowButton
- startIcon={<AddIcon />}
- onClick={showAddAdmin}
- label={t("add_admins", {
- defaultValue: "Add admins",
- })}
- />
- </>
- ) : null}
+ <RowButtonDivider />
+ <RowButton
+ startIcon={<AddIcon />}
+ onClick={showAddAdmin}
+ label={t("add_admins", {
+ defaultValue: "Add admins",
+ })}
+ />
</>
) : null}
</RowButtonGroup>
@@ -596,7 +577,6 @@ const EmailShare: React.FC<EmailShareProps> = ({
wrap,
onRemotePull,
canManageParticipants,
- adminRoleEnabled: isAdminRoleEnabled,
}}
/>
</>
@@ -931,7 +911,6 @@ type ManageEmailShareProps = ModalVisibilityProps & {
participantCount: number;
wrap: (f: () => Promise<void>) => () => void;
canManageParticipants: boolean;
- adminRoleEnabled: boolean;
} & Pick<
CollectionShareProps,
| "user"
@@ -953,7 +932,6 @@ const ManageEmailShare: React.FC<ManageEmailShareProps> = ({
wrap,
onRemotePull,
canManageParticipants,
- adminRoleEnabled,
}) => {
const { show: showAddParticipant, props: addParticipantVisibilityProps } =
useModalVisibility();
@@ -1005,25 +983,18 @@ const ManageEmailShare: React.FC<ManageEmailShareProps> = ({
const isOwner = user.id == collection.owner?.id;
const collaborators = collection.sharees
- .filter(
- (sharee) =>
- sharee.role == "COLLABORATOR" ||
- (!adminRoleEnabled && sharee.role == "ADMIN"),
- )
+ .filter((sharee) => sharee.role == "COLLABORATOR")
.map((sharee) => sharee.email)
.filter((email) => email !== undefined);
- const admins = adminRoleEnabled
- ? collection.sharees
- .filter((sharee) => sharee.role == "ADMIN")
- .map((sharee) => sharee.email)
- .filter((email) => email !== undefined)
- : [];
+ const admins = collection.sharees
+ .filter((sharee) => sharee.role == "ADMIN")
+ .map((sharee) => sharee.email)
+ .filter((email) => email !== undefined);
const currentSharee = collection.sharees.find(
(sharee) => sharee.email == user.email,
);
if (
- adminRoleEnabled &&
currentSharee?.role == "ADMIN" &&
user.email &&
!admins.includes(user.email)
@@ -1062,8 +1033,7 @@ const ManageEmailShare: React.FC<ManageEmailShareProps> = ({
/>
</RowButtonGroup>
</Stack>
- {adminRoleEnabled &&
- (admins.length > 0 || canManageParticipants) ? (
+ {(admins.length > 0 || canManageParticipants) && (
<Stack>
<RowButtonGroupTitle
icon={<AdminPanelSettingsIcon />}
@@ -1130,7 +1100,7 @@ const ManageEmailShare: React.FC<ManageEmailShareProps> = ({
) : null}
</RowButtonGroup>
</Stack>
- ) : null}
+ )}
<Stack>
<RowButtonGroupTitle icon={<ModeEditIcon />}>
{t("collaborators")}
@@ -1254,13 +1224,7 @@ const ManageEmailShare: React.FC<ManageEmailShareProps> = ({
/>
<ManageParticipant
{...manageParticipantVisibilityProps}
- {...{
- onRootClose,
- wrap,
- collection,
- onRemotePull,
- adminRoleEnabled,
- }}
+ {...{ onRootClose, wrap, collection, onRemotePull }}
participant={selectedParticipant}
/>
</>
@@ -1277,7 +1241,6 @@ type ManageParticipantProps = ModalVisibilityProps & {
* when {@link open} is `true`, but the types don't reflect this.
*/
participant: CollectionUser | undefined;
- adminRoleEnabled: boolean;
} & Pick<CollectionShareProps, "collection" | "onRemotePull">;
const ManageParticipant: React.FC<ManageParticipantProps> = ({
@@ -1288,7 +1251,6 @@ const ManageParticipant: React.FC<ManageParticipantProps> = ({
participant,
wrap,
onRemotePull,
- adminRoleEnabled,
}) => {
const { showMiniDialog } = useBaseContext();
@@ -1405,24 +1367,16 @@ const ManageParticipant: React.FC<ManageParticipantProps> = ({
</Typography>
<RowButtonGroup>
- {adminRoleEnabled ? (
- <>
- <RowButton
- fontWeight="regular"
- onClick={createOnRoleChange("ADMIN")}
- label={t("admin", {
- defaultValue: "Admin",
- })}
- startIcon={<AdminPanelSettingsIcon />}
- endIcon={
- participant.role === "ADMIN" && (
- <DoneIcon />
- )
- }
- />
- <RowButtonDivider />
- </>
- ) : null}
+ <RowButton
+ fontWeight="regular"
+ onClick={createOnRoleChange("ADMIN")}
+ label={t("admin", { defaultValue: "Admin" })}
+ startIcon={<AdminPanelSettingsIcon />}
+ endIcon={
+ participant.role === "ADMIN" && <DoneIcon />
+ }
+ />
+ <RowButtonDivider />
<RowButton
fontWeight="regular"
onClick={createOnRoleChange("COLLABORATOR")}
diff --git a/web/packages/new/photos/components/gallery/BarImpl.tsx b/web/packages/new/photos/components/gallery/BarImpl.tsx
index e14a64c5fe..de9ec1c3ff 100644
--- a/web/packages/new/photos/components/gallery/BarImpl.tsx
+++ b/web/packages/new/photos/components/gallery/BarImpl.tsx
@@ -27,7 +27,6 @@ import type {
CollectionsSortBy,
} from "ente-new/photos/services/collection-summary";
import type { Person } from "ente-new/photos/services/ml/people";
-import { settingsSnapshot } from "ente-new/photos/services/settings";
import { t } from "i18next";
import React, {
memo,
@@ -540,9 +539,7 @@ const CollectionBarCardIcon: React.FC<CollectionBarCardIconProps> = ({
// shared album that is also archived), and there is enough space for 3.
<CollectionBarCardIcon_>
{attributes.has("userFavorites") && <StarIcon fontSize="small" />}
- {(attributes.has("pinned") ||
- (attributes.has("shareePinned") &&
- settingsSnapshot().isShareePinEnabled)) && (
+ {(attributes.has("pinned") || attributes.has("shareePinned")) && (
// Need && to override the 20px set in the container.
<PushPinIcon sx={{ "&&": { fontSize: "18px" } }} />
)}
diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.ts
index df81ca5101..4f2d806883 100644
--- a/web/packages/new/photos/components/gallery/reducer.ts
+++ b/web/packages/new/photos/components/gallery/reducer.ts
@@ -20,7 +20,6 @@ import {
isArchivedCollection,
isHiddenCollection,
} from "ente-new/photos/services/collection";
-import { settingsSnapshot } from "ente-new/photos/services/settings";
import { sortTrashItems, type TrashItem } from "ente-new/photos/services/trash";
import { splitByPredicate } from "ente-utils/array";
import { includes } from "ente-utils/type-guards";
@@ -1559,9 +1558,7 @@ const createCollectionSummaries = (
sortPriority = CollectionSummarySortPriority.pinned;
}
// Check for sharee pinned (for incoming shared collections)
- // Only apply when the feature flag is enabled
if (
- settingsSnapshot().isShareePinEnabled &&
type == "sharedIncoming" &&
collection.sharedMagicMetadata?.data.order == CollectionOrder.pinned
) {
diff --git a/web/packages/new/photos/services/pull.ts b/web/packages/new/photos/services/pull.ts
index c1ef21a976..70af879058 100644
--- a/web/packages/new/photos/services/pull.ts
+++ b/web/packages/new/photos/services/pull.ts
@@ -13,7 +13,7 @@ import {
} from "./collection";
import { isMLSupported, mlSync, pullMLStatus } from "./ml";
import { searchDataSync } from "./search";
-import { pullSettings, settingsSnapshot } from "./settings";
+import { pullSettings } from "./settings";
import { pullTrash, type TrashItem } from "./trash";
/**
@@ -114,15 +114,12 @@ export const pullFiles = async (opts?: PullFilesOpts) => {
videoPrunePermanentlyDeletedFileIDsIfNeeded,
);
// After trash sync, fetch pending removal actions and move affected files
- // to the uncategorized collection. This is gated behind the admin role
- // feature flag since it's related to admin removal functionality.
+ // to the uncategorized collection.
// Wrapped in try-catch since self-hosted servers may not have this endpoint.
- if (settingsSnapshot().isAdminRoleEnabled) {
- try {
- await movePendingRemovalActionsToUncategorized(collections);
- } catch (e) {
- log.warn("Failed to process pending removal actions", e);
- }
+ try {
+ await movePendingRemovalActionsToUncategorized(collections);
+ } catch (e) {
+ log.warn("Failed to process pending removal actions", e);
}
if (didUpdateFiles) {
// TODO: Ok for now since its is only commented for the deduper (gallery
diff --git a/web/packages/new/photos/services/settings.ts b/web/packages/new/photos/services/settings.ts
index 119cb722b2..d9c11b0a50 100644
--- a/web/packages/new/photos/services/settings.ts
+++ b/web/packages/new/photos/services/settings.ts
@@ -47,18 +47,6 @@ export interface Settings {
* `true` if the current user is an internal user.
*/
isInternalUser: boolean;
- /**
- * `true` if admin role management features are enabled.
- */
- isAdminRoleEnabled: boolean;
- /**
- * `true` if public link surfaces should be shown to non-owners.
- */
- isSurfacePublicLinkEnabled: boolean;
- /**
- * `true` if sharee pin feature is enabled for shared albums.
- */
- isShareePinEnabled: boolean;
/**
* `true` if the comments and reactions feature is enabled.
*/
@@ -122,9 +110,6 @@ export interface Settings {
const createDefaultSettings = (): Settings => ({
isInternalUser: false,
- isAdminRoleEnabled: false,
- isSurfacePublicLinkEnabled: false,
- isShareePinEnabled: false,
isCommentsEnabled: false,
mapEnabled: false,
cfUploadProxyDisabled: false,
@@ -227,12 +212,8 @@ const syncSettingsSnapshotWithLocalStorage = () => {
const flags = savedRemoteFeatureFlags();
const settings = createDefaultSettings();
settings.isInternalUser = flags?.internalUser || false;
- settings.isAdminRoleEnabled = true;
- settings.isSurfacePublicLinkEnabled = true;
- settings.isShareePinEnabled = (flags?.internalUser ?? false) || isDevBuild;
settings.isCommentsEnabled =
- ((flags?.serverApiFlag ?? 0) & ServerApiFlag.Comments) !== 0 ||
- !!process.env.NEXT_PUBLIC_ENTE_COMMENTS_ENABLED;
+ ((flags?.serverApiFlag ?? 0) & ServerApiFlag.Comments) !== 0;
settings.mapEnabled = flags?.mapEnabled || false;
settings.cfUploadProxyDisabled = savedCFProxyDisabled();
if (flags?.castUrl) settings.castURL = flags.castUrl;