From aa5d24b9e49762bf882ed0c8cc470a8959767b7c Mon Sep 17 00:00:00 2001
From: shamoon <4887959+shamoon@users.noreply.github.com>
Date: Tue, 3 Oct 2023 15:09:25 -0700
Subject: [PATCH] Support notification re deprecated repo

---
 .github/workflows/docker-publish.yml |  1 +
 Dockerfile                           |  3 ++-
 docs/more/homepage-move.md           |  8 +++++++
 src/pages/index.jsx                  | 32 ++++++++++++++++++++++++++++
 4 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 docs/more/homepage-move.md

diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
index 7f317ef6..52d8f867 100644
--- a/.github/workflows/docker-publish.yml
+++ b/.github/workflows/docker-publish.yml
@@ -105,6 +105,7 @@ jobs:
             BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}
             VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}
             REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
+            DEPRECATED_REPO=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.source'] == 'https://github.com/benphelps/homepage' }}
           # https://github.com/docker/setup-qemu-action#about
           # platforms: linux/amd64,linux/arm64,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6
           platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
diff --git a/Dockerfile b/Dockerfile
index 9fec35e7..5019171c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -23,6 +23,7 @@ WORKDIR /app
 ARG BUILDTIME
 ARG VERSION
 ARG REVISION
+ARG DEPRECATED_REPO
 
 COPY --link --from=deps /app/node_modules ./node_modules/
 COPY . .
@@ -30,7 +31,7 @@ COPY . .
 SHELL ["/bin/ash", "-xeo", "pipefail", "-c"]
 RUN npm run telemetry \
  && mkdir config \
- && NEXT_PUBLIC_BUILDTIME=$BUILDTIME NEXT_PUBLIC_VERSION=$VERSION NEXT_PUBLIC_REVISION=$REVISION npm run build
+ && NEXT_PUBLIC_BUILDTIME=$BUILDTIME NEXT_PUBLIC_VERSION=$VERSION NEXT_PUBLIC_REVISION=$REVISION NEXT_PUBLIC_DEPRECATED_REPO=$DEPRECATED_REPO npm run build
 
 # Production image, copy all the files and run next
 FROM docker.io/node:18-alpine AS runner
diff --git a/docs/more/homepage-move.md b/docs/more/homepage-move.md
new file mode 100644
index 00000000..8d1498e8
--- /dev/null
+++ b/docs/more/homepage-move.md
@@ -0,0 +1,8 @@
+---
+title: Homepage Move
+description: Homepage Container Deprecation
+---
+
+As of v0.7.1 homepage migrated from benphelps/homepage to an "orgnization" located at gethomepage/homepage. The reason for this is to setup the project for longevity and allow for community maintenance.
+
+Migrating your installation should be as simple as changing `image: ghcr.io/benphelps/homepage:latest` to `image: ghcr.io/gethomepage/homepage:latest`.
\ No newline at end of file
diff --git a/src/pages/index.jsx b/src/pages/index.jsx
index 9367e8b4..0d9c6a7b 100644
--- a/src/pages/index.jsx
+++ b/src/pages/index.jsx
@@ -27,6 +27,7 @@ import ErrorBoundary from "components/errorboundry";
 import themes from "utils/styles/themes";
 import QuickLaunch from "components/quicklaunch";
 import { getStoredProvider, searchProviders } from "components/widgets/search/search";
+import ResolvedIcon from "components/resolvedicon";
 
 const ThemeToggle = dynamic(() => import("components/toggles/theme"), {
   ssr: false,
@@ -167,6 +168,17 @@ const headerStyles = {
   boxedWidgets: "m-6 mb-0 sm:m-9 sm:mb-0 sm:mt-1",
 };
 
+const deprecatedNotificationDismissedStorageKey = "deprecated-notification-dismissed";
+
+const getNotificationDismissed = () => {
+  if (typeof window !== "undefined" && window.localStorage) {
+    const dismissed = window.localStorage.getItem(deprecatedNotificationDismissedStorageKey);
+    return dismissed;
+  }
+
+  return false;
+};
+
 function Home({ initialSettings }) {
   const { i18n } = useTranslation();
   const { theme, setTheme } = useContext(ThemeContext);
@@ -175,6 +187,9 @@ function Home({ initialSettings }) {
   const { activeTab, setActiveTab } = useContext(TabContext);
   const { asPath } = useRouter();
 
+  const isDeprecatedRepo = process.env.NEXT_PUBLIC_DEPRECATED_REPO;
+  const [notificationDismissed, setNotificationDismissed] = useState(getNotificationDismissed);
+
   useEffect(() => {
     setSettings(initialSettings);
   }, [initialSettings, setSettings]);
@@ -420,6 +435,23 @@ function Home({ initialSettings }) {
           </div>
 
           <div id="version" className="flex mt-4 w-full justify-end">
+            {isDeprecatedRepo && !notificationDismissed && // outside version in case its hidden
+              <div className="flex flex-row items-center py-1 pl-2 mr-3 rounded-md text-xs text-theme-700 dark:text-theme-200 dark:hover:text-theme-300 shadow-md shadow-theme-900/10 dark:shadow-theme-900/20 bg-rose-900/80">
+                <a className="italic flex flex-row items-center" href="https://gethomepage.dev/latest/more/homepage-move/" title="Read more..." target="_blank" rel="noreferrer">
+                  <span className="inline-block flex-shrink-0 mr-1 w-3 h-3">
+                    <ResolvedIcon icon="mdi-alert" />
+                  </span>
+                  Homepage has moved!
+                </a>
+                <button type="button" className="ml-2 w-4 h-4 mr-1" title="Hide this notification"
+                    onClick={() => {
+                      setNotificationDismissed(true);
+                      localStorage.setItem(deprecatedNotificationDismissedStorageKey, true);
+                    }}>
+                  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"><path d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"/></svg>
+                </button>
+              </div>
+            }
             {!settings.hideVersion && <Version />}
           </div>
         </div>