public async Task <IViewComponentResult> InvokeAsync(string selectedOwnerId, string selectedRepoId, string area)
        {
            if (User?.Identity == null || !User.Identity.IsAuthenticated || !ClaimsHelper.OwnerExistsInUserClaims(User.Identity as ClaimsIdentity, selectedOwnerId))
            {
                // dash view model
                var publicDash = new DashboardMenuViewModel
                {
                    SelectedOwnerId = selectedOwnerId,
                    SelectedRepoId  = selectedRepoId,
                    ActiveArea      = area
                };
                //note: when public, the avatar URL cannot be retrieved from the user claims, so needs to be retrieved from data storage / cache
                return(View("Public", publicDash));
            }

            // user view model
            var uvm = new UserViewModel();

            uvm.Populate(User.Identity as ClaimsIdentity);

            // dash view model
            this.DashboardMenuViewModel = new DashboardMenuViewModel
            {
                SelectedOwnerId = selectedOwnerId,
                SelectedRepoId  = selectedRepoId,
                UserViewModel   = uvm,
                ActiveArea      = area
            };
            this.DashboardMenuViewModel.Owners.Add(uvm.UserOwner);
            this.DashboardMenuViewModel.Owners.AddRange(uvm.Organisations);
            this.DashboardMenuViewModel.SelectedOwnerAvatarUrl = this.DashboardMenuViewModel.Owners.FirstOrDefault(o => o.OwnerId.Equals(selectedOwnerId, StringComparison.InvariantCultureIgnoreCase))?.AvatarUrl;
            await PopulateRepositoryList();

            return(View(this.DashboardMenuViewModel));
        }
Example #2
0
        public void TestDashContextPreservesCase()
        {
            var vm = new DashboardMenuViewModel {
                SelectedOwnerId = "OwnerA", SelectedRepoId = "RepoName"
            };

            vm.GetDashContext().Should().Be("OwnerA/RepoName");
        }
Example #3
0
        public void TestDashContextForOwnerAndRepo()
        {
            var vm = new DashboardMenuViewModel {
                SelectedOwnerId = "owner", SelectedRepoId = "repo"
            };

            vm.GetDashContext().Should().Be("owner/repo");
        }
Example #4
0
        public void TestDashContextForOwnerOnly()
        {
            var vm = new DashboardMenuViewModel {
                SelectedOwnerId = "owner"
            };

            vm.GetDashContext().Should().Be("owner");
        }
Example #5
0
        public void TestAreaIsActive()
        {
            var vm = new DashboardMenuViewModel {
                SelectedOwnerId = "owner", SelectedRepoId = "repo", ActiveArea = "someArea"
            };

            vm.AreaIsActive("notActive").Should().BeEmpty();
            vm.AreaIsActive("someArea").Should().Be("active");
            vm.AreaIsActive("somearea").Should().Be("active");
        }
Example #6
0
        public void GetActiveOwnerReturnsFirstCaseInsensitiveOwnerIdMatch()
        {
            var vm = new DashboardMenuViewModel
            {
                SelectedOwnerId = "owner", Owners = new List <OwnerInfo>
                {
                    new OwnerInfo {
                        OwnerId = "Owner", AvatarUrl = "http://example.org/url1"
                    },
                    new OwnerInfo {
                        OwnerId = "owner", AvatarUrl = "http://example.org/url2"
                    }
                }
            };
            var activeOwner = vm.GetActiveOwner();

            activeOwner.Should().NotBeNull();
            activeOwner.AvatarUrl.Should().Be("http://example.org/url1");
        }
