Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Vertical Navigation redesign #1475

Merged
merged 3 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/unreleased/1353-mklanjsek
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Left Navigation redesign
2 changes: 2 additions & 0 deletions internal/api/navigation_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ func NavigationGenerator(ctx context.Context, state octant.State, config Navigat
if err != nil {
return fmt.Errorf("unable to generate navigation for module %s: %v", m.Name(), err)
}
navList[0].Module = m.Name()
navList[0].Description = m.Description()

mu.Lock()
defer mu.Unlock()
Expand Down
3 changes: 2 additions & 1 deletion internal/api/navigation_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func TestNavigationGenerator(t *testing.T) {
m := moduleFake.NewMockModule(controller)
m.EXPECT().ContentPath().Return("/module")
m.EXPECT().Name().Return("module").AnyTimes()
m.EXPECT().Description().Return("description").AnyTimes()
m.EXPECT().
Navigation(gomock.Any(), "default", "/module").
Return([]navigation.Navigation{
Expand All @@ -81,7 +82,7 @@ func TestNavigationGenerator(t *testing.T) {
return dashConfig, state
},
expected: []navigation.Navigation{
{Title: "module"},
{Title: "module", Module: "module", Description: "description"},
},
},
}
Expand Down
14 changes: 14 additions & 0 deletions internal/module/fake/mock_module.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions internal/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type ContentOptions struct {
type Module interface {
// Name is the name of the module.
Name() string
// Description is a description for this module
Description() string
// ClientRequestHandlers are handlers for handling client requests.
ClientRequestHandlers() []octant.ClientRequestHandler
// Content generates content for a path.
Expand Down
5 changes: 5 additions & 0 deletions internal/modules/applications/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ func (m Module) Name() string {
return "applications"
}

// Description is the description of the module.
func (m Module) Description() string {
return "Applications module description comes here"
}

// ClientRequestHandlers are client handlers for the module.
func (m Module) ClientRequestHandlers() []octant.ClientRequestHandler {
return nil
Expand Down
6 changes: 5 additions & 1 deletion internal/modules/clusteroverview/clusteroverview.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ func (co *ClusterOverview) Name() string {
return "cluster-overview"
}

func (co *ClusterOverview) Description() string {
return "Cluster module is used to display all cluster related resources"
}

func (co *ClusterOverview) ClientRequestHandlers() []octant.ClientRequestHandler {
return nil
}
Expand Down Expand Up @@ -200,7 +204,7 @@ func (co *ClusterOverview) Navigation(ctx context.Context, _ string, root string
"Port Forwards": nil,
},
IconMap: map[string]string{
"Cluster Overview": icon.Overview,
"Cluster Overview": icon.Cluster,
"Namespaces": icon.Namespaces,
"Custom Resources": icon.CustomResources,
"Custom Resource Definitions": icon.CustomResourceDefinition,
Expand Down
7 changes: 6 additions & 1 deletion internal/modules/configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ func (Configuration) Name() string {
return "configuration"
}

func (Configuration) Description() string {
return `Plugins module displays all registered plugins and their properties.
To find list of known plugins go to https://github.com/topics/octant-plugin`
}

func (c Configuration) ClientRequestHandlers() []octant.ClientRequestHandler {
return nil
}
Expand Down Expand Up @@ -96,7 +101,7 @@ func (c *Configuration) Navigation(ctx context.Context, namespace, root string)
return []navigation.Navigation{
{
Module: "Configuration",
Title: "Plugin",
Title: "Plugins",
Path: path.Join(c.ContentPath(), "plugins"),
IconName: icon.ConfigurationPlugin,
},
Expand Down
4 changes: 4 additions & 0 deletions internal/modules/localcontent/localcontent.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func (l *LocalContent) Name() string {
return "local"
}

func (l *LocalContent) Description() string {
return "This is the local module description"
}

func (l *LocalContent) ClientRequestHandlers() []octant.ClientRequestHandler {
return nil
}
Expand Down
5 changes: 5 additions & 0 deletions internal/modules/overview/overview.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ func (co *Overview) Name() string {
return "overview"
}

// Description returns module description.
func (co *Overview) Description() string {
return "Namespace module shows all resources related to currently selected namespace\nUse dropdown at the top to change the selected namespace"
}

func (co *Overview) ClientRequestHandlers() []octant.ClientRequestHandler {
return nil
}
Expand Down
5 changes: 5 additions & 0 deletions internal/modules/workloads/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ func (m *Module) Name() string {
return "workloads"
}

// Description returns the module description.
func (m *Module) Description() string {
return "Application module displays all known applications and their status"
}

// ClientRequestHandlers returns nil.
func (m *Module) ClientRequestHandlers() []octant.ClientRequestHandler {
return nil
Expand Down
1 change: 1 addition & 0 deletions pkg/icon/icon.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const (
ConfigAndStorage = "storage"
RBAC = "assign-user"
Events = "event"
Cluster = "cluster"

Namespaces = "namespace"
ApiServer = "hard-disk"
Expand Down
13 changes: 7 additions & 6 deletions pkg/navigation/navigation.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ func SetLoading(isLoading bool) Option {

// Navigation is a set of navigation entries.
type Navigation struct {
Module string `json:"module,omitempty"`
Title string `json:"title,omitempty"`
Path string `json:"path,omitempty"`
Children []Navigation `json:"children,omitempty"`
IconName string `json:"iconName,omitempty"`
Loading bool `json:"isLoading"`
Module string `json:"module,omitempty"`
Description string `json:"description,omitempty"`
Title string `json:"title,omitempty"`
Path string `json:"path,omitempty"`
Children []Navigation `json:"children,omitempty"`
IconName string `json:"iconName,omitempty"`
Loading bool `json:"isLoading"`
}

// New creates a Navigation.
Expand Down
5 changes: 5 additions & 0 deletions pkg/plugin/module_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ func (m *ModuleProxy) Name() string {
return m.Metadata.Name
}

// Description returns the module's description.
func (m *ModuleProxy) Description() string {
return m.Metadata.Description
}

func (m *ModuleProxy) ClientRequestHandlers() []octant.ClientRequestHandler {
return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ export class ContentFilterComponent
}

ngOnInit(): void {
this.filter.selected.forEach(value => (this.checkboxes[value] = true));
this.cd.detectChanges();
if (this.filter.selected) {
this.filter.selected.forEach(value => (this.checkboxes[value] = true));
this.cd.detectChanges();
}
}

accepts(row: TableRow): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,36 @@ <h3 class="modal-title">Keyboard Shortcuts</h3>
<span class="label">Ctrl<span class="badge">Y</span></span>
</clr-stack-content>
</clr-stack-block>
<clr-stack-block
[clrStackViewLevel]="2"
[clrStackViewSetsize]="0"
[clrStackViewPosinset]="1"
>
<clr-stack-label>Toggle Theme</clr-stack-label>
<clr-stack-content>
<span class="label">Ctrl Shift<span class="badge">T</span></span>
</clr-stack-content>
</clr-stack-block>
<clr-stack-block
[clrStackViewLevel]="2"
[clrStackViewSetsize]="0"
[clrStackViewPosinset]="1"
>
<clr-stack-label>Toggle Navigation</clr-stack-label>
<clr-stack-content>
<span class="label">Ctrl<span class="badge">b</span></span>
</clr-stack-content>
</clr-stack-block>
<clr-stack-block
[clrStackViewLevel]="2"
[clrStackViewSetsize]="0"
[clrStackViewPosinset]="1"
>
<clr-stack-label>Show/Hide Labels</clr-stack-label>
<clr-stack-content>
<span class="label">Ctrl Shift<span class="badge">L</span></span>
</clr-stack-content>
</clr-stack-block>
</clr-stack-block>
<clr-stack-block
[clrSbExpandable]="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import {
import { WebsocketServiceMock } from '../../../../data/services/websocket/mock';
import { Navigation } from '../../../sugarloaf/models/navigation';
import { ContentService } from '../content/content.service';
import { NAVIGATION_MOCK_DATA } from './navigation.test.data';
import {
expectedSelection,
NAVIGATION_MOCK_DATA,
} from './navigation.test.data';
import { BehaviorSubject } from 'rxjs';
import { take } from 'rxjs/operators';

Expand Down Expand Up @@ -73,11 +76,16 @@ describe('NavigationService', () => {
if (section.children) {
section.children.map(child => {
verifySelection(child.path, svc, index, 'child');
if (child.children) {
child.children.map(grandchild => {
verifySelection(grandchild.path, svc, index, 'grandchild');
});
}
});
}
});
svc.activeUrl.unsubscribe();
svc.lastSelection.unsubscribe();
svc.selectedItem.unsubscribe();
}
));

Expand All @@ -90,10 +98,19 @@ describe('NavigationService', () => {
svc.activeUrl.next('/' + path);
svc.updateLastSelection();

svc.lastSelection.pipe(take(1)).subscribe(selection => {
expect(selection)
.withContext(`navigation selected ${descriptor} index ${index}`)
.toEqual(index);
svc.selectedItem.pipe(take(1)).subscribe(selection => {
const expected = expectedSelection[path];

expect(selection.index)
.withContext(
`navigation selected ${descriptor} index ${index} ${path}`
)
.toEqual(expected.index);
expect(selection.module)
.withContext(
`navigation selected ${descriptor} module ${index} ${path}`
)
.toEqual(expected.module);
});

svc.activeUrl.pipe(take(1)).subscribe(url =>
Expand Down
Loading