Skip to content

Commit

Permalink
Navigation (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe Birbaum committed May 8, 2021
1 parent 5122320 commit c191904
Show file tree
Hide file tree
Showing 22 changed files with 492 additions and 213 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Boost.Navigation
{
public interface IAppNavigationService
{
AppNavigation GetNavigation();
}
}
31 changes: 31 additions & 0 deletions src/Tool/src/Boost.Abstractions/Navigation/MainNavigation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Collections.Generic;

namespace Boost.Navigation
{
public class AppNavigation
{
public string? Title { get; set; } = default!;

public IEnumerable<MainNavigationItem> Items { get; set; }
= new List<MainNavigationItem>();
}

public class NavigationItem
{
public string? Id { get; set; } = default!;

public string Title { get; set; } = default!;

public string Route { get; set; } = default!;

public string? Icon { get; set; } = default!;

public bool IsServer { get; set; }
}

public class MainNavigationItem : NavigationItem
{
public IEnumerable<NavigationItem> Children { get; set; }
= new List<NavigationItem>();
}
}
2 changes: 1 addition & 1 deletion src/Tool/src/Boost.Core/Boost.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
Expand Down
2 changes: 2 additions & 0 deletions src/Tool/src/Boost.Core/BoostServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Boost.Git;
using Boost.GraphQL;
using Boost.Infrastructure;
using Boost.Navigation;
using Boost.Nuget;
using Boost.Pipelines;
using Boost.Security;
Expand Down Expand Up @@ -49,6 +50,7 @@ public static IServiceCollection AddBoost(this IServiceCollection services)
services.AddSingleton<IAuthTokenStore, UserDataAuthTokenStore>();
services.AddSingleton<IAuthTokenStoreReader, UserDataAuthTokenStoreReader>();
services.AddSingleton<IVersionChecker, VersionChecker>();
services.AddSingleton<IAppNavigationService, AppNavigationService>();

services.AddUserDataProtection();

Expand Down
6 changes: 6 additions & 0 deletions src/Tool/src/Boost.Core/GraphQL/BoostQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Boost.GraphQL;
using Boost.Infrastructure;
using Boost.Navigation;
using HotChocolate;
using HotChocolate.Types;

Expand Down Expand Up @@ -34,7 +35,12 @@ public BoostApplication GetAppliation()
CancellationToken cancellationToken)
{
return versionChecker.GetVersionInfo(cancellationToken);
}

public AppNavigation GetAppNavigation(
[Service] IAppNavigationService appNavigationService)
{
return appNavigationService.GetNavigation();
}
}
}
49 changes: 49 additions & 0 deletions src/Tool/src/Boost.Core/Navigation/AppNavigationService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.IO;
using System.Text.Json;
using Boost.Infrastructure;

namespace Boost.Navigation
{
public class AppNavigationService : IAppNavigationService
{
private readonly IBoostCommandContext _commandContext;

public AppNavigationService(IBoostCommandContext commandContext)
{
_commandContext = commandContext;
}

public AppNavigation GetNavigation()
{
Stream? stream = _commandContext.ToolAssembly
.GetManifestResourceStream("Boost.Tool.AppNavigation.json");

if (stream is { })
{
using StreamReader reader = new StreamReader(stream);
var json = reader.ReadToEnd();
AppNavigation? appNav = JsonSerializer.Deserialize<AppNavigation>(json)!;

foreach (MainNavigationItem? item in appNav.Items)
{
if (item.Id is null)
{
item.Id = item.Route;
}
foreach (NavigationItem child in item.Children)
{
if (child.Id is null)
{
child.Id = $"{item.Id}.{child.Route}";
}
}
}

return appNav;
}

throw new ApplicationException("Could not load app navigation");
}
}
}
97 changes: 97 additions & 0 deletions src/Tool/src/Boost.Tool/AppNavigation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"Title": "Boost",
"Items": [
{
"Title": "Workspace",
"Icon": "mdi-folder-outline",
"Route": "Workspace"
},
{
"Title": "Git",
"Icon": "mdi-git",
"Route": "Git",
"Children": [
{
"Title": "Current",
"Route": "Git.Current"
},
{
"Title": "All Local",
"Route": "Git.Local"
},
{
"Title": "Remote",
"Route": "Git.Remote"
},
{
"Title": "Indexing",
"Route": "Git.Index"
}
]
},
{
"Title": "Utils",
"Icon": "mdi-hammer-screwdriver",
"Route": "Utils",
"Children": [
{
"Title": "Encoding & Guids",
"Route": "Utils.Encoding"
},
{
"Title": "Base64 to File",
"Route": "Utils.Base64ToFile"
},
{
"Title": "Security",
"Route": "Utils.Security"
}
]
},
{
"Title": "Security",
"Icon": "mdi-lock-check",
"Route": "Security",
"Children": [
{
"Title": "Tokens",
"Route": "Security.Tokens"
},
{
"Title": "Authorize (OIDC)",
"Route": "Security.Authorize"
},
{
"Title": "Token requestor",
"Route": "Security.TokenRequest"
}
]
},
{
"Title": "Snapshooter",
"Route": "Snapshooter",
"Icon": "mdi-test-tube"
},
{
"Title": "Settings",
"Icon": "mdi-cog-outline",
"Route": "Settings",
"Children": [
{
"Title": "General",
"Route": "Settings.General"
},
{
"Title": "Security",
"Route": "Settings.Security"
}
]
},
{
"Title": "GraphQL",
"Icon": "mdi-graphql",
"IsServer": true,
"Route": "graphql"
}
]
}
8 changes: 8 additions & 0 deletions src/Tool/src/Boost.Tool/Boost.Tool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
<EmbeddedResource Include="AuthUI/**" />
</ItemGroup>

