Repository: Avaiga/taipy
File: taipy/gui/gui_actions.py (Python)

Code before:
        params: A dictionary of query arguments.
        tab: When navigating to a page that is not a known page, the page is opened in a tab identified by
            *tab* (as in [window.open](https://developer.mozilla.org/en-US/docs/Web/API/Window/open)).<br/>
            The default value creates a new tab for the page (which is equivalent to setting *tab* to "_blank").
        force: When navigating to a known page, the content is refreshed even it the page is already shown.
    """
    if state and isinstance(state._gui, Gui):
        state._gui._navigate(to, params, tab, force)
    else:
        _warn("'navigate()' must be called in the context of a callback.")


def get_user_content_url(
    state: State, path: t.Optional[str] = None, params: t.Optional[t.Dict[str, str]] = None
) -> t.Optional[str]:
    """Get a user content URL.

    This function can be used if you need to deliver dynamic content to your page: you can create
    a path at run-time that, when queried, will deliver some user-defined content defined in the
    *on_user_content* callback (see the description of the `Gui^` class for more information).

    Arguments:
        state (State^): The current user state as received in any callback.
        path: An optional additional path to the URL.
        params: An optional dictionary sent to the *on_user_content* callback.<br/>
            These arguments are added as query arguments to the generated URL and converted into
            strings.

    Returns:
        An URL that, when queried, triggers the *on_user_content* callback.
    """
    if state and isinstance(state._gui, Gui):
        return state._gui._get_user_content_url(path, params)
    _warn("'get_user_content_url()' must be called in the context of a callback.")
    return None


def get_state_id(state: State) -> t.Optional[str]:
    """Get the identifier of a state.

    The state identifier is a string generated by Taipy GUI for a given `State^` that is used
    to serialize callbacks.
    See the
    [User Manual section on Long Running Callbacks](../../../../../userman/gui/callbacks.md#long-running-callbacks)
    for details on when and how this function can be used.

    Arguments:
        state (State^): The current user state as received in any callback.

    Returns:
        A string that uniquely identifies the state. If this value None, it indicates that *state* is not

Review comment (suggestion):
```suggestion
            These arguments are added as query parameters to the generated URL and converted into
```

Code after:
        params: A dictionary of query parameters.
        tab: When navigating to a page that is not a known page, the page is opened in a tab identified by
            *tab* (as in [window.open](https://developer.mozilla.org/en-US/docs/Web/API/Window/open)).<br/>
            The default value creates a new tab for the page (which is equivalent to setting *tab* to "_blank").
        force: When navigating to a known page, the content is refreshed even it the page is already shown.
    """
    if state and isinstance(state._gui, Gui):
        state._gui._navigate(to, params, tab, force)
    else:
        _warn("'navigate()' must be called in the context of a callback.")


def get_user_content_url(
    state: State, path: t.Optional[str] = None, params: t.Optional[t.Dict[str, str]] = None
) -> t.Optional[str]:
    """Get a user content URL.

    This function can be used if you need to deliver dynamic content to your page: you can create
    a path at run-time that, when queried, will deliver some user-defined content defined in the
    *on_user_content* callback (see the description of the `Gui^` class for more information).

    Arguments:
        state (State^): The current user state as received in any callback.
        path: An optional additional path to the URL.
        params: An optional dictionary sent to the *on_user_content* callback.<br/>
            These arguments are added as query parameters to the generated URL and converted into
            strings.

    Returns:
        An URL that, when queried, triggers the *on_user_content* callback.
    """
    if state and isinstance(state._gui, Gui):
        return state._gui._get_user_content_url(path, params)
    _warn("'get_user_content_url()' must be called in the context of a callback.")
    return None


def get_state_id(state: State) -> t.Optional[str]:
    """Get the identifier of a state.

    The state identifier is a string generated by Taipy GUI for a given `State^` that is used
    to serialize callbacks.
    See the
    [User Manual section on Long Running Callbacks](../../../../../userman/gui/callbacks.md#long-running-callbacks)
    for details on when and how this function can be used.

    Arguments:
        state (State^): The current user state as received in any callback.

    Returns:
        A string that uniquely identifies the state. If this value None, it indicates that *state* is not