Skip to content

Commit

Permalink
chore: hide pages connected to payment via the env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Raspopov committed Jan 24, 2025
1 parent bc98cc4 commit 4ac4a77
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .env-ui.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ ISSUER_UI_IPFS_GATEWAY_URL=https://ipfs-proxy-cache.privado.id
ISSUER_UI_SCHEMA_EXPLORER_AND_BUILDER_URL=https://tools.privado.id
ISSUER_UI_DISPLAY_METHOD_BUILDER_URL=https://display-method-dev.privado.id
ISSUER_UI_INSECURE=false
ISSUER_UI_BASE_URL=/
ISSUER_UI_BASE_URL=/
ISSUER_UI_PAYMENT_PAGES_ENABLED=false
4 changes: 3 additions & 1 deletion ui/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ VITE_IPFS_GATEWAY_URL=https://ipfs-proxy-cache.privado.id
VITE_SCHEMA_EXPLORER_AND_BUILDER_URL=https://tools.privado.id
VITE_DISPLAY_METHOD_BUILDER_URL=https://display-method-dev.privado.id

VITE_BASE_URL=/
VITE_BASE_URL=/

VITE_PAYMENT_PAGES_ENABLED=false
1 change: 1 addition & 0 deletions ui/scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ echo "VITE_IPFS_GATEWAY_URL=$ISSUER_UI_IPFS_GATEWAY_URL" >> $ENV_FILENAME
echo "VITE_SCHEMA_EXPLORER_AND_BUILDER_URL=$ISSUER_UI_SCHEMA_EXPLORER_AND_BUILDER_URL" >> $ENV_FILENAME
echo "VITE_DISPLAY_METHOD_BUILDER_URL=$ISSUER_UI_DISPLAY_METHOD_BUILDER_URL" >> $ENV_FILENAME
echo "VITE_BASE_URL"=$ISSUER_UI_BASE_URL >> $ENV_FILENAME
echo "VITE_PAYMENT_PAGES_ENABLED"=$ISSUER_UI_PAYMENT_PAGES_ENABLED >> $ENV_FILENAME

# Build app
cd /app && npm run build
Expand Down
4 changes: 4 additions & 0 deletions ui/src/adapters/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type EnvInput = {
VITE_IPFS_GATEWAY_URL: string;
VITE_ISSUER_LOGO?: string;
VITE_ISSUER_NAME: string;
VITE_PAYMENT_PAGES_ENABLED?: string;
VITE_SCHEMA_EXPLORER_AND_BUILDER_URL?: string;
VITE_WARNING_MESSAGE?: string;
};
Expand All @@ -30,6 +31,7 @@ export const envParser = getStrictParser<EnvInput, Env>()(
VITE_IPFS_GATEWAY_URL: z.string().url(),
VITE_ISSUER_LOGO: z.string().optional(),
VITE_ISSUER_NAME: z.string().min(1),
VITE_PAYMENT_PAGES_ENABLED: z.string().optional(),
VITE_SCHEMA_EXPLORER_AND_BUILDER_URL: z
.union([z.string().url(), z.literal("")])
.transform((value) => value || undefined)
Expand All @@ -47,6 +49,7 @@ export const envParser = getStrictParser<EnvInput, Env>()(
VITE_IPFS_GATEWAY_URL,
VITE_ISSUER_LOGO,
VITE_ISSUER_NAME,
VITE_PAYMENT_PAGES_ENABLED,
VITE_SCHEMA_EXPLORER_AND_BUILDER_URL,
VITE_WARNING_MESSAGE,
}): Env => ({
Expand All @@ -63,6 +66,7 @@ export const envParser = getStrictParser<EnvInput, Env>()(
logo: VITE_ISSUER_LOGO || IMAGE_PLACEHOLDER_PATH,
name: VITE_ISSUER_NAME,
},
paymentPagesEnabled: VITE_PAYMENT_PAGES_ENABLED === "true",
schemaExplorerAndBuilderUrl: VITE_SCHEMA_EXPLORER_AND_BUILDER_URL,
warningMessage: VITE_WARNING_MESSAGE,
})
Expand Down
20 changes: 12 additions & 8 deletions ui/src/components/shared/SiderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function SiderMenu({
isBreakpoint?: boolean;
onClick: () => void;
}) {
const { buildTag } = useEnvContext();
const { buildTag, paymentPagesEnabled } = useEnvContext();
const { status } = useIssuerStateContext();

const { pathname } = useLocation();
Expand Down Expand Up @@ -208,13 +208,17 @@ export function SiderMenu({
onClick: () => onMenuClick(keysPath),
title: "",
},
{
icon: <IconPaymentOptions />,
key: paymentOptionsPath,
label: PAYMENT_OPTIONS,
onClick: () => onMenuClick(paymentOptionsPath),
title: "",
},
...(paymentPagesEnabled
? [
{
icon: <IconPaymentOptions />,
key: paymentOptionsPath,
label: PAYMENT_OPTIONS,
onClick: () => onMenuClick(paymentOptionsPath),
title: "",
},
]
: []),
]}
selectedKeys={getSelectedKey()}
style={{ marginTop: 16 }}
Expand Down
1 change: 1 addition & 0 deletions ui/src/contexts/Env.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const defaultEnvContext: Env = {
logo: "",
name: "",
},
paymentPagesEnabled: false,
};

const EnvContext = createContext(defaultEnvContext);
Expand Down
1 change: 1 addition & 0 deletions ui/src/domain/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type Env = {
logo: string;
name: string;
};
paymentPagesEnabled: boolean;
schemaExplorerAndBuilderUrl?: string;
warningMessage?: string;
};

0 comments on commit 4ac4a77

Please sign in to comment.