This repository was archived by the owner on Jul 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Ensure Definitions are opened via Route changes #281
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ import Perspective exposing (Perspective) | |
import Task | ||
import UI.Button as Button | ||
import UI.Icon as Icon | ||
import Workspace.WorkspaceItem as WorkspaceItem exposing (Item, WorkspaceItem(..)) | ||
import Workspace.WorkspaceItem as WorkspaceItem exposing (Item, WorkspaceItem) | ||
import Workspace.WorkspaceItems as WorkspaceItems exposing (WorkspaceItems) | ||
|
||
|
||
|
@@ -55,7 +55,7 @@ init env mRef = | |
|
||
Just ref -> | ||
let | ||
( m, c, _ ) = | ||
( m, c ) = | ||
open env model ref | ||
in | ||
( m, c ) | ||
|
@@ -116,7 +116,7 @@ update env msg ({ workspaceItems } as model) = | |
in | ||
( { model | workspaceItems = nextWorkspaceItems } | ||
, cmd | ||
, openDefinitionsFocusToOutMsg nextWorkspaceItems | ||
, None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (this is the We don't need to change the URL to the focused item after fetching anymore since we are now fetching what was in the URL. |
||
) | ||
|
||
IsDocCropped ref res -> | ||
|
@@ -157,7 +157,7 @@ update env msg ({ workspaceItems } as model) = | |
WorkspaceItemMsg wiMsg -> | ||
case wiMsg of | ||
WorkspaceItem.OpenReference relativeToRef ref -> | ||
openItem env model (Just relativeToRef) ref | ||
openReference env model relativeToRef ref | ||
|
||
WorkspaceItem.Close ref -> | ||
let | ||
|
@@ -218,11 +218,6 @@ type alias WithWorkspaceItems m = | |
{ m | workspaceItems : WorkspaceItems } | ||
|
||
|
||
open : Env -> WithWorkspaceItems m -> Reference -> ( WithWorkspaceItems m, Cmd Msg, OutMsg ) | ||
open env model ref = | ||
openItem env model Nothing ref | ||
|
||
|
||
replaceWorkspaceItemReferencesWithHashOnly : Model -> Model | ||
replaceWorkspaceItemReferencesWithHashOnly model = | ||
let | ||
|
@@ -232,7 +227,29 @@ replaceWorkspaceItemReferencesWithHashOnly model = | |
{ model | workspaceItems = workspaceItems } | ||
|
||
|
||
openItem : Env -> WithWorkspaceItems m -> Maybe Reference -> Reference -> ( WithWorkspaceItems m, Cmd Msg, OutMsg ) | ||
open : Env -> WithWorkspaceItems m -> Reference -> ( WithWorkspaceItems m, Cmd Msg ) | ||
open env model ref = | ||
openItem env model Nothing ref | ||
|
||
|
||
{-| openReference opens a definition relative to another definition. This is | ||
done within Workspace, as opposed to from the outside via a URL change. This | ||
function returns a Focused command for the newly opened reference and as such | ||
changes the URL. | ||
-} | ||
openReference : Env -> WithWorkspaceItems m -> Reference -> Reference -> ( WithWorkspaceItems m, Cmd Msg, OutMsg ) | ||
openReference env model relativeToRef ref = | ||
let | ||
( newModel, cmd ) = | ||
openItem env model (Just relativeToRef) ref | ||
|
||
out = | ||
openDefinitionsFocusToOutMsg newModel.workspaceItems | ||
in | ||
( newModel, cmd, out ) | ||
|
||
|
||
openItem : Env -> WithWorkspaceItems m -> Maybe Reference -> Reference -> ( WithWorkspaceItems m, Cmd Msg ) | ||
openItem env ({ workspaceItems } as model) relativeToRef ref = | ||
-- We don't want to refetch or replace any already open definitions, but we | ||
-- do want to focus and scroll to it | ||
|
@@ -243,7 +260,6 @@ openItem env ({ workspaceItems } as model) relativeToRef ref = | |
in | ||
( { model | workspaceItems = nextWorkspaceItems } | ||
, scrollToDefinition ref | ||
, openDefinitionsFocusToOutMsg nextWorkspaceItems | ||
) | ||
|
||
else | ||
|
@@ -261,24 +277,14 @@ openItem env ({ workspaceItems } as model) relativeToRef ref = | |
in | ||
( { model | workspaceItems = nextWorkspaceItems } | ||
, Cmd.batch [ Api.perform env.apiBasePath (fetchDefinition env.perspective ref), scrollToDefinition ref ] | ||
, openDefinitionsFocusToOutMsg nextWorkspaceItems | ||
) | ||
|
||
|
||
openDefinitionsFocusToOutMsg : WorkspaceItems -> OutMsg | ||
openDefinitionsFocusToOutMsg openDefs = | ||
let | ||
toFocusedOut workspaceItem = | ||
case workspaceItem of | ||
Success ref _ -> | ||
Focused ref | ||
|
||
_ -> | ||
None | ||
in | ||
openDefs | ||
|> WorkspaceItems.focus | ||
|> Maybe.map toFocusedOut | ||
|> WorkspaceItems.focusedReference | ||
|> Maybe.map Focused | ||
|> Maybe.withDefault Emptied | ||
|
||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't attempt to fix route driven perspectives (later effort).