Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement logic in messagebox for copying archived instances #355

Closed
11 of 21 tasks
acn-sbuad opened this issue Nov 8, 2021 · 5 comments
Closed
11 of 21 tasks

Implement logic in messagebox for copying archived instances #355

acn-sbuad opened this issue Nov 8, 2021 · 5 comments
Assignees
Labels
kind/feature-request New feature or request kind/user-story Used for issues that describes functionality for our users.

Comments

@acn-sbuad
Copy link
Contributor

acn-sbuad commented Nov 8, 2021

Description

Copying an archived instance should also be supported for Altinn 3 apps. The view should match the view for ReporteeElements in Altinn 2.

The portal button/link should send the user to the app which performs the instantiation based on existing instance. The App already have a POST endpoint that allows for creating a new instance based on an existing instance. It's needs a GET endpoint that can perform the same logic and then do a redirect to the new endpoint.

Endpoint suggestion:
/{org}/{app}/instances/{instanceId}/copy

Development tasks

  • Extend the messagebox instance model with a field for identifying if copy is enabled
    • The MessageBoxInstance model exposed by Storage already have a property AllowNewCopy
  • Implement a GET endpoint in InstanceController in App that can be the entry point for the Copy feature.
    • The logic performs the instantiation of the new instance and redirects the user to the new instance.
    • Any error redirects the user to an error page?
  • Add new property to mapping in InstanceHelper in Storage
    • The value can be set based on the CopyInstanceSettings on the Application model.
    • Use the Enable property to create an authorization request to ensure that the user have the necessary rights to instantiate.
    • The immediate logic doesn't have access to Application. This must be added. Preferably with some sort of caching.
    • The property AllowNewCopy should be set only when requesting a single instance
  • Fix relevant .cshtml files in SBL
    • ArchiveReportingElementInfo.cshtml
  • Fix ArchiveReportingElementInfo.cshtml to use correct endpoint URL.

Testing

An app with the copy archived instance feature already enabled has been deployed to TT02:
https://ttd.apps.tt02.altinn.no/ttd/copy-instance-tester/

The app can be used by any reportee. One possible confusion is that the app has two form filling steps so you need to submit two forms which are identical. The intent was to test the ExcludeDataType feature, but that's not supported as of now. ExcludedDataFields can be tested, but the deployed app has no excluded fields.

To test "make new instance based on existing instance" create a direct URL based on this template:
https://ttd.apps.tt02.altinn.no/ttd/copy-instance-tester/legacy/instances/{partyid}/{instanceGuid}/copy

Acceptance criteria

  • An app with copy disabled will return 400 with appropriate message
  • An instance that hasn't been archived will result in 400 with appropriate message
  • An archived instance from an app with copy enabled will have copy enabled (messagebox)
    • Also requires that the user is allowed to read and instantiate.
    • As of writing this the link from the portal is wrong. Will be hotfixed. You can still click the link. The browser will get a 404, but from here you can easily manipulate the url.
  • The message box panel displays a copy button for instances with copy enabled.
  • Clicking the button generates a new instance based on the archived instance and the user is redirected to the new instance.
  • Only datatypes with a ClassRef and for the first Task in the process is copied
    • This makes it impossible to test ExcludedDataType

Definition of done

Verify that this issue meets DoD (Only for project members) before closing.

  • Documentation is updated (if relevant)
    • Technical documentation (docs.altinn.studio)
    • User documentation (altinn.github.io/docs)
  • QA
  • Manual test is complete (if relevant)
  • Automated test is implemented (if relevant)
  • All tasks in this userstory are closed (i.e. remaining tasks are moved to other user stories or marked obsolete)
@acn-sbuad acn-sbuad added solution/sbl kind/user-story Used for issues that describes functionality for our users. labels Nov 8, 2021
@FinnurO
Copy link

FinnurO commented Jan 4, 2023

Duplicate of Altinn/altinn-studio#1566. Closing issue.

@FinnurO FinnurO closed this as completed Jan 4, 2023
@tjololo
Copy link
Member

tjololo commented Jan 16, 2023

Reopening as this is a task to implement it in the messagebox UI. Altinn/altinn-studio#1566 is the epic containing all steps needed to make copy of archived instance behave like in altinn2

@acn-sbuad
Copy link
Contributor Author

Comments from first round of testing:

  • 404 result code for apps with an old template version when attempting to copy instance directly towards url. Expected I guess.
  • an issue should exists for completing/verifying the functionality related to ExcludedDataType.
  • no acceptance criteria related to documentation. Is this on your To-do list @SandGrainOne ? Or on the apps teams list of things to do?

Waiting to verify logic related to button and link until after SBL hot fix.

@acn-sbuad
Copy link
Contributor Author

Attempting to copy an instance based of a non-existing instanceId result in a 500 error. Should we have any error handling here to control the result code in some way ?

@SandGrainOne
Copy link
Member

Attempting to copy an instance based of a non-existing instanceId result in a 500 error. Should we have any error handling here to control the result code in some way ?

Managed to find out what it is that is going wrong. The InstanceClient in Core creates a PlatformHttpException if the response from Storage is non successful. I've made a PR to handle it slightly better:

Altinn/app-lib-dotnet#236

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature-request New feature or request kind/user-story Used for issues that describes functionality for our users.
Projects
None yet
Development

No branches or pull requests

5 participants