Skip to content

armgit / ente

Public Imported from GitHub
0

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

chore(featureFlag):single-source-of-truth

Aswin Asokc5eba226549c
diff --git a/web/apps/photos/src/components/Collections/AllAlbums.tsx b/web/apps/photos/src/components/Collections/AllAlbums.tsx
index a0e94fc8e8..86b250b32d 100644
--- a/web/apps/photos/src/components/Collections/AllAlbums.tsx
+++ b/web/apps/photos/src/components/Collections/AllAlbums.tsx
@@ -40,6 +40,7 @@ import type {
CollectionSummary,
} from "ente-new/photos/services/collection-summary";
import { usePhotosAppContext } from "ente-new/photos/types/context";
+import { enableV2 } from "ente-new/photos/utils/feature-flags";
import { t } from "i18next";
import memoize from "memoize-one";
import React, { useEffect, useMemo, useRef, useState } from "react";
@@ -62,8 +63,6 @@ interface AllAlbums {
onRemotePull: () => Promise<void>;
}
-const enableV2 = true as boolean;
-
/**
* A modal showing the list of all the albums.
*/
diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsx
index 6fe3c8d489..2e424cd3ec 100644
--- a/web/apps/photos/src/components/Upload.tsx
+++ b/web/apps/photos/src/components/Upload.tsx
@@ -103,6 +103,7 @@ import {
} from "ente-new/photos/services/collection";
import { redirectToCustomerPortal } from "ente-new/photos/services/user-details";
import { usePhotosAppContext } from "ente-new/photos/types/context";
+import { enableV2 } from "ente-new/photos/utils/feature-flags";
import { firstNonEmpty } from "ente-utils/array";
import { t } from "i18next";
import React, { useCallback, useEffect, useRef, useState } from "react";
@@ -171,8 +172,6 @@ interface UploadProps {
type UploadType = "files" | "folders" | "zips";
-const enableV2 = true as boolean;
-
interface UploadFilesOptions {
persistPendingUploads?: boolean;
postUploadTargetCollection?: Collection;
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index e40ee6ac90..efcd95dc7c 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -130,6 +130,7 @@ import {
addManualFileAssignmentsToPerson,
isMLEnabled,
} from "ente-new/photos/services/ml";
+import { enableV2 } from "ente-new/photos/utils/feature-flags";
import { uploadManager } from "@/services/upload-manager";
import watcher from "@/services/watch";
@@ -188,8 +189,6 @@ import { Trans } from "react-i18next";
* --------------------- |
* Photo List v
*/
-const enableV2 = true as boolean;
-
const Page: React.FC = () => {
const { logout, showMiniDialog, onGenericError } = useBaseContext();
const {
diff --git a/web/packages/gallery/components/upload-progress-v2/UploadProgressDetails.tsx b/web/packages/gallery/components/upload-progress-v2/UploadProgressDetails.tsx
index dd37131aa5..0a55a2cf9c 100644
--- a/web/packages/gallery/components/upload-progress-v2/UploadProgressDetails.tsx
+++ b/web/packages/gallery/components/upload-progress-v2/UploadProgressDetails.tsx
@@ -192,7 +192,7 @@ export function UploadProgressDetails() {
/>
)}
</Box>
- {hasLivePhotos && (
+ {uploadPhase == "uploading" && hasLivePhotos && (
<Typography sx={livePhotosTextSx}>
{t("live_photos_detected")}
</Typography>
diff --git a/web/packages/gallery/components/upload-progress-v2/UploadProgressDialog.tsx b/web/packages/gallery/components/upload-progress-v2/UploadProgressDialog.tsx
index 0dab3a8739..198598297e 100644
--- a/web/packages/gallery/components/upload-progress-v2/UploadProgressDialog.tsx
+++ b/web/packages/gallery/components/upload-progress-v2/UploadProgressDialog.tsx
@@ -151,7 +151,9 @@ function UploadProgressV2Summary() {
)}
{isDeterminate && (
<Typography sx={mutedCaptionSx}>
- {t("percent_complete", { percent: 100 })}
+ {t("percent_complete", {
+ percent: progress,
+ })}
</Typography>
)}
</Stack>
diff --git a/web/packages/new/photos/components/CollectionSelector.tsx b/web/packages/new/photos/components/CollectionSelector.tsx
index afc01fef61..511cc5a939 100644
--- a/web/packages/new/photos/components/CollectionSelector.tsx
+++ b/web/packages/new/photos/components/CollectionSelector.tsx
@@ -35,6 +35,7 @@ import {
type CollectionSummaries,
type CollectionSummary,
} from "ente-new/photos/services/collection-summary";
+import { enableV2 } from "ente-new/photos/utils/feature-flags";
import { includes } from "ente-utils/type-guards";
import { t } from "i18next";
import React, {
@@ -46,8 +47,6 @@ import React, {
} from "react";
import { CollectionSelectorV2 } from "./CollectionSelectorV2";
-const enableV2 = true as boolean;
-
export type CollectionSelectorAction =
| "upload"
| "add"
@@ -142,8 +141,8 @@ export type CollectionSelectorProps = ModalVisibilityProps & {
* A dialog allowing the user to select one of their existing collections or
* create a new one.
*
- * For internal users this renders the restyled {@link CollectionSelectorV2}
- * variant; everyone else continues to get the classic implementation below.
+ * The shared Photos UI flag chooses the restyled
+ * {@link CollectionSelectorV2} variant or the classic implementation below.
* Both share the exact same props and behaviour.
*/
export const CollectionSelector: React.FC<CollectionSelectorProps> = (
diff --git a/web/packages/new/photos/components/CollectionSelectorV2.tsx b/web/packages/new/photos/components/CollectionSelectorV2.tsx
index 79b61ac5d2..9e0a5cb190 100644
--- a/web/packages/new/photos/components/CollectionSelectorV2.tsx
+++ b/web/packages/new/photos/components/CollectionSelectorV2.tsx
@@ -35,9 +35,9 @@ import type {
} from "./CollectionSelector";
/**
- * The internal-only ("v2") variant of {@link CollectionSelector}, restyled to
- * match the upload design system (paper surfaces, hairline borders, radius 20
- * dialog, 16px tiles, paper-filled 38px icon buttons).
+ * The V2 variant of {@link CollectionSelector}, restyled to match the upload
+ * design system (paper surfaces, hairline borders, radius 20 dialog, 16px
+ * tiles, paper-filled 38px icon buttons).
*
* It preserves the exact same behaviour and props as the classic selector; only
* the presentation differs. See {@link CollectionSelector} for a description of
@@ -144,7 +144,7 @@ export const CollectionSelectorV2: React.FC<CollectionSelectorProps> = (
const showCreateButton =
!searchTerm.trim() ||
- t("new_album").toLowerCase().includes(searchTerm.toLowerCase());
+ t("create_albums").toLowerCase().includes(searchTerm.toLowerCase());
if (!filteredCollections.length || !attributes) return null;
diff --git a/web/packages/new/photos/utils/feature-flags.ts b/web/packages/new/photos/utils/feature-flags.ts
new file mode 100644
index 0000000000..b0803117ce
--- /dev/null
+++ b/web/packages/new/photos/utils/feature-flags.ts
@@ -0,0 +1,7 @@
+/**
+ * Shared rollout switch for the Photos V2 UI.
+ *
+ * Keep this in one module so the app and shared Photos components cannot end
+ * up rendering a mixed V1/V2 flow.
+ */
+export const enableV2 = true as boolean;