Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[N/A] disables analysis routes when EUDR env var is enabled #1166

Merged
merged 1 commit into from
Apr 17, 2024
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/testing-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
name: Running client tests
runs-on: ubuntu-22.04
timeout-minutes: 30
if: ${{ github.ref_name != 'test' }}
strategy:
fail-fast: false
defaults:
Expand Down
42 changes: 29 additions & 13 deletions client/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,46 @@ const nextConfig = {
reactStrictMode: false,
redirects() {
return [
{
source: '/',
destination: '/analysis/map',
permanent: false,
},
{
source: '/analysis',
destination: '/analysis/map',
permanent: false,
},
{
source: '/auth/signup',
destination: '/auth/signin',
permanent: false,
},
...(!env.NEXT_PUBLIC_ENABLE_EUDR
...(env.NEXT_PUBLIC_ENABLE_EUDR
? [
{
source: '/',
destination: '/eudr',
permanent: false,
},
{
source: '/analysis',
destination: '/eudr',
permanent: false,
},
{
source: '/analysis/map',
destination: '/eudr',
permanent: false,
},
]
: [
{
source: '/',
destination: '/analysis/map',
permanent: false,
},
{
source: '/analysis',
destination: '/analysis/map',
permanent: false,
},
{
source: '/eudr',
destination: '/analysis/map',
permanent: false,
},
]
: []),
]),
];
},
};
Expand Down
4 changes: 3 additions & 1 deletion client/src/env.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { createEnv } from '@t3-oss/env-nextjs';
import { z } from 'zod';

const castToBoolean = z.preprocess((/** @type {string} */ val) => val === 'true', z.boolean());

export const env = createEnv({
shared: {
NODE_ENV: z.enum(['development', 'production', 'test']),
Expand Down Expand Up @@ -28,7 +30,7 @@ export const env = createEnv({
// ? URL (including protocol) of the API
NEXT_PUBLIC_API_URL: z.string().url(),
// ? enables access to EUDR page
NEXT_PUBLIC_ENABLE_EUDR: z.coerce.boolean().optional().default(false),
NEXT_PUBLIC_ENABLE_EUDR: castToBoolean.default(false),
NEXT_PUBLIC_PLANET_API_KEY: z.string().default('PLAK6679039df83f414faf798ba4ad4530db'),
NEXT_PUBLIC_CARTO_FOREST_ACCESS_TOKEN: z
.string()
Expand Down
10 changes: 2 additions & 8 deletions client/src/layouts/application/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ const ApplicationLayout: React.FC<React.PropsWithChildren> = ({ children }) => {
default: CollectionIconOutline,
active: CollectionIconSolid,
},
disabled: env.NEXT_PUBLIC_ENABLE_EUDR,
},
{
name: 'Analysis',
href: '/analysis',
icon: { default: ChartBarIconOutline, active: ChartBarIconSolid },
disabled: !!(!lastTask || lastTask?.status === 'processing'),
disabled: !!(!lastTask || lastTask?.status === 'processing') || env.NEXT_PUBLIC_ENABLE_EUDR,
},
...(env.NEXT_PUBLIC_ENABLE_EUDR
? [
Expand All @@ -44,13 +45,6 @@ const ApplicationLayout: React.FC<React.PropsWithChildren> = ({ children }) => {
: []),
];

// navigationItems.push({
// name: 'EUDR',
// href: '/eudr',
// icon: { default: ReportSVG, active: ReportSVG },
// disabled: !!(!lastTask || lastTask?.status === 'processing'),
// });

return (
<div className="min-w-screen-lg flex h-screen min-h-[700px] overflow-hidden bg-navy-600">
<div className="flex w-28 shrink-0 grow-0 flex-col">
Expand Down
Loading