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

[DAPS-1283] Add Resume Flow For Consent Reconstruct #1327

Closed
wants to merge 19 commits into from

Conversation

AronPerez
Copy link
Collaborator

@AronPerez AronPerez commented Feb 19, 2025

PR Description

This pr:

  • Utilizes sessionStorage
  • Has components independently manage their sessionStorage
  • Adds resumeTransferFlow check to web/static/main.js

Addressesd [Web, UI] Manage Consent Redirect

Tasks

  • - A description of the PR has been provided, and a diagram included if it is a new feature.
  • - Formatter has been run
  • - CHANGELOG comment has been added
  • - Labels have been assigned to the pr
  • - A reviwer has been added
  • - A user has been assigned to work on the pr
  • - If new feature a unit test has been added

Summary by Sourcery

This pull request introduces the ability to resume the transfer flow after a consent redirect. It leverages sessionStorage to persist the state of the transfer dialog and endpoint browser, allowing users to continue their transfer process seamlessly after granting consent. It also adds a check for resumeTransferFlow to web/static/main.js to handle the resumption of the transfer flow.

New Features:

  • Implements a mechanism to resume the transfer flow after a consent redirect, preserving the state of the transfer dialog and endpoint browser using sessionStorage.

Enhancements:

  • The transfer UI manager, endpoint manager, and endpoint browser components now independently manage their state using sessionStorage, allowing the application to restore the UI to its previous state after a redirect or page reload.
  • The endpoint browser now caches its state when consent is required, allowing the application to restore the browser to its previous state after the user grants consent.

@AronPerez AronPerez added Priority: High Highest priority Type: New Feature New or enhanced feature Component: Web UI Relates to web appp user interface labels Feb 19, 2025
Copy link

sourcery-ai bot commented Feb 19, 2025

Reviewer's Guide by Sourcery

This pull request introduces session storage to persist and resume the transfer flow, especially when consent is required. It also refactors the endpoint manager to use a state object and modifies the browse button functionality to support resuming the flow.

Sequence diagram for resuming transfer flow

sequenceDiagram
    participant User
    participant Browser
    participant TransferDialogController

    User->>Browser: Navigates to page after consent
    Browser->>Browser: Checks sessionStorage for 'resumeFlow'
    alt resumeFlow === "true"
        Browser->>Browser: Retrieves 'transferDialogState' from sessionStorage
        Browser->>TransferDialogController: new TransferDialogController(state.mode, state.ids, state.callback)
        TransferDialogController->>TransferDialogController: show()
        TransferDialogController->>Browser: Initializes UI components
        Browser->>User: Displays transfer dialog with previous state
        Browser->>Browser: Removes 'resumeFlow' from sessionStorage
    else resumeFlow !== "true"
        Browser->>User: Normal page load
    end
Loading

Updated class diagram for TransferEndpointManager

classDiagram
    class TransferEndpointManager {
        -controller
        -api
        -dialogs
        +state
        +constructor(controller, services)
        +loadCache()
        +saveCache()
        +handlePathInput(searchToken)
        +searchEndpoint(endpoint, searchToken)
        +updateMatchesList(endpoints)
        +handleSelectedEndpoint(data)
    }
    note for TransferEndpointManager "State object added to manage component state and sessionStorage integration."
Loading

Updated class diagram for TransferUIManager

classDiagram
    class TransferUIManager {
        -api
        -dialogs
        +cachedComponentData
        +inputTimer
        +state
        +constructor(services)
        +loadCache()
        +saveCache()
        +initializeComponents()
        +initializePathInput()
        +initializeBrowseButton()
        +showBrowseDialog(pathInput)
        +getBrowsePath(currentPath)
        +getDefaultPath(endpoint)
        +handleSelectedEndpoint(data)
        +updateEndpointOptions(endpoint)
        +enableStartButton(enable)
        +enableBrowseButton(enable)
        +safelyExecuteUIOperation(operation)
    }
    note for TransferUIManager "Added caching and state management for UI persistence."
Loading

File-Level Changes

Change Details Files
Implements session storage to persist and resume the transfer flow across page reloads or when consent is required.
  • Utilizes sessionStorage to store the state of various components within the transfer dialog.
  • Components independently manage their own sessionStorage to save and load state.
  • Adds a resumeTransferFlow function to web/static/main.js to check for a flag in sessionStorage and resume the flow if it exists.
  • Adds saveCache to TransferUIManager to save the component state to sessionStorage.
  • Adds loadCache to TransferUIManager to load the component state from sessionStorage.
  • Adds saveCache to TransferEndpointManager to save the component state to sessionStorage.
  • Adds loadCache to TransferEndpointManager to load the component state from sessionStorage.
  • Adds saveCache to TransferDialogController to save the component state to sessionStorage.
