Skip to content

Commit

Permalink
Resourceadm: allow publishing resources and editing access lists in A…
Browse files Browse the repository at this point in the history
…T21 and AT24 (#12781)

* add teams for publish resource and edit access lists for AT21 and AT24

* allow publish resource and edit access lists in AT21 and AT24

* show labels for test environments in import from Altinn 2 modal

* only allow import Altinn 2 service from AT environments if user belongs to ttd organization
  • Loading branch information
mgunnerud authored May 15, 2024
1 parent 847a83b commit 240e2c7
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 16 deletions.
24 changes: 24 additions & 0 deletions development/data/gitea-teams.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
"description": "Tilgang til ressursregister",
"includes_all_repositories": true
},
{
"name": "Resources-Publish-AT21",
"permission": "write",
"description": "Deploy av ressurser i AT21",
"includes_all_repositories": true
},
{
"name": "Resources-Publish-AT22",
"permission": "write",
Expand All @@ -65,12 +71,24 @@
"description": "Deploy av ressurser i AT23",
"includes_all_repositories": true
},
{
"name": "Resources-Publish-AT24",
"permission": "write",
"description": "Deploy av ressurser i AT24",
"includes_all_repositories": true
},
{
"name": "Resources-Publish-TT02",
"permission": "write",
"description": "Deploy av ressurser i TT02",
"includes_all_repositories": true
},
{
"name": "AccessLists-AT21",
"permission": "write",
"description": "Skriving av RRR tilgangslister i AT21",
"includes_all_repositories": true
},
{
"name": "AccessLists-AT22",
"permission": "write",
Expand All @@ -83,6 +101,12 @@
"description": "Skriving av RRR tilgangslister i AT23",
"includes_all_repositories": true
},
{
"name": "AccessLists-AT24",
"permission": "write",
"description": "Skriving av RRR tilgangslister i AT24",
"includes_all_repositories": true
},
{
"name": "AccessLists-TT02",
"permission": "write",
Expand Down
8 changes: 8 additions & 0 deletions development/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ const addUserToSomeTestDepTeams = async (env) => {
'Deploy-AT21',
'Deploy-AT22',
'Resources',
'Resources-Publish-AT21',
'Resources-Publish-AT22',
'Resources-Publish-AT23',
'Resources-Publish-AT24',
'Resources-Publish-TT02',
'AccessLists-AT21',
'AccessLists-AT22',
'AccessLists-AT23',
'AccessLists-AT24',
'AccessLists-TT02',
]) {
const existing = teams.find((t) => t.name === teamName);
Expand All @@ -106,11 +110,15 @@ const addUserToSomeTestDepTeams = async (env) => {
'Deploy-AT21',
'Deploy-AT22',
'Resources',
'Resources-Publish-AT21',
'Resources-Publish-AT22',
'Resources-Publish-AT23',
'Resources-Publish-AT24',
'Resources-Publish-TT02',
'AccessLists-AT21',
'AccessLists-AT22',
'AccessLists-AT23',
'AccessLists-AT24',
'AccessLists-TT02',
]) {
const existing = teams.find((t) => t.name === teamName);
Expand Down
2 changes: 2 additions & 0 deletions frontend/language/src/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -969,8 +969,10 @@
"resourceadm.dashboard_table_row_missing_title": "Mangler tittel på Bokmål",
"resourceadm.dashboard_userdata_error_body": "Vi beklager, men en feil oppstod ved henting av dine brukerdata.",
"resourceadm.dashboard_userdata_error_header": "Feil oppstod ved innlasting av brukerdata",
"resourceadm.deploy_at21_env": "Testmiljø AT21",
"resourceadm.deploy_at22_env": "Testmiljø AT22",
"resourceadm.deploy_at23_env": "Testmiljø AT23",
"resourceadm.deploy_at24_env": "Testmiljø AT24",
"resourceadm.deploy_card_arrow_icon": "Ny versjon for {{env}}",
"resourceadm.deploy_card_publish": "Publiser til {{env}}",
"resourceadm.deploy_deploying": "Publiserer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ const defaultProps: ImportResourceModalProps = {
onClose: mockOnClose,
};

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useParams: () => ({
selectedContext: 'ttd',
}),
}));

