Exemple #1
0
        public ModuleVersionSelector(Tuple <IRepositoryManager, IModule> moduleSelectable, IModule projectModule, GUIStyles styles)
        {
            this.moduleSelectable = moduleSelectable;
            this.projectModule    = projectModule;
            this.styles           = styles;

            if (this.projectModule != null)
            {
                this.repositoryStatus = new ModuleRepositoryStatus(projectModule, styles);
            }

            this.maxVersion = this.moduleSelectable.Item2.Versions.Where((BranchVersion branchVersion) => branchVersion.IsVersion).Max();
            if (projectModule != null)
            {
                this.versionSelected = this.moduleSelectable.Item2.Versions.FindIndex((BranchVersion branchVersion) => branchVersion.ToString() == projectModule.CurrentBranchVersion.ToString());
            }
            else
            {
                this.versionSelected = this.moduleSelectable.Item2.Versions.FindIndex((BranchVersion branchVersion) => branchVersion.ToString() == "master");
            }
            this.versionsAvailable = this.moduleSelectable.Item2.Versions.Select <BranchVersion, string>((BranchVersion branchVersion) => branchVersion.ToString()).ToArray();
        }
Exemple #2
0
        public void Display()
        {
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            if (!this.moduniModel.RepositoriesManagers.Any())
            {
                EditorGUILayout.LabelField("No repositories found. Please, create a repository and modules before you can publish anything.", EditorStyles.boldLabel, null);
            }
            else if (!this.moduniModel.ProjectModules.Any())
            {
                EditorGUILayout.LabelField("No modules found in your project. Please, import or create modules before you can publish anything.", EditorStyles.boldLabel, null);
            }
            else
            {
                EditorGUILayout.Space();
                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUILayout.LabelField(new GUIContent("Click on the name of the module you want to publish, type in the message for the publication and then select one type of publication below."), this.styles.BoldLabelStyle, GUILayout.MinWidth(500f));
                }
                EditorGUILayout.Space();
                EditorGUILayout.Space();

                using (new EditorGUILayout.VerticalScope(GUILayout.ExpandHeight(true)))
                {
                    using (EditorGUILayout.ScrollViewScope scrollView = new EditorGUILayout.ScrollViewScope(this.scrollPosition))
                    {
                        this.scrollPosition = scrollView.scrollPosition;
                        this.modulesToggleGroup.Display();
                    }
                }
                EditorGUILayout.Separator();
                using (new EditorGUILayout.VerticalScope())
                {
                    EditorGUILayout.LabelField("Type in below a message for your publication.");
                    this.commitMessage = EditorGUILayout.TextArea(this.commitMessage);
                    using (new EditorGUILayout.HorizontalScope(GUILayout.ExpandWidth(true)))
                    {
                        using (new EditorGUILayout.VerticalScope(GUILayout.ExpandWidth(true)))
                        {
                        }
                        IModule module = this.modulesToggleGroup.ObjectSelected;
                        if (module != null)
                        {
                            BranchVersion maxVersion = module.Versions.Where((BranchVersion branchVersion) => branchVersion.IsVersion).Max();
                            BranchVersion majorVersion = maxVersion, minorVersion = maxVersion, patchVersion = maxVersion;
                            string        errorMessage = "Please type in a message for your publication.";
                            majorVersion.IncreaseMajorVersion();
                            minorVersion.IncreaseMinorVersion();
                            patchVersion.IncreasePatchVersion();

                            if (GUILayout.Button("Publish changes", GUILayout.MinWidth(250f), GUILayout.MinHeight(50f), GUILayout.Width(250f)))
                            {
                                if (string.IsNullOrEmpty(this.commitMessage) || this.commitMessage == ModulePublicationTab.DefaultCommitMessage)
                                {
                                    if (this.OnMessageTriggered != null)
                                    {
                                        this.OnMessageTriggered(new Message(errorMessage, MessageType.Info));
                                    }
                                }
                                else
                                {
                                    if (this.OnModuleChangesPublicationSelected != null)
                                    {
                                        this.OnModuleChangesPublicationSelected(module, this.commitMessage);
                                    }
                                    this.modulesToggleGroup.Select(false);
                                }
                            }
                            if (!module.IsDirty)
                            {
                                if (GUILayout.Button("Publish " + majorVersion.ToString(), GUILayout.MinWidth(250f), GUILayout.MinHeight(50f), GUILayout.Width(250f)))
                                {
                                    if (string.IsNullOrEmpty(this.commitMessage) || this.commitMessage == ModulePublicationTab.DefaultCommitMessage)
                                    {
                                        if (this.OnMessageTriggered != null)
                                        {
                                            this.OnMessageTriggered(new Message(errorMessage, MessageType.Info));
                                        }
                                    }
                                    else
                                    {
                                        if (this.OnModuleVersionPublicationSelected != null)
                                        {
                                            this.OnModuleVersionPublicationSelected(module, this.commitMessage, majorVersion);
                                        }
                                        this.modulesToggleGroup.Select(false);
                                    }
                                }
                                if (GUILayout.Button("Publish " + minorVersion.ToString(), GUILayout.MinWidth(250f), GUILayout.MinHeight(50f), GUILayout.Width(250f)))
                                {
                                    if (string.IsNullOrEmpty(this.commitMessage) || this.commitMessage == ModulePublicationTab.DefaultCommitMessage)
                                    {
                                        if (this.OnMessageTriggered != null)
                                        {
                                            this.OnMessageTriggered(new Message(errorMessage, MessageType.Info));
                                        }
                                    }
                                    else
                                    {
                                        if (this.OnModuleVersionPublicationSelected != null)
                                        {
                                            this.OnModuleVersionPublicationSelected(module, this.commitMessage, minorVersion);
                                        }
                                        this.modulesToggleGroup.Select(false);
                                    }
                                }
                                if (GUILayout.Button("Publish " + patchVersion.ToString(), GUILayout.MinWidth(250f), GUILayout.MinHeight(50f), GUILayout.Width(250f)))
                                {
                                    if (string.IsNullOrEmpty(this.commitMessage) || this.commitMessage == ModulePublicationTab.DefaultCommitMessage)
                                    {
                                        if (this.OnMessageTriggered != null)
                                        {
                                            this.OnMessageTriggered(new Message(errorMessage, MessageType.Info));
                                        }
                                    }
                                    else
                                    {
                                        if (this.OnModuleVersionPublicationSelected != null)
                                        {
                                            this.OnModuleVersionPublicationSelected(module, this.commitMessage, patchVersion);
                                        }
                                        this.modulesToggleGroup.Select(false);
                                    }
                                }
                            }
                        }
                        using (new EditorGUILayout.VerticalScope(GUILayout.ExpandWidth(true)))
                        {
                        }
                    }
                    GUILayout.Space(15f);
                }
            }
        }
Exemple #3
0
 void OnModuleSelectedForVersionPublication(IModule modulesSelectedForVersionPublication, string versionMessage, BranchVersion newVersion)
 {
     this.moduniModel.PublishVersion(modulesSelectedForVersionPublication, versionMessage, newVersion);
 }