Skip to content

Commit

Permalink
Merge branch 'main' into refactor--replace-AltinnConfirmDialog-with-s…
Browse files Browse the repository at this point in the history
…tudio-components
  • Loading branch information
framitdavid authored Dec 9, 2024
2 parents bb561d4 + 2ab780b commit 2cb7ddf
Show file tree
Hide file tree
Showing 174 changed files with 2,887 additions and 5,660 deletions.
49 changes: 49 additions & 0 deletions .github/ISSUE_TEMPLATE/user_story.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: User Story 😃
description: Create a new user story
labels: ["kind/user-story", "status/draft"]
body:
- type: markdown
attributes:
value: |
* Please make sure this user story hasn't been already submitted by someone by looking through other open/closed user stories.
* Consider the [INVEST](https://www.pivotaltracker.com/blog/how-to-invest-in-your-user-stories) qualities when writing the story
- type: textarea
id: description
attributes:
label: Description
description: Give us a brief WHO, WHAT, and WHY of this user story.
value: |
As a [persona], I want to [do something] so that [I can achieve a goal].
validations:
required: true

- type: textarea
id: design
attributes:
label: Design - Screenshots and Figma links
description: Add screenshots where relevant, and always link to the Figma design if available.

- type: textarea
id: additional-information
attributes:
label: Additional Information
description: Add more details as needed, like links, open questions, etc.

- type: textarea
id: tasks
attributes:
label: Tasks
description: Add tasks to be done as part of this story.

- type: textarea
id: acceptance-criterias
attributes:
label: Acceptance Criterias
description: Define the acceptance criterias that this user story should testet against

- type: markdown
attributes:
value: |
* Check the [Definition of Ready](https://docs.altinn.studio/community/devops/definition-of-ready/) if you need hints on what to include.
* Remember to add the correct labels (status/*, org/*, ...)
2 changes: 1 addition & 1 deletion .github/workflows/run-playwright-resourceadm-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ jobs:
if: failure()
with:
name: playwright-resourceadm-screenshots
path: frontend/testing/playwright/test-results
path: frontend/resourceadm/testing/playwright/test-results
2 changes: 1 addition & 1 deletion backend/Migrations.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ENV OidcLoginSettings__ClientSecret=dummyRequired

RUN dotnet ef migrations script --project src/Designer/Designer.csproj -o /app/migrations.sql

FROM alpine:3.20.3 AS final
FROM alpine:3.21.0 AS final
COPY --from=build /app/migrations.sql migrations.sql
RUN apk --no-cache add postgresql-client

Expand Down
2 changes: 1 addition & 1 deletion backend/packagegroups/NuGet.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReference Update="ini-parser-netstandard" Version="2.5.2" />
<PackageReference Update="JWTCookieAuthentication" Version="4.0.1" />
<!-- Do not upgrade this package unless extensively tested-->
<PackageReference Update="LibGit2Sharp" Version="0.30.0" />
<PackageReference Update="LibGit2Sharp" Version="0.31.0" />
<PackageReference Update="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageReference Update="Microsoft.ApplicationInsights.Kubernetes" Version="7.0.0" />
<PackageReference Update="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
Expand Down
24 changes: 16 additions & 8 deletions backend/src/Designer/Controllers/ResourceAdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Altinn.Studio.Designer.ModelBinding.Constants;
using Altinn.Studio.Designer.Models;
using Altinn.Studio.Designer.Services.Interfaces;
using Altinn.Studio.Designer.Services.Models;
using Altinn.Studio.Designer.TypedHttpClients.ResourceRegistryOptions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -35,7 +34,6 @@ public class ResourceAdminController : ControllerBase
private readonly CacheSettings _cacheSettings;
private readonly IOrgService _orgService;
private readonly IResourceRegistry _resourceRegistry;
private readonly IEnvironmentsService _environmentsService;

public ResourceAdminController(IGitea gitea, IRepository repository, IResourceRegistryOptions resourceRegistryOptions, IMemoryCache memoryCache, IOptions<CacheSettings> cacheSettings, IOrgService orgService, IResourceRegistry resourceRegistry, IEnvironmentsService environmentsService)
{
Expand All @@ -46,7 +44,6 @@ public ResourceAdminController(IGitea gitea, IRepository repository, IResourceRe
_cacheSettings = cacheSettings.Value;
_orgService = orgService;
_resourceRegistry = resourceRegistry;
_environmentsService = environmentsService;
}

[HttpPost]
Expand Down Expand Up @@ -176,7 +173,7 @@ public async Task<ActionResult<List<ListviewServiceResource>>> GetRepositoryReso

if (includeEnvResources)
{
IEnumerable<string> environments = await GetEnvironmentsForOrg(org);
IEnumerable<string> environments = GetEnvironmentsForOrg(org);
foreach (string environment in environments)
{
string cacheKey = $"resourcelist_${environment}";
Expand Down Expand Up @@ -242,7 +239,7 @@ public async Task<ActionResult<ServiceResourceStatus>> GetPublishStatusById(stri
PublishedVersions = []
};

IEnumerable<string> environments = await GetEnvironmentsForOrg(org);
IEnumerable<string> environments = GetEnvironmentsForOrg(org);
foreach (string envir in environments)
{
resourceStatus.PublishedVersions.Add(await AddEnvironmentResourceStatus(envir, id));
Expand Down Expand Up @@ -336,6 +333,13 @@ public async Task<ActionResult> ImportResource(string org, string serviceCode, i
[Route("designer/api/{org}/resources/altinn2/delegationcount/{serviceCode}/{serviceEdition}/{env}")]
public async Task<ActionResult> GetDelegationCount(string org, string serviceCode, int serviceEdition, string env)
{
List<ServiceResource> allResources = await _resourceRegistry.GetResourceList(env.ToLower(), true);
bool serviceExists = allResources.Any(x => x.Identifier.Equals($"se_{serviceCode}_{serviceEdition}"));
if (!serviceExists)
{
return new NotFoundResult();
}

ServiceResource resource = await _resourceRegistry.GetServiceResourceFromService(serviceCode, serviceEdition, env.ToLower());
if (!IsServiceOwner(resource, org))
{
Expand Down Expand Up @@ -648,10 +652,14 @@ private string GetRepositoryName(string org)
return string.Format("{0}-resources", org);
}

private async Task<IEnumerable<string>> GetEnvironmentsForOrg(string org)
private List<string> GetEnvironmentsForOrg(string org)
{
IEnumerable<EnvironmentModel> environments = await _environmentsService.GetOrganizationEnvironments(org);
return environments.Select(environment => environment.Name == "production" ? "prod" : environment.Name);
List<string> environmentsForOrg = ["prod", "tt02"];
if (OrgUtil.IsTestEnv(org))
{
environmentsForOrg.AddRange(["at22", "at23", "at24", "yt01"]);
}
return environmentsForOrg;
}
}
}
29 changes: 16 additions & 13 deletions backend/src/Designer/Helpers/PackageVersionHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Xml.XPath;
using NuGet.Versioning;
Expand All @@ -7,27 +8,29 @@ namespace Altinn.Studio.Designer.Helpers
{
public static class PackageVersionHelper
{
public static bool TryGetPackageVersionFromCsprojFile(string csprojFilePath, string packageName, out SemanticVersion version)
public static bool TryGetPackageVersionFromCsprojFile(string csprojFilePath, IReadOnlyList<string> packageNames, out SemanticVersion version)
{
version = null;
var doc = XDocument.Load(csprojFilePath);
var packageReferences = doc.XPathSelectElements("//PackageReference")
.Where(element => element.Attribute("Include")?.Value == packageName).ToList();
.Where(element => packageNames.Contains(element.Attribute("Include")?.Value));

if (packageReferences.Count != 1)
foreach (var packageReference in packageReferences)
{
return false;
}

var packageReference = packageReferences.First();
string versionString = packageReference.Attribute("Version")?.Value;
if (string.IsNullOrEmpty(versionString))
{
continue;
}

string versionString = packageReference.Attribute("Version")?.Value;
if (string.IsNullOrEmpty(versionString))
{
return false;
if (SemanticVersion.TryParse(versionString, out version))
{
return true;
}
}

return SemanticVersion.TryParse(versionString, out version);
version = default;
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,11 @@ public SemanticVersion GetAppLibVersion(AltinnRepoEditingContext altinnRepoEditi

var csprojFiles = altinnAppGitRepository.FindFiles(new[] { "*.csproj" });

string[] packageNames = ["Altinn.App.Api", "Altinn.App.Api.Experimental"];

foreach (string csprojFile in csprojFiles)
{
if (PackageVersionHelper.TryGetPackageVersionFromCsprojFile(csprojFile, "Altinn.App.Api",
if (PackageVersionHelper.TryGetPackageVersionFromCsprojFile(csprojFile, packageNames,
out SemanticVersion version))
{
return version;
Expand Down
16 changes: 11 additions & 5 deletions backend/tests/Designer.Tests/Helpers/PackageVersionHelperTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.Linq;
using Altinn.Studio.Designer.Helpers;
using DotNet.Testcontainers.Builders;
using FluentAssertions;
Expand All @@ -15,13 +16,18 @@ public void TryGetPackageVersionFromCsprojFile_GivenValidCsprojFile_ReturnsTrue(
{
string testTemplateCsProjPath = Path.Combine(CommonDirectoryPath.GetSolutionDirectory().DirectoryPath, "..", "testdata", "AppTemplates", "AspNet", "App", "App.csproj");

bool result = PackageVersionHelper.TryGetPackageVersionFromCsprojFile(testTemplateCsProjPath, packageName, out var version);
string[] packages = [packageName, $"{packageName}.Experimental"];
string[][] inputs = [packages, packages.Reverse().ToArray()];
foreach (var input in inputs)
{
bool result = PackageVersionHelper.TryGetPackageVersionFromCsprojFile(testTemplateCsProjPath, input, out var version);

result.Should().Be(expectedResult);
result.Should().Be(expectedResult);

if (result)
{
version.ToString().Should().Be(expectedVersion);
if (result)
{
version.ToString().Should().Be(expectedVersion);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mockAppMetadata, mockDataTypeId } from '../../../../../test/applicationMetadataMock';
import { extractDataTypeNamesFromAppMetadata } from './validationUtils';
import { extractDataTypeNamesFromAppMetadata, findFileNameError } from './validationUtils';

describe('extractDataTypeNamesFromAppMetadata', () => {
it('should extract data type names when application metadata is provided', () => {
Expand All @@ -21,3 +21,23 @@ describe('extractDataTypeNamesFromAppMetadata', () => {
expect(dataTypeNames).toEqual([]);
});
});

describe('findFileNameError', () => {
it('should validate name as invalid if name does not match regEx', () => {
const fileName = 'æ';
const validationResult = findFileNameError(fileName, mockAppMetadata);
expect(validationResult).toEqual('invalidFileName');
});

it('should validate name as invalid if name exists in appMetadata', () => {
const fileName = mockAppMetadata.dataTypes[0].id;
const validationResult = findFileNameError(fileName, mockAppMetadata);
expect(validationResult).toEqual('fileExists');
});

it('should validate name as valid if appMetadata is undefined', () => {
const fileName = 'fileName';
const validationResult = findFileNameError(fileName, undefined);
expect(validationResult).toEqual(null);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const isNameFormatValid = (fileNameWithoutExtension: string): boolean => {
const doesFileExistInMetadata = (
appMetadata: ApplicationMetadata,
fileNameWithoutExtension: string,
): boolean => appMetadata.dataTypes?.some((dataType) => dataType.id === fileNameWithoutExtension);
): boolean => appMetadata?.dataTypes?.some((dataType) => dataType.id === fileNameWithoutExtension);

export const extractDataTypeNamesFromAppMetadata = (
appMetadata?: ApplicationMetadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import React, { forwardRef, useCallback, useImperativeHandle, useRef, useState }
import classes from './SettingsModal.module.css';
import { CogIcon } from '@studio/icons';
import {
StudioModal,
StudioContentMenu,
type StudioContentMenuButtonTabProps,
StudioModal,
} from '@studio/components';
import type { SettingsModalTabId } from '../../../../../types/SettingsModalTabId';
import { useTranslation } from 'react-i18next';
Expand All @@ -16,7 +16,7 @@ import { SetupTab } from './components/Tabs/SetupTab';
import { type SettingsModalHandle } from '../../../../../types/SettingsModalHandle';
import { useSettingsModalMenuTabConfigs } from './hooks/useSettingsModalMenuTabConfigs';
import { Maskinporten } from './components/Tabs/Maskinporten';
import { shouldDisplayFeature } from 'app-shared/utils/featureToggleUtils';
import { shouldDisplayFeature, FeatureFlag } from 'app-shared/utils/featureToggleUtils';

export const SettingsModal = forwardRef<SettingsModalHandle, {}>(({}, ref): ReactElement => {
const { t } = useTranslation();
Expand Down Expand Up @@ -54,7 +54,7 @@ export const SettingsModal = forwardRef<SettingsModalHandle, {}>(({}, ref): Reac
return <AccessControlTab />;
}
case 'maskinporten': {
return shouldDisplayFeature('maskinporten') ? <Maskinporten /> : null;
return shouldDisplayFeature(FeatureFlag.Maskinporten) ? <Maskinporten /> : null;
}
}
};
Expand Down Expand Up @@ -94,7 +94,7 @@ SettingsModal.displayName = 'SettingsModal';
function filterFeatureFlag(
menuTabConfigs: Array<StudioContentMenuButtonTabProps<SettingsModalTabId>>,
) {
return shouldDisplayFeature('maskinporten')
return shouldDisplayFeature(FeatureFlag.Maskinporten)
? menuTabConfigs
: menuTabConfigs.filter((tab) => tab.tabId !== 'maskinporten');
}
4 changes: 2 additions & 2 deletions frontend/app-development/types/HeaderMenu/HeaderMenuItem.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { type HeaderMenuGroupKey } from 'app-development/enums/HeaderMenuGroupKey';
import { type HeaderMenuItemKey } from 'app-development/enums/HeaderMenuItemKey';
import { type RepositoryType } from 'app-shared/types/global';
import { type SupportedFeatureFlags } from 'app-shared/utils/featureToggleUtils';
import { type FeatureFlag } from 'app-shared/utils/featureToggleUtils';

export interface HeaderMenuItem {
key: HeaderMenuItemKey;
link: string;
icon?: React.FC<React.SVGProps<SVGSVGElement>>;
repositoryTypes: RepositoryType[];
featureFlagName?: SupportedFeatureFlags;
featureFlagName?: FeatureFlag;
isBeta?: boolean;
group: HeaderMenuGroupKey;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { RoutePaths } from 'app-development/enums/RoutePaths';
import { DatabaseIcon } from '@studio/icons';
import { HeaderMenuGroupKey } from 'app-development/enums/HeaderMenuGroupKey';
import { typedLocalStorage } from '@studio/pure-functions';
import { shouldDisplayFeature } from 'app-shared/utils/featureToggleUtils';
import { shouldDisplayFeature, FeatureFlag } from 'app-shared/utils/featureToggleUtils';

jest.mock('app-shared/utils/featureToggleUtils');

Expand Down Expand Up @@ -137,7 +137,7 @@ describe('headerMenuUtils', () => {
icon: DatabaseIcon,
repositoryTypes: [RepositoryType.App, RepositoryType.DataModels],
group: HeaderMenuGroupKey.Tools,
featureFlagName: 'shouldOverrideAppLibCheck',
featureFlagName: FeatureFlag.ShouldOverrideAppLibCheck,
};

expect(filterRoutesByFeatureFlag(menuItem)).toBe(true);
Expand All @@ -152,7 +152,7 @@ describe('headerMenuUtils', () => {
icon: DatabaseIcon,
repositoryTypes: [RepositoryType.App, RepositoryType.DataModels],
group: HeaderMenuGroupKey.Tools,
featureFlagName: 'shouldOverrideAppLibCheck',
featureFlagName: FeatureFlag.ShouldOverrideAppLibCheck,
};

expect(filterRoutesByFeatureFlag(menuItem)).toBe(false);
Expand Down
8 changes: 8 additions & 0 deletions frontend/language/src/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@
"expression.valueType.null": "Ikke satt",
"expression.valueType.number": "Tall",
"expression.valueType.string": "Tekst",
"feature_flags.heading": "Funksjonsflagg",
"form_filler.file_uploader_validation_error_upload": "Noe gikk galt da filen skulle lastes opp, prøv igjen senere.",
"general.action": "Handling",
"general.actions": "Handlinger",
Expand Down Expand Up @@ -1557,6 +1558,10 @@
"ux_editor.modal_header_type_helper": "Velg titteltype",
"ux_editor.modal_new_option": "Legg til alternativ",
"ux_editor.modal_properties_add_radio_button_options": "Hvordan vil du legge til radioknapper?",
"ux_editor.modal_properties_code_list": "Velg fra biblioteket",
"ux_editor.modal_properties_code_list_alert_title": "Du redigerer nå en kodeliste i biblioteket.",
"ux_editor.modal_properties_code_list_button_title_library": "Kodeliste fra biblioteket",
"ux_editor.modal_properties_code_list_button_title_manual": "Kodeliste på komponenten",
"ux_editor.modal_properties_code_list_custom_list": "Egendefinert kodeliste",
"ux_editor.modal_properties_code_list_filename_error": "Filnavnet er ugyldig. Du kan bruke tall, understrek, punktum, bindestrek, og store/små bokstaver fra det norske alfabetet. Filnavnet må starte med en engelsk bokstav.",
"ux_editor.modal_properties_code_list_helper": "Velg kodeliste",
Expand Down Expand Up @@ -1713,11 +1718,14 @@
"ux_editor.options.code_list_referenceId.description": "Her kan du legge til en referanse-ID til en dynamisk kodeliste som er satt opp i koden.",
"ux_editor.options.code_list_referenceId.description_details": "Du bruker dynamiske kodelister for å tilpasse alternativer for brukerne. Det kan for eksempel være tilpasninger ut fra geografisk plassering, eller valg brukeren gjør tidligere i skjemaet.",
"ux_editor.options.multiple": "{{value}} alternativer",
"ux_editor.options.option_edit_text": "Rediger kodeliste",
"ux_editor.options.option_remove_text": "Fjern valgt kodeliste",
"ux_editor.options.section_heading": "Valg for kodelister",
"ux_editor.options.single": "{{value}} alternativ",
"ux_editor.options.tab_code_list": "Velg kodeliste",
"ux_editor.options.tab_manual": "Sett opp egne alternativer",
"ux_editor.options.tab_referenceId": "Angi referanse-ID",
"ux_editor.options.upload_title": "Last opp egen kodeliste",
"ux_editor.page": "Side",
"ux_editor.page_config_pdf_abort_converting_page_to_pdf": "Avbryt å gjøre om siden til PDF",
"ux_editor.page_config_pdf_card_heading": "Siden skal være en PDF",
Expand Down
Loading

0 comments on commit 2cb7ddf

Please sign in to comment.