We prepare the data for `PeerSelector` and `BranchSelector` in the
`History` and `Browser` instead of `SourceBrowsingHeader`. This makes
the component APIs overall simpler and allows us to remove
`LoadedSourceBrowsingView`.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
There’s no need for the outer `if branches.length > 0`. We already
disable the dropdown unless `branches.length > 1`.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
We had a regression because of introducing marked-linkify-it, which took
links for CONTRIBUTING.md or HACKING.md as domains of a new page instead
than files to be navigating to.
This commit sets the `fuzzyLink` option for marked-linkify-it to false,
which disables this behavior
Also tests that the browser tree expands itself when navigating to a
file inside a directory
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
We were always calling `replace` and not passing the desired action in
the `navigateInternalOnAnchor`, this was leading to the URL not updating
when e.g. clicking on file URLs in Markdown renders.
By passing the action to the `navigate` fn instead we can also take the
`push` action into account.
Test have been written to guarantee this works
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
For a single commit view the source browsing header (peer selector,
branch selector, commits, contributor count) does not contain meaningful
information. We remove the header and simply show the commit.
See #938.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
We greatly reduce the numbers of properties that need to be passed to
`BranchSelector` and `PeerSelector` by constructing routes in
`SourceBrowsingHeader`. We’ll lift the logic out of
`SourceBrowsingHeader` in a follow-up.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
The `loadProjectRoute` function has become too big too understand. To
address this, we extract and separate the loading for the `tree` and
`history` views. This also gives us the opportunity to simplify some of
the code and parallelize more HTTP requests.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
Based on a new addition to marked, this commits replaces the imported
marked namespaces with a Marked class, that doesn't change when
`marked.use` introduces new options or extensions.
Also changes the naming slighty to use `markdown` as module, so it
sounds more generic.
Reference: https://github.com/markedjs/marked/pull/2831
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
We switch the test for `pathToRoute` from a paramterized test to regular
tests. I had a lot of trouble finding the right properties to change
when a test in this group failed. The line number was not helpful at all
and the test description was burried inside an object.
We also rename `pathToRoute` to `urlToRoute` because the function takes
a `URL` as an argument.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
We switch to a project route type that is just a union. This has the
following advantages
* It’s much easier to construct project routes. Fewer properties are
needed and there are no nested objects.
* We eliminate the implicitly shared properties `path`, `peer`,
`revision` and `route` which only belonged to the tree route.
* The structure of the project route is more regular and thus easier to
understand.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
This improves UX making it easier to find the tab that I'm looking for
when I have multiple tabs open.
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
We simplify some of the choices for `ProjectLoadedView` by reducing the
nesting and removing redundant properties.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
We move the `peer` and `revision` properties from the shared
`ProjectLoadedParams` interface to the `tree` and `history` subroutes
where they are needed.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
We remove the requirement that `LoadedSourceBrowsingView` needs to be
assignable to `ProjectParams["view"]`. This decouples `ProjectRoute` and
`ProjectLoadedRoute` and lets us modify them independently.
I did not use a common `routeParamsView` function because I prefer the
flexibility of being able to modify them independently while this area
of code changes a lot.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
We refactor the code that builds a URL from a project route so that it
is clearer that only the `tree` and `history` resource have some
complicated logic. We also eliminate the use of the shared `suffix`
variable. We now build the URL left-to-right.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
We stop handling the URL hash through the routing system. Hashes are
local to the current view and can be handled by the shown components.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
This way we can get rid of the project browsing specific ProjectLink
component and simplify the router types.
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
We don’t replace the path when we navigate internally. This means we
keep the hash part of the URL even if it is not part of the route and we
can remove the workaround for that.
This also means that we keep the original URL if the parsed route would
result in a different URL. This change is visible through a slight
adjustments in the tests.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
We remove a couple of calls to `console.error()` in the code for the
local node connection. It’s not necessary to log errors that are
expected, for example, if the node is down.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
* Don’t load branches in `commits` view. We the branch selector is not
enabled there.
* Don’t silently swallow errors when fetching branches. Let the route
loading mechanism handle errors.
* Don’t use the default branch as the fallback for `branches`. They are
allowed to be empty and the empty case is handled properly now.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>
We remove logic used in the `BranchSelector` component. Instead we
restructure the component properties and rely on the `Browser`,
`History` and `Commit` components to pass values that result in the same
behavior.
Signed-off-by: Thomas Scholtes <geigerzaehler@axiom.fm>