Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-07-04 06:09:21 +00:00
parent 0869145fab
commit 529d16eb9c
15 changed files with 216 additions and 18 deletions

View file

@ -81,7 +81,7 @@ Please list the test areas (unit, integration and end-to-end) that needs to be a
* Integration test changes
* End-to-end test change
See the test engineering planning process and reach out to your counterpart Software Engineer in Test for assistance: https://about.gitlab.com/handbook/engineering/quality/test-engineering/#test-planning -->
See the Quality Engineering quad planning process and reach out to your counterpart Software Engineer in Test for assistance: https://about.gitlab.com/handbook/engineering/quality/quality-engineering/quad-planning -->
### Available Tier

View file

@ -1,5 +1,5 @@
<script>
import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
import { GlIcon, GlTooltipDirective, GlOutsideDirective as Outside } from '@gitlab/ui';
import { mapGetters, mapActions } from 'vuex';
import { __, sprintf } from '~/locale';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
@ -28,6 +28,7 @@ export default {
},
directives: {
GlTooltip: GlTooltipDirective,
Outside,
},
mixins: [glFeatureFlagMixin()],
inject: ['fullPath'],
@ -102,6 +103,9 @@ export default {
this.isLoading = false;
});
},
closeForm() {
this.isLockDialogOpen = false;
},
},
};
</script>
@ -148,6 +152,7 @@ export default {
<div class="value sidebar-item-value hide-collapsed">
<edit-form
v-if="isLockDialogOpen"
v-outside="closeForm"
data-testid="edit-form"
:is-locked="isLocked"
:issuable-display-name="issuableDisplayName"

View file

@ -0,0 +1,17 @@
# frozen_string_literal: true
module Projects
class ProjectCreatedEvent < ::Gitlab::EventStore::Event
def schema
{
'type' => 'object',
'properties' => {
'project_id' => { 'type' => 'integer' },
'namespace_id' => { 'type' => 'integer' },
'root_namespace_id' => { 'type' => 'integer' }
},
'required' => %w[project_id namespace_id root_namespace_id]
}
end
end
end

View file

@ -129,6 +129,8 @@ module Projects
create_readme if @initialize_with_readme
create_sast_commit if @initialize_with_sast
publish_event
end
def create_project_settings
@ -294,6 +296,16 @@ module Projects
params[:topic_list] ||= topic_list if topic_list
end
def publish_event
event = Projects::ProjectCreatedEvent.new(data: {
project_id: project.id,
namespace_id: project.namespace_id,
root_namespace_id: project.root_namespace.id
})
Gitlab::EventStore.publish(event)
end
end
end

View file

@ -9,32 +9,35 @@ info: To determine the technical writer assigned to the Stage/Group associated w
You can create users:
- Manually through the sign in page or Administrator Area.
- Automatically through user authentication integrations.
- [Manually through the sign-in page](#create-users-on-sign-in-page).
- [Manually in the Admin Area](#create-users-in-admin-area).
- [Manually using the API](../../../api/users.md).
- [Automatically through user authentication integrations](#create-users-through-authentication-integrations).
## Create users on sign in page
## Create users on sign-in page
If you have [sign-up enabled](../../admin_area/settings/sign_up_restrictions.md), users can create
their own accounts by either:
Prerequisites:
- [Sign-up enabled](../../admin_area/settings/sign_up_restrictions.md)
Users can create their own accounts by either:
- Selecting the **Register now** link on the sign-in page.
- Navigating to `https://gitlab.example.com/users/sign_up`.
![Register Tab](img/register_v13_6.png)
- Navigating to your GitLab instance's sign-up link. For example: `https://gitlab.example.com/users/sign_up`.
## Create users in Admin Area
As an Administrator user, you can manually create users:
Prerequisites:
- You must have administrator access for the instance.
To create a user manually:
1. On the top bar, select **Menu > Admin**.
1. On the left sidebar, select **Overview > Users** (`/admin/users`).
1. Select **New user**.
You can also [create users through the API](../../../api/users.md) as an administrator.
![Administrator User Button](img/admin_user_button.png)
![Administrator User Form](img/admin_user_form.png)
1. Complete the fields.
1. Select **Create user**.
## Create users through authentication integrations

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

View file

@ -37,7 +37,7 @@ module Gitlab
user_id: user_id,
issue_id: issue_event.issue_db_id,
source_commit: issue_event.commit_id,
state: ResourceStateEvent.states[:closed],
state: 'closed',
close_after_error_tracking_resolve: false,
close_auto_resolve_prometheus_alert: false,
created_at: issue_event.created_at

View file

@ -0,0 +1,47 @@
# frozen_string_literal: true
module Gitlab
module GithubImport
module Importer
module Events
class Reopened
attr_reader :project, :user_id
def initialize(project, user_id)
@project = project
@user_id = user_id
end
# issue_event - An instance of `Gitlab::GithubImport::Representation::IssueEvent`.
def execute(issue_event)
create_event(issue_event)
create_state_event(issue_event)
end
private
def create_event(issue_event)
Event.create!(
project_id: project.id,
author_id: user_id,
action: 'reopened',
target_type: Issue.name,
target_id: issue_event.issue_db_id,
created_at: issue_event.created_at,
updated_at: issue_event.created_at
)
end
def create_state_event(issue_event)
ResourceStateEvent.create!(
user_id: user_id,
issue_id: issue_event.issue_db_id,
state: 'reopened',
created_at: issue_event.created_at
)
end
end
end
end
end
end

View file

@ -21,6 +21,9 @@ module Gitlab
when 'closed'
Gitlab::GithubImport::Importer::Events::Closed.new(project, author_id)
.execute(issue_event)
when 'reopened'
Gitlab::GithubImport::Importer::Events::Reopened.new(project, author_id)
.execute(issue_event)
else
Gitlab::GithubImport::Logger.debug(
message: 'UNSUPPORTED_EVENT_TYPE',

View file

@ -0,0 +1,34 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Projects::ProjectCreatedEvent do
where(:data, :valid) do
[
[{ project_id: 1, namespace_id: 2, root_namespace_id: 3 }, true],
[{ project_id: 1 }, false],
[{ namespace_id: 1 }, false],
[{ project_id: 'foo', namespace_id: 2 }, false],
[{ project_id: 1, namespace_id: 'foo' }, false],
[{ project_id: [], namespace_id: 2 }, false],
[{ project_id: 1, namespace_id: [] }, false],
[{ project_id: {}, namespace_id: 2 }, false],
[{ project_id: 1, namespace_id: {} }, false],
['foo', false],
[123, false],
[[], false]
]
end
with_them do
it 'validates data' do
constructor = -> { described_class.new(data: data) }
if valid
expect { constructor.call }.not_to raise_error
else
expect { constructor.call }.to raise_error(Gitlab::EventStore::InvalidEvent)
end
end
end
end

View file

@ -0,0 +1,56 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::GithubImport::Importer::Events::Reopened, :aggregate_failures do
subject(:importer) { described_class.new(project, user.id) }
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
let(:issue) { create(:issue, project: project) }
let(:issue_event) do
Gitlab::GithubImport::Representation::IssueEvent.from_json_hash(
'id' => 6501124486,
'node_id' => 'CE_lADOHK9fA85If7x0zwAAAAGDf0mG',
'url' => 'https://api.github.com/repos/elhowm/test-import/issues/events/6501124486',
'actor' => { 'id' => 4, 'login' => 'alice' },
'event' => 'reopened',
'created_at' => '2022-04-26 18:30:53 UTC',
'issue_db_id' => issue.id
)
end
let(:expected_event_attrs) do
{
project_id: project.id,
author_id: user.id,
target_id: issue.id,
target_type: Issue.name,
action: 'reopened',
created_at: issue_event.created_at,
updated_at: issue_event.created_at
}.stringify_keys
end
let(:expected_state_event_attrs) do
{
user_id: user.id,
state: 'reopened',
created_at: issue_event.created_at
}.stringify_keys
end
it 'creates expected event and state event' do
importer.execute(issue_event)
expect(issue.events.count).to eq 1
expect(issue.events[0].attributes)
.to include expected_event_attrs
expect(issue.resource_state_events.count).to eq 1
expect(issue.resource_state_events[0].attributes)
.to include expected_state_event_attrs
end
end

View file

@ -59,6 +59,13 @@ RSpec.describe Gitlab::GithubImport::Importer::IssueEventImporter, :clean_gitlab
Gitlab::GithubImport::Importer::Events::Closed
end
context "when it's reopened issue event" do
let(:event_name) { 'reopened' }
it_behaves_like 'triggers specific event importer',
Gitlab::GithubImport::Importer::Events::Reopened
end
context "when it's unknown issue event" do
let(:event_name) { 'fake' }

View file

@ -152,6 +152,20 @@ RSpec.describe Projects::CreateService, '#execute' do
create_project(user, opts)
end
it 'publishes a ProjectCreatedEvent' do
group = create(:group, :nested).tap do |group|
group.add_owner(user)
end
expect { create_project(user, name: 'Project', path: 'project', namespace_id: group.id) }
.to publish_event(Projects::ProjectCreatedEvent)
.with(
project_id: kind_of(Numeric),
namespace_id: group.id,
root_namespace_id: group.parent_id
)
end
end
context "admin creates project with other user's namespace_id" do