Example #7
0
    public override IRootDock CreateLayout()
    {
        // Tool Windows - Libraries

        var styleLibraryViewModel = new StyleLibraryViewModel()
        {
            Id    = "StyleLibrary",
            Title = "Styles"
        };

        var groupLibraryViewModel = new GroupLibraryViewModel()
        {
            Id    = "GroupLibrary",
            Title = "Groups"
        };

        var databaseLibraryViewModel = new DatabaseLibraryViewModel()
        {
            Id    = "DatabaseLibrary",
            Title = "Databases"
        };

        var templateLibraryViewModel = new TemplateLibraryViewModel()
        {
            Id    = "TemplateLibrary",
            Title = "Templates"
        };

        var scriptLibraryViewModel = new ScriptLibraryViewModel()
        {
            Id    = "ScriptLibrary",
            Title = "Scripts"
        };

        // Tool Windows - Options

        var projectOptionsViewModel = new ProjectOptionsViewModel()
        {
            Id    = "ProjectOptions",
            Title = "Options"
        };

        var rendererOptionsViewModel = new RendererOptionsViewModel()
        {
            Id    = "RendererOptions",
            Title = "Renderer"
        };

        var zoomOptionsViewModel = new ZoomOptionsViewModel()
        {
            Id    = "ZoomOptions",
            Title = "Zoom"
        };

        var imageOptionsViewModel = new ImageOptionsViewModel()
        {
            Id    = "ImageOptions",
            Title = "Images"
        };

        // Tool Windows - Properties

        var pagePropertiesViewModel = new PagePropertiesViewModel()
        {
            Id    = "PageProperties",
            Title = "Page"
        };

        var shapePropertiesViewModel = new ShapePropertiesViewModel()
        {
            Id    = "ShapeProperties",
            Title = "Shape"
        };

        var stylePropertiesViewModel = new StylePropertiesViewModel()
        {
            Id    = "StyleProperties",
            Title = "Style"
        };

        var dataPropertiesViewModel = new DataPropertiesViewModel()
        {
            Id    = "DataProperties",
            Title = "Data"
        };

        var statePropertiesViewModel = new StatePropertiesViewModel()
        {
            Id    = "StateProperties",
            Title = "State"
        };

        // Tool Windows

        var projectExplorerViewModel = new ProjectExplorerViewModel()
        {
            Id    = "ProjectExplorer",
            Title = "Project Explorer"
        };

        var objectBrowserViewModel = new ObjectBrowserViewModel()
        {
            Id    = "ObjectBrowser",
            Title = "Object Browser"
        };

        // Home Perspective

        var leftTopToolDock = new ToolDock
        {
            ActiveDockable   = projectExplorerViewModel,
            VisibleDockables = CreateList <IDockable>(
                projectExplorerViewModel,
                objectBrowserViewModel,
                scriptLibraryViewModel),
            Alignment = Alignment.Left,
            GripMode  = GripMode.Visible
        };

        var leftBottomToolDock = new ToolDock
        {
            Proportion       = 0.35,
            ActiveDockable   = pagePropertiesViewModel,
            VisibleDockables = CreateList <IDockable>(
                pagePropertiesViewModel,
                projectOptionsViewModel,
                rendererOptionsViewModel,
                zoomOptionsViewModel,
                imageOptionsViewModel),
            Alignment = Alignment.Right,
            GripMode  = GripMode.Visible
        };

        var rightTopToolDock = new ToolDock
        {
            Proportion       = 0.35,
            ActiveDockable   = shapePropertiesViewModel,
            VisibleDockables = CreateList <IDockable>(
                shapePropertiesViewModel,
                dataPropertiesViewModel,
                statePropertiesViewModel,
                templateLibraryViewModel),
            Alignment = Alignment.Right,
            GripMode  = GripMode.Visible
        };

        var rightBottomToolDock = new ToolDock
        {
            ActiveDockable   = stylePropertiesViewModel,
            VisibleDockables = CreateList <IDockable>(
                stylePropertiesViewModel,
                styleLibraryViewModel,
                groupLibraryViewModel,
                databaseLibraryViewModel),
            Alignment = Alignment.Right,
            GripMode  = GripMode.Visible
        };

        var leftDock = new ProportionalDock
        {
            Proportion       = 0.20,
            Orientation      = Orientation.Vertical,
            ActiveDockable   = leftTopToolDock,
            VisibleDockables = CreateList <IDockable>
                               (
                leftTopToolDock,
                new ProportionalDockSplitter(),
                leftBottomToolDock
                               )
        };

        var rightDock = new ProportionalDock
        {
            Proportion       = 0.20,
            Orientation      = Orientation.Vertical,
            ActiveDockable   = rightTopToolDock,
            VisibleDockables = CreateList <IDockable>
                               (
                rightTopToolDock,
                new ProportionalDockSplitter(),
                rightBottomToolDock
                               )
        };

        var documentDock = new PageDocumentDock
        {
            Id                = "PageDocumentDock",
            Title             = "Pages",
            ActiveDockable    = null,
            VisibleDockables  = CreateList <IDockable>(),
            CanCreateDocument = true,
            IsCollapsable     = false
        };

        var homeDock = new ProportionalDock
        {
            Id               = "HomeDock",
            Orientation      = Orientation.Horizontal,
            ActiveDockable   = documentDock,
            VisibleDockables = CreateList <IDockable>
                               (
                leftDock,
                new ProportionalDockSplitter(),
                documentDock,
                new ProportionalDockSplitter(),
                rightDock
                               ),
            IsCollapsable = false
        };

        var homeMenuViewModel = new HomeMenuViewModel()
        {
            Id   = "HomeMenuView",
            Dock = DockMode.Top
        };

        var homeStatusBarViewModel = new HomeStatusBarViewModel()
        {
            Id   = "HomeStatusBarView",
            Dock = DockMode.Bottom
        };

        var homeViewModel = new HomeViewModel
        {
            Id               = "HomeView",
            Dock             = DockMode.Center,
            ActiveDockable   = homeDock,
            VisibleDockables = CreateList <IDockable>(homeDock),
            IsCollapsable    = false
        };

        var homeDockDock = new DockDock()
        {
            Id               = "HomeDockDock",
            LastChildFill    = true,
            VisibleDockables = CreateList <IDockable>
                               (
                homeMenuViewModel,
                homeStatusBarViewModel,
                homeViewModel
                               ),
            IsCollapsable = false
        };

        // Dashboard Perspective

        var dashboardMenuViewModel = new DashboardMenuViewModel()
        {
            Id            = "DashboardMenuView",
            Title         = "Dashboard Menu",
            Dock          = DockMode.Top,
            IsCollapsable = false
        };

        var dashboardViewModel = new DashboardViewModel
        {
            Id            = "DashboardView",
            Title         = "Dashboard",
            Dock          = DockMode.Center,
            IsCollapsable = false
        };

        var dashboardDockDock = new DockDock()
        {
            Id               = "DashboardDock",
            Proportion       = 1.0,
            LastChildFill    = true,
            VisibleDockables = CreateList <IDockable>
                               (
                dashboardMenuViewModel,
                dashboardViewModel
                               ),
            IsCollapsable = false
        };

        // Root Perspective

        var dashboardRootDock = CreateRootDock();

        dashboardRootDock.Id               = "Dashboard";
        dashboardRootDock.ActiveDockable   = dashboardDockDock;
        dashboardRootDock.DefaultDockable  = dashboardDockDock;
        dashboardRootDock.VisibleDockables = CreateList <IDockable>(dashboardDockDock);
        dashboardRootDock.IsCollapsable    = false;

        var homeRootDock = CreateRootDock();

        homeRootDock.Id               = "Home";
        homeRootDock.ActiveDockable   = homeDockDock;
        homeRootDock.DefaultDockable  = homeDockDock;
        homeRootDock.VisibleDockables = CreateList <IDockable>(homeDockDock);
        homeRootDock.IsCollapsable    = false;

        // Root Dock

        var rootDock = CreateRootDock();

        rootDock.Id               = "Root";
        rootDock.ActiveDockable   = dashboardRootDock;
        rootDock.DefaultDockable  = dashboardRootDock;
        rootDock.VisibleDockables = CreateList <IDockable>(dashboardRootDock, homeRootDock);
        rootDock.IsCollapsable    = false;

        _rootDock  = rootDock;
        _pagesDock = documentDock;
        _homeDock  = homeDock;

        return(rootDock);
    }