diff --git a/.env b/.env index 4bdf3e6..ea651dc 100644 --- a/.env +++ b/.env @@ -1,5 +1,6 @@ ENABLE_NEW_JSX_TRANSFORM="true" FAST_REFRESH="true" +LOGO_MUST_BE_VISIBLE="true" CLOUD_IDENTIFIER=gcp-us APPLICATION_ID=cldoqtyfj009nzk01wfj8r99o diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fccdd55..9beed82 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: node-version: ${{ matrix.node-version }} - name: Get yarn cache id: yarn-cache - run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + run: echo "::set-output name=dir::$(yarn cache dir)" - uses: actions/cache@v4 with: path: ${{ steps.yarn-cache.outputs.dir }} @@ -32,9 +32,5 @@ jobs: run: yarn install --pure-lockfile - name: Test run: yarn run test - - - name: Load custom application config - run: node node_modules/@commercetools-frontend/application-config/scripts/load-js-module.js ${{ github.workspace }}/custom-application-config.js - - name: Build run: yarn run build diff --git a/custom-application-config.js b/custom-application-config.js index af7c291..f854f4a 100644 --- a/custom-application-config.js +++ b/custom-application-config.js @@ -1,4 +1,5 @@ -import { PERMISSIONS, entryPointUriPath } from './src/constants'; +// eslint-disable-next-line import/extensions +import { PERMISSIONS, entryPointUriPath } from './src/constants.ts'; /** * @type {import('@commercetools-frontend/application-config').ConfigOptions} @@ -36,6 +37,9 @@ const config = { labelAllLocales: [], permissions: [PERMISSIONS.View], }, + additionalEnv: { + logoMustBeVisible: '${env:LOGO_MUST_BE_VISIBLE}', + }, submenuLinks: [ // { // defaultLabel: 'Custom Objects Editor List', diff --git a/src/components/container-list/container-list.tsx b/src/components/container-list/container-list.tsx index 312e862..2346266 100644 --- a/src/components/container-list/container-list.tsx +++ b/src/components/container-list/container-list.tsx @@ -1,4 +1,5 @@ import React, { lazy, ReactNode } from 'react'; +import { useApplicationContext } from '@commercetools-frontend/application-shell-connectors'; import { Link, Switch, useHistory, useRouteMatch } from 'react-router-dom'; import { SuspendedRoute } from '@commercetools-frontend/application-shell'; import { FormattedMessage, useIntl } from 'react-intl'; @@ -25,6 +26,7 @@ import LoadingSpinner from '@commercetools-uikit/loading-spinner'; import { CONTAINER, SORT_OPTIONS } from '../../constants'; import { getErrorMessage } from '../../helpers'; import { useCustomObjectsFetcher } from '../../hooks/use-custom-object-connector/use-custom-object-connector'; +import { Logo } from '../../images/logo'; import { FIELDS } from './constants'; import messages from './messages'; @@ -66,6 +68,12 @@ const ContainerList = () => { order: 'asc', }); + const { environment } = useApplicationContext<{ + logoMustBeVisible?: unknown; + }>(); + const logoMustBeVisible = + String(environment.logoMustBeVisible).toLowerCase() === 'true'; + const { customObjectsPaginatedResult, loading, error, refetch } = useCustomObjectsFetcher({ container: CONTAINER, @@ -185,6 +193,9 @@ const ContainerList = () => { /> ) )} + + {logoMustBeVisible && } + import('../create-custom-object')); const CustomObjectDetails = lazy(() => import('../custom-object-details')); @@ -50,6 +52,12 @@ const CustomObjectsList = () => { const { push } = useHistory(); const { hasContainers, containers } = useContainerContext(); + const { environment } = useApplicationContext<{ + logoMustBeVisible?: unknown; + }>(); + const logoMustBeVisible = + String(environment.logoMustBeVisible).toLowerCase() === 'true'; + const [key, setKey] = useState(''); const { page, perPage } = usePaginationState(); @@ -340,7 +348,11 @@ const CustomObjectsList = () => { /> ) )} + + + {logoMustBeVisible && } + { + return ( + + + + + + + + ); + }; \ No newline at end of file diff --git a/src/routes.tsx b/src/routes.tsx index 127e895..84b1a64 100644 --- a/src/routes.tsx +++ b/src/routes.tsx @@ -6,13 +6,11 @@ import { import { FormattedMessage } from 'react-intl'; import { useIsAuthorized } from '@commercetools-frontend/permissions'; import LockedDiamondSVG from '@commercetools-frontend/assets/images/locked-diamond.svg'; -import React, { ReactNode } from 'react'; +import { ReactNode } from 'react'; import { ContentNotification } from '@commercetools-uikit/notifications'; import LoadingSpinner from '@commercetools-uikit/loading-spinner'; import Spacings from '@commercetools-uikit/spacings'; -import Link from '@commercetools-uikit/link'; import Text from '@commercetools-uikit/text'; -import ariesLabsLogo from './assets/aries-labs-logo.svg'; import ContainerList from './components/container-list'; import CustomObjectsList from './components/custom-objects-list'; import { messages } from './messages'; @@ -98,11 +96,6 @@ const ApplicationRoutes = (_props: ApplicationRoutesProps) => { - - - Aries Labs Logo - - ); }; diff --git a/tsconfig.json b/tsconfig.json index ded508b..0fff807 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,3 +1,9 @@ { - "extends": "@commercetools-frontend/application-config/tsconfig-mc-app.json" + "extends": "@commercetools-frontend/application-config/tsconfig-mc-app.json", + "compilerOptions": { + "typeRoots": ["@types", "@types-extensions", "node_modules/@types"], + // Allow tsc to resolve dependencies of `@types` packages in the way pnpm sets up the `node_modules`. + "preserveSymlinks": false + }, + "include": ["src"] }