web/static/components/transfer/transfer-ui-manager.js
web/static/components/transfer/transfer-endpoint-manager.js
web/static/main.js
web/static/components/transfer/transfer-dialog-controller.js
web/static/components/endpoint-browse/index.js
Updates the endpoint manager to use a state object for managing its properties.
  • Replaces individual properties like currentEndpoint, endpointManagerList, currentSearchToken, searchTokenIterator, and initialized with a single state object.
  • Updates references to these properties throughout the TransferEndpointManager class to use the state object.
web/static/components/transfer/transfer-endpoint-manager.js
Modifies the browse button functionality to support resuming the transfer flow after consent is granted.
  • Caches necessary data for view reconstruction when the browse dialog is opened.
  • Saves the state of the endpointManager and the controller to sessionStorage before showing the browse dialog.
  • Introduces a showBrowseDialog method to encapsulate the browse dialog logic.
web/static/components/transfer/transfer-ui-manager.js

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@AronPerez AronPerez force-pushed the feat-DAPS-1283-add-consent-reconstruct branch from a8e334a to 58172e5 Compare February 19, 2025 17:42
@AronPerez AronPerez linked an issue Feb 19, 2025 that may be closed by this pull request
@AronPerez
Copy link
Collaborator Author

@AronPerez
Copy link
Collaborator Author

  1. Iframe time (callback cannot be converted to function fronnsessionStoragedue to CSP). Short term fix, long term need rewrite
  2. Redux - A bit of a lot for something that’s just supporting one feature

@AronPerez AronPerez force-pushed the feat-DAPS-1283-add-consent-reconstruct branch from bc94435 to b3fdd17 Compare March 5, 2025 15:07
@AronPerez AronPerez force-pushed the feat-DAPS-1283-add-consent-reconstruct branch from a76a16a to c755b0a Compare March 7, 2025 05:03
@AronPerez AronPerez requested a review from Copilot March 10, 2025 14:35
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR adds a resume flow for the transfer process after consent redirects by leveraging redux‐persist with sessionStorage. Key changes include:

  • Configuring a Redux store with redux‐persist for transfer state management.
  • Integrating a resume flow in main.js that restores a previous transfer session.
  • Updating multiple transfer components (dialog controller, UI manager, endpoint manager, and endpoint browser) to support independent state management and caching.

Reviewed Changes

File Description
web/static/store/store.js Introduces Redux store setup and persistence with sessionStorage.
web/static/main.js Implements resumeTransferFlow with rehydration and state validation before restoring transfers.
web/static/components/transfer/transfer-dialog-controller.js Adds state saving and clearing within the transfer dialog lifecycle.
web/static/components/transfer/transfer-ui-manager.js Enhances UI state management by syncing with the Redux store.
web/datafed-ws.js Updates session metadata during logout processing.
web/static/dlg_data_new_edit.js Adjusts transfer dialog invocation to pass an explicit TransferMode.
web/static/store/reducers/transfer-reducer.js Defines reducer actions for saving, clearing, and updating transfer-related states.
web/static/store/index.js Provides a simple Redux-like store implementation.
web/static/components/transfer/transfer-endpoint-manager.js Refactors endpoint manager to load and update state from Redux store.
web/static/components/transfer/index.js Updates transfer dialog type annotations with TransferMode.
web/static/components/endpoint-browse/index.js Integrates cached state handling and consent redirect flow improvements.

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

web/static/components/endpoint-browse/index.js:55

  • The use of new Function to reconstruct a callback from a string can introduce security risks if the stored string is tampered with. Consider using a safer serialization/deserialization approach for callbacks.
onSelect: props.onSelect || Function("return " + cachedComponentData.props.onSelect),

// Set resumeFlow flag in sessionStorage
sessionStorage.setItem("resumeFlow", "true");

window.location.reload(consentLink.getAttribute("data-url"));
Copy link
Preview

Copilot AI Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

window.location.reload() does not accept a URL parameter; instead, assign the URL to window.location.href. For example, replace the line with: window.location.href = consentLink.getAttribute("data-url");

Suggested change
window.location.reload(consentLink.getAttribute("data-url"));
window.location.href = consentLink.getAttribute("data-url");

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@AronPerez AronPerez closed this Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Web UI Relates to web appp user interface Priority: High Highest priority Type: New Feature New or enhanced feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Web, UI] Manage Consent Redirect
1 participant