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

Refactor Globals.NavigateURL to Interface and Use Dependency Injection #3159

Closed
SkyeHoefling opened this issue Oct 17, 2019 · 4 comments
Closed

Comments

@SkyeHoefling
Copy link
Contributor

Parent: #3153

Description of problem

Refactor all invocations of Globals.NavigateURL to use a new interface INavigationManager and use dependency injection.

Description of solution

Create INavigationManager

public interface INavigationManager
{
    /// <summary>
    /// Gets the URL to the current page.
    /// </summary>
    /// <returns>Formatted URL.</returns>
    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    string NavigateURL();

    /// <summary>
    /// Gets the URL to the given page.
    /// </summary>
    /// <param name="tabID">The tab ID.</param>
    /// <returns>Formatted URL.</returns>
    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    string NavigateURL(int tabID);

    /// <summary>
    /// Gets the URL to the given page.
    /// </summary>
    /// <param name="tabID">The tab ID.</param>
    /// <param name="isSuperTab">if set to <c>true</c> the page is a "super-tab," i.e. a host-level page.</param>
    /// <returns>Formatted URL.</returns>
    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    string NavigateURL(int tabID, bool isSuperTab);

    /// <summary>
    /// Gets the URL to show the control associated with the given control key.
    /// </summary>
    /// <param name="controlKey">The control key, or <see cref="string.Empty"/> or <c>null</c>.</param>
    /// <returns>Formatted URL.</returns>
    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    string NavigateURL(string controlKey);

    /// <summary>
    /// Gets the URL to show the control associated with the given control key.
    /// </summary>
    /// <param name="controlKey">The control key, or <see cref="string.Empty"/> or <c>null</c>.</param>
    /// <param name="additionalParameters">Any additional parameters, in <c>"key=value"</c> format.</param>
    /// <returns>Formatted URL.</returns>
    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    string NavigateURL(string controlKey, params string[] additionalParameters);

    /// <summary>
    /// Gets the URL to show the control associated with the given control key on the given page.
    /// </summary>
    /// <param name="tabID">The tab ID.</param>
    /// <param name="controlKey">The control key, or <see cref="string.Empty"/> or <c>null</c>.</param>
    /// <returns>Formatted URL.</returns>
    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    string NavigateURL(int tabID, string controlKey);

    /// <summary>
    /// Gets the URL to show the given page.
    /// </summary>
    /// <param name="tabID">The tab ID.</param>
    /// <param name="controlKey">The control key, or <see cref="string.Empty"/> or <c>null</c>.</param>
    /// <param name="additionalParameters">Any additional parameters.</param>
    /// <returns>Formatted URL.</returns>
    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    string NavigateURL(int tabID, string controlKey, params string[] additionalParameters);

    /// <summary>
    /// Gets the URL to show the given page.
    /// </summary>
    /// <param name="tabID">The tab ID.</param>
    /// <param name="settings">The portal settings.</param>
    /// <param name="controlKey">The control key, or <see cref="string.Empty"/> or <c>null</c>.</param>
    /// <param name="additionalParameters">Any additional parameters.</param>
    /// <returns>Formatted URL.</returns>
    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    string NavigateURL(int tabID, PortalSettings settings, string controlKey, params string[] additionalParameters);

    /// <summary>
    /// Gets the URL to show the given page.
    /// </summary>
    /// <param name="tabID">The tab ID.</param>
    /// <param name="isSuperTab">if set to <c>true</c> the page is a "super-tab," i.e. a host-level page.</param>
    /// <param name="settings">The portal settings.</param>
    /// <param name="controlKey">The control key, or <see cref="string.Empty"/> or <c>null</c>.</param>
    /// <param name="additionalParameters">Any additional parameters.</param>
    /// <returns>Formatted URL.</returns>
    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    string NavigateURL(int tabID, bool isSuperTab, PortalSettings settings, string controlKey, params string[] additionalParameters);

    /// <summary>
    /// Gets the URL to show the given page.
    /// </summary>
    /// <param name="tabID">The tab ID.</param>
    /// <param name="isSuperTab">if set to <c>true</c> the page is a "super-tab," i.e. a host-level page.</param>
    /// <param name="settings">The portal settings.</param>
    /// <param name="controlKey">The control key, or <see cref="string.Empty"/> or <c>null</c>.</param>
    /// <param name="language">The language code.</param>
    /// <param name="additionalParameters">Any additional parameters.</param>
    /// <returns>Formatted URL.</returns>
    string NavigateURL(int tabID, bool isSuperTab, PortalSettings settings, string controlKey, string language, params string[] additionalParameters);

    /// <summary>
    /// Gets the URL to show the given page.
    /// </summary>
    /// <param name="tabID">The tab ID.</param>
    /// <param name="isSuperTab">if set to <c>true</c> the page is a "super-tab," i.e. a host-level page.</param>
    /// <param name="settings">The portal settings.</param>
    /// <param name="controlKey">The control key, or <see cref="string.Empty"/> or <c>null</c>.</param>
    /// <param name="language">The language code.</param>
    /// <param name="pageName">The page name to pass to <see cref="FriendlyUrl(DotNetNuke.Entities.Tabs.TabInfo,string,string)"/>.</param>
    /// <param name="additionalParameters">Any additional parameters.</param>
    /// <returns>Formatted url.</returns>
    string NavigateURL(int tabID, bool isSuperTab, PortalSettings settings, string controlKey, string language, string pageName, params string[] additionalParameters);
}

Once we create the interface we should mark all related Globals.NavigateURL() methods as deprecated for removal in v11.0

Description of alternatives considered

N/A

Screenshots

N/A

Additional context

N/A

Affected browser

N/A

@bdukes
Copy link
Contributor

bdukes commented Oct 17, 2019

I like the idea of introducing INavigationManager. What's the thinking behind marking the simpler overloads with [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]? Are we trying to avoid people using navigationManager(tabId: 100)?

@SkyeHoefling
Copy link
Contributor Author

I copied that attribute over from the Globals.cs to limit impact

@valadas
Copy link
Contributor

valadas commented Oct 28, 2019

I think this is good to close now right? If not feel free to reopen or comment...

@valadas valadas closed this as completed Oct 28, 2019
@SkyeHoefling
Copy link
Contributor Author

This is merged, no need to keep this open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants