Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/services')
-rw-r--r--app/services/concerns/members/bulk_create_users.rb6
-rw-r--r--app/services/deployments/link_merge_requests_service.rb2
-rw-r--r--app/services/members/create_service.rb19
-rw-r--r--app/services/members/creator_service.rb18
-rw-r--r--app/services/members/invite_service.rb5
-rw-r--r--app/services/tasks_to_be_done/base_service.rb55
-rw-r--r--app/services/tasks_to_be_done/create_ci_task_service.rb44
-rw-r--r--app/services/tasks_to_be_done/create_code_task_service.rb52
-rw-r--r--app/services/tasks_to_be_done/create_issues_task_service.rb43
9 files changed, 240 insertions, 4 deletions
diff --git a/app/services/concerns/members/bulk_create_users.rb b/app/services/concerns/members/bulk_create_users.rb
index 4498f40c396..b98917f1396 100644
--- a/app/services/concerns/members/bulk_create_users.rb
+++ b/app/services/concerns/members/bulk_create_users.rb
@@ -6,7 +6,7 @@ module Members
included do
class << self
- def add_users(source, users, access_level, current_user: nil, expires_at: nil)
+ def add_users(source, users, access_level, current_user: nil, expires_at: nil, tasks_to_be_done: [], tasks_project_id: nil)
return [] unless users.present?
emails, users, existing_members = parse_users_list(source, users)
@@ -18,7 +18,9 @@ module Members
access_level,
existing_members: existing_members,
current_user: current_user,
- expires_at: expires_at)
+ expires_at: expires_at,
+ tasks_to_be_done: tasks_to_be_done,
+ tasks_project_id: tasks_project_id)
.execute
end
end
diff --git a/app/services/deployments/link_merge_requests_service.rb b/app/services/deployments/link_merge_requests_service.rb
index 39fbef5dee2..40385418e48 100644
--- a/app/services/deployments/link_merge_requests_service.rb
+++ b/app/services/deployments/link_merge_requests_service.rb
@@ -16,7 +16,7 @@ module Deployments
# Review apps have the environment type set (e.g. to `review`, though the
# exact value may differ). We don't want to link merge requests to review
# app deployments, as this is not useful.
- return if deployment.environment.environment_type
+ return unless deployment.environment.should_link_to_merge_requests?
# This service is triggered by a Sidekiq worker, which only runs when a
# deployment is successful. We add an extra check here in case we ever
diff --git a/app/services/members/create_service.rb b/app/services/members/create_service.rb
index 0cc62e661a3..cb905e01613 100644
--- a/app/services/members/create_service.rb
+++ b/app/services/members/create_service.rb
@@ -63,10 +63,14 @@ module Members
invites,
params[:access_level],
expires_at: params[:expires_at],
- current_user: current_user
+ current_user: current_user,
+ tasks_to_be_done: params[:tasks_to_be_done],
+ tasks_project_id: params[:tasks_project_id]
)
members.each { |member| process_result(member) }
+
+ create_tasks_to_be_done
end
def process_result(member)
@@ -112,6 +116,19 @@ module Members
end
end
+ def create_tasks_to_be_done
+ return unless experiment(:invite_members_for_task).enabled?
+ return if params[:tasks_to_be_done].blank? || params[:tasks_project_id].blank?
+
+ valid_members = members.select { |member| member.valid? && member.member_task.valid? }
+ return unless valid_members.present?
+
+ # We can take the first `member_task` here, since all tasks will have the same attributes needed
+ # for the `TasksToBeDone::CreateWorker`, ie. `project` and `tasks_to_be_done`.
+ member_task = valid_members[0].member_task
+ TasksToBeDone::CreateWorker.perform_async(member_task.id, current_user.id, valid_members.map(&:user_id))
+ end
+
def areas_of_focus
params[:areas_of_focus] || []
end
diff --git a/app/services/members/creator_service.rb b/app/services/members/creator_service.rb
index 7b0bebff760..f2c8a6f20a1 100644
--- a/app/services/members/creator_service.rb
+++ b/app/services/members/creator_service.rb
@@ -4,6 +4,8 @@ module Members
# This class serves as more of an app-wide way we add/create members
# All roads to add members should take this path.
class CreatorService
+ include Gitlab::Experiment::Dsl
+
class << self
def parsed_access_level(access_level)
access_levels.fetch(access_level) { access_level.to_i }
@@ -24,6 +26,7 @@ module Members
def execute
find_or_build_member
update_member
+ create_member_task
member
end
@@ -61,6 +64,21 @@ module Members
}
end
+ def create_member_task
+ return unless experiment(:invite_members_for_task).enabled?
+ return unless member.persisted?
+ return if member_task_attributes.value?(nil)
+
+ member.create_member_task(member_task_attributes)
+ end
+
+ def member_task_attributes
+ {
+ tasks_to_be_done: args[:tasks_to_be_done],
+ project_id: args[:tasks_project_id]
+ }
+ end
+
def approve_request
::Members::ApproveAccessRequestService.new(current_user,
access_level: access_level)
diff --git a/app/services/members/invite_service.rb b/app/services/members/invite_service.rb
index 257a986b8dd..85acb720f0f 100644
--- a/app/services/members/invite_service.rb
+++ b/app/services/members/invite_service.rb
@@ -39,6 +39,11 @@ module Members
errors[invite_email(member)] = member.errors.full_messages.to_sentence
end
+ override :create_tasks_to_be_done
+ def create_tasks_to_be_done
+ # Only create task issues for existing users. Tasks for new users are created when they signup.
+ end
+
def invite_email(member)
member.invite_email || member.user.email
end
diff --git a/app/services/tasks_to_be_done/base_service.rb b/app/services/tasks_to_be_done/base_service.rb
new file mode 100644
index 00000000000..a5648ad10c4
--- /dev/null
+++ b/app/services/tasks_to_be_done/base_service.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+module TasksToBeDone
+ class BaseService < ::IssuableBaseService
+ LABEL_PREFIX = 'tasks to be done'
+
+ def initialize(project:, current_user:, assignee_ids: [])
+ params = {
+ assignee_ids: assignee_ids,
+ title: title,
+ description: description,
+ add_labels: label_name
+ }
+ super(project: project, current_user: current_user, params: params)
+ end
+
+ def execute
+ if (issue = existing_task_issue)
+ update_service = Issues::UpdateService.new(project: project, current_user: current_user, params: { add_assignee_ids: params[:assignee_ids] })
+ update_service.execute(issue)
+ else
+ build_service = Issues::BuildService.new(project: project, current_user: current_user, params: params)
+ create(build_service.execute)
+ end
+ end
+
+ private
+
+ def existing_task_issue
+ IssuesFinder.new(
+ current_user,
+ project_id: project.id,
+ state: 'opened',
+ non_archived: true,
+ label_name: label_name
+ ).execute.last
+ end
+
+ def title
+ raise NotImplementedError
+ end
+
+ def description
+ raise NotImplementedError
+ end
+
+ def label_suffix
+ raise NotImplementedError
+ end
+
+ def label_name
+ "#{LABEL_PREFIX}:#{label_suffix}"
+ end
+ end
+end
diff --git a/app/services/tasks_to_be_done/create_ci_task_service.rb b/app/services/tasks_to_be_done/create_ci_task_service.rb
new file mode 100644
index 00000000000..025ca2feb8e
--- /dev/null
+++ b/app/services/tasks_to_be_done/create_ci_task_service.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+module TasksToBeDone
+ class CreateCiTaskService < BaseService
+ protected
+
+ def title
+ 'Set up CI/CD'
+ end
+
+ def description
+ <<~DESCRIPTION
+ GitLab CI/CD is a tool built into GitLab for software development through the [continuous methodologies](https://docs.gitlab.com/ee/ci/introduction/index.html#introduction-to-cicd-methodologies):
+
+ * Continuous Integration (CI)
+ * Continuous Delivery (CD)
+ * Continuous Deployment (CD)
+
+ Continuous Integration works by pushing small changes to your application’s codebase hosted in a Git repository, and, to every push, run a pipeline of scripts to build, test, and validate the code changes before merging them into the main branch.
+
+ Continuous Delivery and Deployment consist of a step further CI, deploying your application to production at every push to the default branch of the repository.
+
+ These methodologies allow you to catch bugs and errors early in the development cycle, ensuring that all the code deployed to production complies with the code standards you established for your app.
+
+ * :book: [Read the documentation](https://docs.gitlab.com/ee/ci/introduction/index.html)
+ * :clapper: [Watch a Demo](https://www.youtube.com/watch?v=1iXFbchozdY)
+
+ ## Next steps
+
+ * [ ] To start we recommend reviewing the following documentation:
+ * [ ] [How GitLab CI/CD works.](https://docs.gitlab.com/ee/ci/introduction/index.html#how-gitlab-cicd-works)
+ * [ ] [Fundamental pipeline architectures.](https://docs.gitlab.com/ee/ci/pipelines/pipeline_architectures.html)
+ * [ ] [GitLab CI/CD basic workflow.](https://docs.gitlab.com/ee/ci/introduction/index.html#basic-cicd-workflow)
+ * [ ] [Step-by-step guide for writing .gitlab-ci.yml for the first time.](https://docs.gitlab.com/ee/user/project/pages/getting_started_part_four.html)
+ * [ ] When you're ready select **Projects** (in the top navigation bar) > **Your projects** > select the Project you've already created.
+ * [ ] Select **CI / CD** in the left navigation to start setting up CI / CD in your project.
+ DESCRIPTION
+ end
+
+ def label_suffix
+ 'ci'
+ end
+ end
+end
diff --git a/app/services/tasks_to_be_done/create_code_task_service.rb b/app/services/tasks_to_be_done/create_code_task_service.rb
new file mode 100644
index 00000000000..dc3b9366a66
--- /dev/null
+++ b/app/services/tasks_to_be_done/create_code_task_service.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+
+module TasksToBeDone
+ class CreateCodeTaskService < BaseService
+ protected
+
+ def title
+ 'Create or import your code into your Project (Repository)'
+ end
+
+ def description
+ <<~DESCRIPTION
+ You've already created your Group and Project within GitLab; we'll quickly review this hierarchy below. Once you're within your project you can easily create or import repositories.
+
+ **With GitLab Groups, you can:**
+
+ * Create one or multiple Projects for hosting your codebase (repositories).
+ * Assemble related projects together.
+ * Grant members access to several projects at once.
+
+ Groups can also be nested in subgroups.
+
+ Read more about groups in our [documentation](https://docs.gitlab.com/ee/user/group/).
+
+ **Within GitLab Projects, you can**
+
+ * Use it as an issue tracker.
+ * Collaborate on code.
+ * Continuously build, test, and deploy your app with built-in GitLab CI/CD.
+
+ You can also import an existing repository by providing the Git URL.
+
+ * :book: [Read the documentation](https://docs.gitlab.com/ee/user/project/index.html).
+
+ ## Next steps
+
+ Create or import your first repository into the project you created:
+
+ * [ ] Click **Projects** in the top navigation bar, then click **Your projects**.
+ * [ ] Select the Project that you created, then select **Repository**.
+ * [ ] Once on the Repository page you can select the **+** icon to add or import files.
+ * [ ] You can review our full documentation on creating [repositories](https://docs.gitlab.com/ee/user/project/repository/) in GitLab.
+
+ :tada: All done, you can close this issue!
+ DESCRIPTION
+ end
+
+ def label_suffix
+ 'code'
+ end
+ end
+end
diff --git a/app/services/tasks_to_be_done/create_issues_task_service.rb b/app/services/tasks_to_be_done/create_issues_task_service.rb
new file mode 100644
index 00000000000..a2de6852868
--- /dev/null
+++ b/app/services/tasks_to_be_done/create_issues_task_service.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+module TasksToBeDone
+ class CreateIssuesTaskService < BaseService
+ protected
+
+ def title
+ 'Create/import issues (tickets) to collaborate on ideas and plan work'
+ end
+
+ def description
+ <<~DESCRIPTION
+ Issues allow you and your team to discuss proposals before, and during, their implementation. They can be used for a variety of other purposes, customized to your needs and workflow.
+
+ Issues are always associated with a specific project. If you have multiple projects in a group, you can view all the issues at the group level. [You can review our full Issue documentation here.](https://docs.gitlab.com/ee/user/project/issues/)
+
+ If you have existing issues or equivalent tickets you can import them as long as they are formatted as a CSV file, [the import process is covered here](https://docs.gitlab.com/ee/user/project/issues/csv_import.html).
+
+ **Common use cases include:**
+
+ * Discussing the implementation of a new idea
+ * Tracking tasks and work status
+ * Accepting feature proposals, questions, support requests, or bug reports
+ * Elaborating on new code implementations
+
+ ## Next steps
+
+ * [ ] Select **Projects** in the top navigation > **Your Projects** > select the Project you've already created.
+ * [ ] Once you've selected that project, you can select **Issues** in the left navigation, then click **New issue**.
+ * [ ] Fill in the title and description in the **New issue** page.
+ * [ ] Click on **Create issue**.
+
+ Pro tip: When you're in a group or project you can always utilize the **+** icon in the top navigation (located to the left of the search bar) to quickly create new issues.
+
+ That's it! You can close this issue.
+ DESCRIPTION
+ end
+
+ def label_suffix
+ 'issues'
+ end
+ end
+end