Skip to content

Commit

Permalink
Merge pull request #485 from zesu22/bug/variable-image
Browse files Browse the repository at this point in the history
[ADDED] util method for env variable boolean check
  • Loading branch information
aranaravi authored Nov 28, 2023
2 parents c278030 + 26756c5 commit e4b68b8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
3 changes: 2 additions & 1 deletion oidc-ui/src/components/Background.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { configurationKeys } from "../constants/clientConstants";
import { getBooleanValue } from "../services/utilService";

export default function Background({
heading,
Expand Down Expand Up @@ -31,7 +32,7 @@ export default function Background({
// check if background logo is needed or not,
// create div according to the environment variable
const backgroundLogoDiv =
process.env.REACT_APP_BACKGROUND_LOGO === "true" ? (
getBooleanValue(process.env.REACT_APP_BACKGROUND_LOGO) ? (
<div className="flex justify-center m-10 lg:mt-20 mb:mt-0 lg:w-1/2 md:w-1/2 md:block sm:w-1/2 sm:block hidden w-5/6 mt-20 mb-10 md:mb-0">
<img
className="background-logo object-contain rtl:scale-x-[-1]"
Expand Down
9 changes: 7 additions & 2 deletions oidc-ui/src/components/Consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { LoadingStates, LoadingStates as states } from "../constants/states";
import FormAction from "./FormAction";
import langConfigService from "./../services/langConfigService";
import ModalPopup from "../common/ModalPopup";
import { getBooleanValue } from "../services/utilService";

export default function Consent({
authService,
Expand Down Expand Up @@ -45,7 +46,11 @@ export default function Consent({
const [timeLeft, setTimeLeft] = useState(null);
const [cancelPopup, setCancelPopup] = useState(false);

const slideToggleClass = process.env.REACT_APP_NO_OUTLINE_TOGGLE === "true" ? "toggle-no-outline" : "toggle-outline";
const slideToggleClass = getBooleanValue(
process.env.REACT_APP_NO_OUTLINE_TOGGLE
)
? "toggle-no-outline"
: "toggle-outline";

const hasAllElement = (mainArray, subArray) =>
subArray.every((ele) => mainArray.includes(ele));
Expand Down Expand Up @@ -402,7 +407,7 @@ export default function Consent({
// check if background logo is needed or not,
// create div according to the environment variable
const backgroundLogoDiv =
process.env.REACT_APP_BACKGROUND_LOGO === "true" ? (
getBooleanValue(process.env.REACT_APP_BACKGROUND_LOGO) ? (
<div className="flex justify-center m-10 lg:mt-20 mb:mt-0 lg:w-1/2 md:w-1/2 md:block sm:w-1/2 sm:block hidden w-5/6 mt-20 mb-10 md:mb-0">
<img
className="background-logo object-contain rtl:scale-x-[-1]"
Expand Down
3 changes: 2 additions & 1 deletion oidc-ui/src/components/EsignetDetails.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useTranslation } from "react-i18next";
import { useEffect, useState } from "react";
import { LoadingStates as states } from "../constants/states";
import { getBooleanValue } from "../services/utilService";

export default function EsignetDetails({ i18nKeyPrefix = "esignetDetails" }) {
const { t } = useTranslation("translation", { keyPrefix: i18nKeyPrefix });
Expand Down Expand Up @@ -30,7 +31,7 @@ export default function EsignetDetails({ i18nKeyPrefix = "esignetDetails" }) {
// check if background logo is needed or not,
// create div according to the environment variable
const backgroundLogoDiv =
process.env.REACT_APP_BACKGROUND_LOGO === "true" ? (
getBooleanValue(process.env.REACT_APP_BACKGROUND_LOGO) ? (
<div className="flex justify-center m-10 lg:mt-20 mb:mt-0 lg:w-1/2 md:w-1/2 md:block sm:w-1/2 sm:block hidden w-5/6 mt-20 mb-10 md:mb-0">
<img
className="background-logo object-contain rtl:scale-x-[-1]"
Expand Down
3 changes: 2 additions & 1 deletion oidc-ui/src/components/Footer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useTranslation } from "react-i18next";
import { getBooleanValue } from "../services/utilService";

export default function Footer({ i18nKeyPrefix = "footer" }) {
const footerCheck = process.env.REACT_APP_FOOTER === "true";
const footerCheck = getBooleanValue(process.env.REACT_APP_FOOTER);

const { t } = useTranslation("translation", {
keyPrefix: i18nKeyPrefix,
Expand Down
3 changes: 2 additions & 1 deletion oidc-ui/src/components/NavHeader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import Select from "react-select";
import { getBooleanValue } from "../services/utilService";

export default function NavHeader({ langOptions, i18nKeyPrefix = "header" }) {
const { t, i18n } = useTranslation("translation", {
Expand All @@ -12,7 +13,7 @@ export default function NavHeader({ langOptions, i18nKeyPrefix = "header" }) {
i18n.changeLanguage(e.value);
};

const removeIndicatorPipe = process.env.REACT_APP_REMOVE_INDICATOR_PIPE === "true";
const removeIndicatorPipe = getBooleanValue(process.env.REACT_APP_REMOVE_INDICATOR_PIPE);

const customStyles = {
control: (base) => ({
Expand Down
8 changes: 8 additions & 0 deletions oidc-ui/src/services/utilService.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const getBooleanValue = (inputValue) => {
if (typeof(inputValue) === 'undefined' || inputValue === null || inputValue === '') {
return false;
}
return /^true$/i.test(inputValue);
}

export { getBooleanValue };

0 comments on commit e4b68b8

Please sign in to comment.