{t('resourceadm.listadmin_lists_in', {
- environment: t(
- getAvailableEnvironments(selectedContext).find(
- (listEnv) => listEnv.id === selectedEnv,
- ).label,
- ),
+ environment: t(getEnvLabel(selectedEnv as EnvId)),
})}
{envListData.pages.map((list) => {
diff --git a/frontend/resourceadm/pages/MigrationPage/MigrationPage.tsx b/frontend/resourceadm/pages/MigrationPage/MigrationPage.tsx
index 892c1f5258f..560b58a0d0a 100644
--- a/frontend/resourceadm/pages/MigrationPage/MigrationPage.tsx
+++ b/frontend/resourceadm/pages/MigrationPage/MigrationPage.tsx
@@ -19,8 +19,8 @@ import type { NavigationBarPage } from '../../types/NavigationBarPage';
import { useTranslation } from 'react-i18next';
import { useUrlParams } from '../../hooks/useSelectedContext';
import { StudioButton } from '@studio/components';
-import type { EnvId } from '../../utils/resourceUtils/resourceUtils';
-import { getAvailableEnvironments } from '../../utils/resourceUtils/resourceUtils';
+import type { EnvId } from '../../utils/resourceUtils';
+import { getAvailableEnvironments } from '../../utils/resourceUtils';
export type MigrationPageProps = {
navigateToPageWithError: (page: NavigationBarPage) => void;
diff --git a/frontend/resourceadm/pages/ResourcePage/ResourcePage.tsx b/frontend/resourceadm/pages/ResourcePage/ResourcePage.tsx
index 63818ad93a6..363ae6ee18f 100644
--- a/frontend/resourceadm/pages/ResourcePage/ResourcePage.tsx
+++ b/frontend/resourceadm/pages/ResourcePage/ResourcePage.tsx
@@ -28,6 +28,7 @@ import {
} from '@studio/icons';
import { LeftNavigationBar } from 'app-shared/components/LeftNavigationBar';
import { createNavigationTab, deepCompare } from '../../utils/resourceUtils';
+import type { EnvId } from '../../utils/resourceUtils';
import { ResourceAccessLists } from '../../components/ResourceAccessLists';
import { AccessListDetail } from '../../components/AccessListDetails';
import { useGetAccessListQuery } from '../../hooks/queries/useGetAccessListQuery';
@@ -298,7 +299,7 @@ export const ResourcePage = (): React.JSX.Element => {
/>
)}
{currentPage === accessListsPageId && env && !accessListId && (
-
+
)}
{currentPage === accessListsPageId && env && accessList && (
{
const areEqual = deepCompare([], {});
expect(areEqual).toBeFalsy();
});
+
+ describe('getEnvLabel', () => {
+ it('should return label for selected environment when environment exists', () => {
+ const envLabel = getEnvLabel('tt02');
+ expect(envLabel).toEqual('resourceadm.deploy_test_env');
+ });
+
+ it('should return empty label for selected environment when environment with given id does not exist', () => {
+ const envLabel = getEnvLabel('mu01' as EnvId);
+ expect(envLabel).toEqual('');
+ });
+ });
});
diff --git a/frontend/resourceadm/utils/resourceUtils/resourceUtils.ts b/frontend/resourceadm/utils/resourceUtils/resourceUtils.ts
index ed3ca450fd8..5c0da2b5f55 100644
--- a/frontend/resourceadm/utils/resourceUtils/resourceUtils.ts
+++ b/frontend/resourceadm/utils/resourceUtils/resourceUtils.ts
@@ -49,35 +49,40 @@ export type Environment = {
label: string;
envType: EnvType;
};
+
+const environments: Record = {
+ ['at22']: {
+ id: 'at22' as EnvId,
+ label: 'resourceadm.deploy_at22_env',
+ envType: 'test' as EnvType,
+ },
+ ['at23']: {
+ id: 'at23' as EnvId,
+ label: 'resourceadm.deploy_at23_env',
+ envType: 'test' as EnvType,
+ },
+ ['tt02']: {
+ id: 'tt02' as EnvId,
+ label: 'resourceadm.deploy_test_env',
+ envType: 'test' as EnvType,
+ },
+ ['prod']: {
+ id: 'prod' as EnvId,
+ label: 'resourceadm.deploy_prod_env',
+ envType: 'prod' as EnvType,
+ },
+};
+
export const getAvailableEnvironments = (org: string): Environment[] => {
- const availableEnvs = [
- {
- id: 'tt02' as EnvId,
- label: 'resourceadm.deploy_test_env',
- envType: 'test' as EnvType,
- },
- {
- id: 'prod' as EnvId,
- label: 'resourceadm.deploy_prod_env',
- envType: 'prod' as EnvType,
- },
- ];
+ const availableEnvs = [environments['tt02'], environments['prod']];
if (org === 'ttd') {
- availableEnvs.push(
- {
- id: 'at22' as EnvId,
- label: 'resourceadm.deploy_at22_env',
- envType: 'test' as EnvType,
- },
- {
- id: 'at23' as EnvId,
- label: 'resourceadm.deploy_at23_env',
- envType: 'test' as EnvType,
- },
- );
+ availableEnvs.push(environments['at22'], environments['at23']);
}
return availableEnvs;
};
+export const getEnvLabel = (env: EnvId): string => {
+ return environments[env]?.label || '';
+};
/**
* Maps the language key to the text