Пример #1
0
        private void buttonEditTitle_Click(object sender, EventArgs e)
        {
            string       title         = mrHelper.Common.Tools.StringUtils.ConvertNewlineUnixToWindows(getTitle());
            string       formCaption   = "Edit Merge Request title";
            TextEditForm editTitleForm = new TextEditForm(formCaption, title, true, false, null, String.Empty);

            if (editTitleForm.ShowDialog() == DialogResult.OK)
            {
                setTitle(Common.Tools.StringUtils.ConvertNewlineWindowsToUnix(editTitleForm.Body));
            }
        }
        private void buttonEditDescription_Click(object sender, EventArgs e)
        {
            string       description         = mrHelper.Common.Tools.StringUtils.ConvertNewlineUnixToWindows(getDescription());
            string       formCaption         = "Edit Merge Request description";
            TextEditForm editDescriptionForm = new TextEditForm(formCaption, description, true, true, null);

            if (editDescriptionForm.ShowDialog() == DialogResult.OK)
            {
                setDescription(Common.Tools.StringUtils.ConvertNewlineWindowsToUnix(editDescriptionForm.Body));
            }
        }
Пример #3
0
        async private Task onNewDiscussionAsync(MergeRequestKey mrk, string title)
        {
            string caption = String.Format("Create a new thread in merge request \"{0}\"", title);
            DiscussionNoteEditPanel actions = new DiscussionNoteEditPanel();

            using (TextEditForm form = new TextEditForm(caption, "", true, true, actions))
            {
                actions.SetTextbox(form.TextBox);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    if (form.Body.Length == 0)
                    {
                        MessageBox.Show("Discussion body cannot be empty", "Warning",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    DataCache dataCache = getDataCache(!isSearchMode());
                    if (dataCache == null)
                    {
                        Debug.Assert(false);
                        return;
                    }

                    labelWorkflowStatus.Text = "Creating a discussion...";
                    try
                    {
                        GitLabInstance     gitLabInstance = new GitLabInstance(mrk.ProjectKey.HostName, Program.Settings);
                        IDiscussionCreator creator        = Shortcuts.GetDiscussionCreator(
                            gitLabInstance, _modificationNotifier, mrk, getCurrentUser());
                        await creator.CreateDiscussionAsync(new NewDiscussionParameters(form.Body, null), false);
                    }
                    catch (DiscussionCreatorException)
                    {
                        MessageBox.Show("Cannot create a discussion at GitLab. Check your connection and try again",
                                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        labelWorkflowStatus.Text = "Cannot create a discussion";
                        return;
                    }
                    labelWorkflowStatus.Text = "Thread started";

                    dataCache.DiscussionCache?.RequestUpdate(mrk, Constants.DiscussionCheckOnNewThreadInterval, null);
                }
            }
        }
Пример #4
0
        async private Task onAddCommentAsync(MergeRequestKey mrk, string title)
        {
            string caption = String.Format("Add comment to merge request \"{0}\"", title);
            DiscussionNoteEditPanel actions = new DiscussionNoteEditPanel();

            using (TextEditForm form = new TextEditForm(caption, "", true, true, actions))
            {
                actions.SetTextbox(form.TextBox);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    if (form.Body.Length == 0)
                    {
                        MessageBox.Show("Comment body cannot be empty", "Warning",
                                        MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    labelWorkflowStatus.Text = "Adding a comment...";
                    try
                    {
                        GitLabInstance     gitLabInstance = new GitLabInstance(mrk.ProjectKey.HostName, Program.Settings);
                        IDiscussionCreator creator        = Shortcuts.GetDiscussionCreator(
                            gitLabInstance, _modificationNotifier, mrk, getCurrentUser());
                        await creator.CreateNoteAsync(new CreateNewNoteParameters(form.Body));
                    }
                    catch (DiscussionCreatorException)
                    {
                        MessageBox.Show("Cannot create a discussion at GitLab. Check your connection and try again",
                                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        labelWorkflowStatus.Text = "Cannot create a discussion";
                        return;
                    }
                    labelWorkflowStatus.Text = "Comment added";
                }
            }
        }