<ItemGroup>
<None Remove="AppNavigation.json" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="AppNavigation.json" />
</ItemGroup>

<ItemGroup>
<Folder Include="UI\" />
<Folder Include="AuthUI\" />
Expand Down
2 changes: 1 addition & 1 deletion src/Tool/src/Boost.Tool/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"Boost.Tool": {
"commandName": "Project",
"commandLineArgs": "version"
"commandLineArgs": "ui"
}
}
}
8 changes: 8 additions & 0 deletions src/UI/boost-ui/src/core/appService.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import apollo from "../apollo";

import QUERY_INITIAL_DATA from "./graphql/InitialData.gql";
import QUERY_VERSION_GET from "./graphql/App/GetVersion.gql";
import QUERY_NAVIGATION_GET from "./graphql/App/GetNavigation.gql";

export const getInitialData = async () => {
return await apollo.query({
Expand All @@ -16,3 +17,10 @@ export const getVersion = async () => {
variables: {}
});
};

export const getNavigation = async () => {
return await apollo.query({
query: QUERY_NAVIGATION_GET,
variables: {}
});
};
64 changes: 15 additions & 49 deletions src/UI/boost-ui/src/core/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@
>mdi-alert</v-icon
>
</div>

<div style="cursor: pointer" @click="$router.push({ name: 'Info' })">
<v-icon class="mt-n1">mdi-information-outline</v-icon>
<span class="mr-2" v-if="version">{{ version.installed }}</span>
<span class="mr-4" v-if="version">{{ version.installed }}</span>
</div>
<v-btn @click="$router.push({ name: 'Settings' })" icon
><v-icon>mdi-cog-outline</v-icon></v-btn
>
</v-system-bar>
<v-navigation-drawer width="62" class="nav" app>
<div
class="nav-item"
v-for="(nav, i) in navBarItems"
:key="i"
v-for="nav in navBarItems"
:key="nav.id"
:title="nav.name"
@click="onNavigate(nav)"
>
Expand All @@ -59,6 +61,7 @@
<v-main>
<router-view></router-view>
</v-main>

<v-snackbar
color="red darken-3"
v-model="versionSnack"
Expand Down Expand Up @@ -109,56 +112,19 @@ export default {
mounted() {
this.getVersion();
},
data: () => ({
dialog: false,
versionSnack: false,
navItems: [
{
text: "Workspace",
icon: "mdi-folder-outline",
route: "Workspace",
},
{
text: "Git",
icon: "mdi-git",
route: "Git",
},
{
text: "Utils",
icon: "mdi-hammer-screwdriver",
route: "Utils",
},
{
text: "Security",
icon: "mdi-lock-check",
route: "Security",
},
{
text: "Snapshooter",
route: "Snapshooter",
icon: "mdi-test-tube",
image2: require("../../assets/ss_logo.png"),
},
{
text: "Settings",
icon: "mdi-cog-outline",
route: "Settings",
},
{
text: "GraphQL",
icon: "mdi-graphql",
isServer: true,
route: "graphql",
},
],
}),
data() {
return {
dialog: false,
versionSnack: false,
};
},
computed: {
...mapState("app", ["statusMessage", "app", "version"]),
...mapState("app", ["statusMessage", "app", "version", "navigation"]),
me: function () {
return null;
},
navBarItems: function () {
return this.navItems.map((x) => {
return this.$store.state.app.navigation.items.map((x) => {
x.active = this.$route.name.startsWith(x.route);
x.color = x.active ? "#fff" : "#b3b3b3";
Expand Down
Loading

0 comments on commit c191904

Please sign in to comment.