describe('ImportResourceModal', () => {
afterEach(jest.clearAllMocks);

Expand All @@ -45,9 +52,11 @@ describe('ImportResourceModal', () => {
textMock('resourceadm.dashboard_import_modal_select_env'),
);
await user.click(environmentSelect);
await user.click(screen.getByRole('option', { name: 'AT21' }));
await user.click(screen.getByRole('option', { name: textMock('resourceadm.deploy_at21_env') }));

await waitFor(() => expect(environmentSelect).toHaveValue('AT21'));
await waitFor(() =>
expect(environmentSelect).toHaveValue(textMock('resourceadm.deploy_at21_env')),
);
expect(importButton).toHaveAttribute('aria-disabled', 'true');

// wait for the second combobox to appear, instead of waiting for the spinner to disappear.
Expand Down Expand Up @@ -92,7 +101,7 @@ describe('ImportResourceModal', () => {
textMock('resourceadm.dashboard_import_modal_select_env'),
);
await user.click(environmentSelect);
await user.click(screen.getByRole('option', { name: 'AT21' }));
await user.click(screen.getByRole('option', { name: textMock('resourceadm.deploy_at21_env') }));

// wait for the second combobox to appear, instead of waiting for the spinner to disappear.
// (sometimes the spinner disappears) too quick and the test will fail
Expand All @@ -110,7 +119,7 @@ describe('ImportResourceModal', () => {
await waitFor(() => expect(serviceSelect).toHaveValue(mockOption));

await user.click(environmentSelect);
await user.click(screen.getByRole('option', { name: 'AT22' }));
await user.click(screen.getByRole('option', { name: textMock('resourceadm.deploy_at22_env') }));
await waitFor(() =>
expect(
screen.queryByLabelText(textMock('resourceadm.dashboard_resource_name_and_id_resource_id')),
Expand All @@ -126,7 +135,7 @@ describe('ImportResourceModal', () => {
textMock('resourceadm.dashboard_import_modal_select_env'),
);
await user.click(environmentSelect);
await user.click(screen.getByRole('option', { name: 'AT21' }));
await user.click(screen.getByRole('option', { name: textMock('resourceadm.deploy_at21_env') }));

// wait for the second combobox to appear, instead of waiting for the spinner to disappear.
// (sometimes the spinner disappears) too quick and the test will fail
Expand Down Expand Up @@ -172,7 +181,7 @@ describe('ImportResourceModal', () => {
textMock('resourceadm.dashboard_import_modal_select_env'),
);
await user.click(environmentSelect);
await user.click(screen.getByRole('option', { name: 'AT21' }));
await user.click(screen.getByRole('option', { name: textMock('resourceadm.deploy_at21_env') }));

// wait for the second combobox to appear, instead of waiting for the spinner to disappear.
// (sometimes the spinner disappears) too quick and the test will fail
Expand Down Expand Up @@ -204,7 +213,7 @@ describe('ImportResourceModal', () => {
textMock('resourceadm.dashboard_import_modal_select_env'),
);
await user.click(environmentSelect);
await user.click(screen.getByRole('option', { name: 'AT21' }));
await user.click(screen.getByRole('option', { name: textMock('resourceadm.deploy_at21_env') }));

// wait for the second combobox to appear, instead of waiting for the spinner to disappear.
// (sometimes the spinner disappears) too quick and the test will fail
Expand Down Expand Up @@ -236,7 +245,7 @@ describe('ImportResourceModal', () => {
textMock('resourceadm.dashboard_import_modal_select_env'),
);
await user.click(environmentSelect);
await user.click(screen.getByRole('option', { name: 'AT21' }));
await user.click(screen.getByRole('option', { name: textMock('resourceadm.deploy_at21_env') }));

// wait for the second combobox to appear, instead of waiting for the spinner to disappear.
// (sometimes the spinner disappears) too quick and the test will fail
Expand Down Expand Up @@ -274,7 +283,7 @@ describe('ImportResourceModal', () => {
textMock('resourceadm.dashboard_import_modal_select_env'),
);
await user.click(environmentSelect);
await user.click(screen.getByRole('option', { name: 'AT21' }));
await user.click(screen.getByRole('option', { name: textMock('resourceadm.deploy_at21_env') }));

// wait for the second combobox to appear, instead of waiting for the spinner to disappear.
// (sometimes the spinner disappears) too quick and the test will fail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import { ServerCodes } from 'app-shared/enums/ServerCodes';
import { useUrlParams } from '../../hooks/useSelectedContext';
import { StudioButton } from '@studio/components';
import { formatIdString } from '../../utils/stringUtils';
import { getResourceIdentifierErrorMessage } from '../../utils/resourceUtils';

const environmentOptions = ['AT21', 'AT22', 'AT23', 'AT24', 'TT02', 'PROD'];
import {
getAvailableEnvironments,
getResourceIdentifierErrorMessage,
} from '../../utils/resourceUtils';

export type ImportResourceModalProps = {
isOpen: boolean;
Expand Down Expand Up @@ -60,6 +61,9 @@ export const ImportResourceModal = ({
const idErrorMessage = getResourceIdentifierErrorMessage(id, resourceIdExists);
const hasValidValues =
selectedEnv && selectedService && id.length >= 4 && !idErrorMessage && !isImportingResource;

const environmentOptions = getAvailableEnvironments(selectedContext);

/**
* Reset fields on close
*/
Expand Down Expand Up @@ -113,8 +117,8 @@ export const ImportResourceModal = ({
}}
>
{environmentOptions.map((env) => (
<Combobox.Option key={env} value={env}>
{env}
<Combobox.Option key={env.id} value={env.id}>
{t(env.label)}
</Combobox.Option>
))}
</Combobox>
Expand Down
19 changes: 17 additions & 2 deletions frontend/resourceadm/utils/resourceUtils/resourceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const availableForTypeMap: Record<ResourceAvailableForTypeOption, string>
SelfRegisteredUser: 'resourceadm.about_resource_available_for_type_self_registered',
};

export type EnvId = 'tt02' | 'prod' | 'at22' | 'at23';
export type EnvId = 'tt02' | 'prod' | 'at21' | 'at22' | 'at23' | 'at24';
export type EnvType = 'test' | 'prod';
export type Environment = {
id: EnvId;
Expand All @@ -52,6 +52,11 @@ export type Environment = {
};

const environments: Record<EnvId, Environment> = {
['at21']: {
id: 'at21' as EnvId,
label: 'resourceadm.deploy_at21_env',
envType: 'test' as EnvType,
},
['at22']: {
id: 'at22' as EnvId,
label: 'resourceadm.deploy_at22_env',
Expand All @@ -62,6 +67,11 @@ const environments: Record<EnvId, Environment> = {
label: 'resourceadm.deploy_at23_env',
envType: 'test' as EnvType,
},
['at24']: {
id: 'at24' as EnvId,
label: 'resourceadm.deploy_at24_env',
envType: 'test' as EnvType,
},
['tt02']: {
id: 'tt02' as EnvId,
label: 'resourceadm.deploy_test_env',
Expand All @@ -77,7 +87,12 @@ const environments: Record<EnvId, Environment> = {
export const getAvailableEnvironments = (org: string): Environment[] => {
const availableEnvs = [environments['tt02'], environments['prod']];
if (org === 'ttd') {
availableEnvs.push(environments['at22'], environments['at23']);
availableEnvs.push(
environments['at21'],
environments['at22'],
environments['at23'],
environments['at24'],
);
}
return availableEnvs;
};
Expand Down

0 comments on commit 240e2c7

Please sign in to comment.