Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions web/components/core/image-picker-popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useEffect, useState, useRef, useCallback } from "react";
// next
import Image from "next/image";
import { useRouter } from "next/router";
import getConfig from "next/config";

// swr
import useSWR from "swr";
Expand All @@ -21,9 +22,9 @@ import { Input, Spinner, PrimaryButton, SecondaryButton } from "components/ui";
// hooks
import useWorkspaceDetails from "hooks/use-workspace-details";

const { publicRuntimeConfig } = getConfig();
const unsplashEnabled =
process.env.NEXT_PUBLIC_UNSPLASH_ENABLED === "true" ||
process.env.NEXT_PUBLIC_UNSPLASH_ENABLED === "1";
publicRuntimeConfig.unsplashEnabled === "true" || publicRuntimeConfig.unsplashEnabled === "1";

const tabOptions = [
{
Expand Down Expand Up @@ -172,7 +173,7 @@ export const ImagePickerPopover: React.FC<Props> = ({
</div>
{images ? (
<div className="grid grid-cols-4 gap-4">
{images.map((image) => (
{Array.from(images).map((image) => (
<div
key={image.id}
className="relative col-span-2 aspect-video md:col-span-1"
Expand Down
7 changes: 7 additions & 0 deletions web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ const nextConfig = {
// this includes files from the monorepo base two directories up
outputFileTracingRoot: path.join(__dirname, "../"),
},
publicRuntimeConfig: {
unsplashEnabled: process.env.NEXT_PUBLIC_UNSPLASH_ENABLED,
},
serverRuntimeConfig: {
// TODO: remove NEXT_PUBLIC_ prefix from env variable
unsplashAccess: process.env.NEXT_PUBLIC_UNSPLASH_ACCESS,
},
};

if (parseInt(process.env.NEXT_PUBLIC_ENABLE_SENTRY || "0")) {
Expand Down
5 changes: 3 additions & 2 deletions web/pages/api/unsplash.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { NextApiRequest, NextApiResponse } from "next";
import getConfig from "next/config";

// TODO: remove NEXT_PUBLIC_ prefix from env variable
const unsplashKey = process.env.NEXT_PUBLIC_UNSPLASH_ACCESS;
const { serverRuntimeConfig } = getConfig();
const unsplashKey = serverRuntimeConfig.unsplashAccess;

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { query, page, per_page = 20 } = req.query;
Expand Down