Esempio n. 1
0
        public void Can_Add_Section()
        {
            // delete it if it exists, before running installer
            Section section = _sectionService.GetByAlias("workflow");

            if (section != null)
            {
                _sectionService.DeleteSection(section);
            }

            Assert.Null(_sectionService.GetByAlias("workflow"));

            var install = new Workflow.Helpers.Installer();

            Assert.True(install.AddSection(ApplicationContext.Current));
        }
Esempio n. 2
0
        public void Can_Add_Section()
        {
            // delete it if it exists, before running installer
            Uninstaller.RemoveSection();

            Assert.Null(_sectionService.GetByAlias("workflow"));

            Assert.True(Installer.AddSection(ApplicationContext.Current));
        }
Esempio n. 3
0
        internal void Build(FluidityContext context)
        {
            foreach (var sectionConfig in context.Config.Sections.Values)
            {
                // Create the section
                var existingSection = _sectionService.GetByAlias(sectionConfig.Alias);
                if (existingSection == null)
                {
                    _sectionService.MakeNew(
                        sectionConfig.Name,
                        sectionConfig.Alias,
                        sectionConfig.Icon);
                }

                // Add section name to default lang file
                AddSectionNameToLangFile(sectionConfig.Alias, sectionConfig.Name);

                // Add dashboard to section
                AddFluidityDashboardToSection(sectionConfig.Alias);

                // Create section tree
                if (sectionConfig.Tree != null)
                {
                    var existingTree = _treeService.GetByAlias(sectionConfig.Tree.Alias);
                    if (existingTree == null)
                    {
                        _treeService.MakeNew(
                            sectionConfig.Tree.Initialize,
                            0,
                            sectionConfig.Alias,
                            sectionConfig.Tree.Alias,
                            sectionConfig.Tree.Name,
                            sectionConfig.Tree.Icon,
                            sectionConfig.Tree.Icon,
                            "Fluidity.Web.Trees.FluidityTreeController, Fluidity");
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Returns the tree nodes for an application
        /// </summary>
        /// <param name="application">The application to load tree for</param>
        /// <param name="tree">An optional single tree alias, if specified will only load the single tree for the request app</param>
        /// <param name="queryStrings">The query strings</param>
        /// <param name="use">Tree use.</param>
        public async Task <ActionResult <TreeRootNode> > GetApplicationTrees(string application, string tree, [ModelBinder(typeof(HttpQueryStringModelBinder))] FormCollection queryStrings, TreeUse use = TreeUse.Main)
        {
            application = application.CleanForXss();

            if (string.IsNullOrEmpty(application))
            {
                return(NotFound());
            }

            var section = _sectionService.GetByAlias(application);

            if (section == null)
            {
                return(NotFound());
            }

            // find all tree definitions that have the current application alias
            var groupedTrees = _treeService.GetBySectionGrouped(application, use);
            var allTrees     = groupedTrees.Values.SelectMany(x => x).ToList();

            if (allTrees.Count == 0)
            {
                // if there are no trees defined for this section but the section is defined then we can have a simple
                // full screen section without trees
                var name = _localizedTextService.Localize("sections", application);
                return(TreeRootNode.CreateSingleTreeRoot(Constants.System.RootString, null, null, name, TreeNodeCollection.Empty, true));
            }

            // handle request for a specific tree / or when there is only one tree
            if (!tree.IsNullOrWhiteSpace() || allTrees.Count == 1)
            {
                var t = tree.IsNullOrWhiteSpace()
                    ? allTrees[0]
                    : allTrees.FirstOrDefault(x => x.TreeAlias == tree);

                if (t == null)
                {
                    return(NotFound());
                }

                var treeRootNode = await GetTreeRootNode(t, Constants.System.Root, queryStrings);

                if (treeRootNode != null)
                {
                    return(treeRootNode);
                }

                return(NotFound());
            }

            // handle requests for all trees
            // for only 1 group
            if (groupedTrees.Count == 1)
            {
                var nodes = new TreeNodeCollection();
                foreach (var t in allTrees)
                {
                    var nodeResult = await TryGetRootNode(t, queryStrings);

                    if (!(nodeResult.Result is null))
                    {
                        return(nodeResult.Result);
                    }

                    var node = nodeResult.Value;
                    if (node != null)
                    {
                        nodes.Add(node);
                    }
                }

                var name = _localizedTextService.Localize("sections", application);

                if (nodes.Count > 0)
                {
                    var treeRootNode = TreeRootNode.CreateMultiTreeRoot(nodes);
                    treeRootNode.Name = name;
                    return(treeRootNode);
                }

                // otherwise it's a section with all empty trees, aka a fullscreen section
                // todo is this true? what if we just failed to TryGetRootNode on all of them? SD: Yes it's true but we should check the result of TryGetRootNode and throw?
                return(TreeRootNode.CreateSingleTreeRoot(Constants.System.RootString, null, null, name, TreeNodeCollection.Empty, true));
            }

            // for many groups
            var treeRootNodes = new List <TreeRootNode>();

            foreach (var(groupName, trees) in groupedTrees)
            {
                var nodes = new TreeNodeCollection();
                foreach (var t in trees)
                {
                    var nodeResult = await TryGetRootNode(t, queryStrings);

                    if (nodeResult != null && nodeResult.Result is not null)
                    {
                        return(nodeResult.Result);
                    }
                    var node = nodeResult?.Value;

                    if (node != null)
                    {
                        nodes.Add(node);
                    }
                }

                if (nodes.Count == 0)
                {
                    continue;
                }

                // no name => third party
                // use localization key treeHeaders/thirdPartyGroup
                // todo this is an odd convention
                var name = groupName.IsNullOrWhiteSpace() ? "thirdPartyGroup" : groupName;

                var groupRootNode = TreeRootNode.CreateGroupNode(nodes, application);
                groupRootNode.Name = _localizedTextService.Localize("treeHeaders", name);
                treeRootNodes.Add(groupRootNode);
            }

            return(TreeRootNode.CreateGroupedMultiTreeRoot(new TreeNodeCollection(treeRootNodes.OrderBy(x => x.Name))));
        }