From 17569e185c449d7b0fd6246b53b348afb9e61ca4 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 23 Sep 2022 06:10:24 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- .../pajamas/progress_component.html.haml | 2 + app/components/pajamas/progress_component.rb | 12 ++++++ app/helpers/time_helper.rb | 6 +-- app/helpers/timeboxes_helper.rb | 12 ++---- app/presenters/ci/pipeline_presenter.rb | 2 +- app/views/projects/pipelines/_info.html.haml | 11 ++--- ...sed_fields_from_merge_request_assignees.rb | 40 +++++++++++++++++++ db/schema_migrations/20220919023208 | 1 + db/structure.sql | 11 +---- doc/ci/secure_files/index.md | 8 +++- doc/ci/yaml/index.md | 15 ++++++- doc/user/project/repository/web_editor.md | 2 +- locale/gitlab.pot | 6 +++ .../pajamas/progress_component_spec.rb | 36 +++++++++++++++++ .../pajamas/progress_component_preview.rb | 16 ++++++++ 15 files changed, 149 insertions(+), 31 deletions(-) create mode 100644 app/components/pajamas/progress_component.html.haml create mode 100644 app/components/pajamas/progress_component.rb create mode 100644 db/post_migrate/20220919023208_drop_unused_fields_from_merge_request_assignees.rb create mode 100644 db/schema_migrations/20220919023208 create mode 100644 spec/components/pajamas/progress_component_spec.rb create mode 100644 spec/components/previews/pajamas/progress_component_preview.rb diff --git a/app/components/pajamas/progress_component.html.haml b/app/components/pajamas/progress_component.html.haml new file mode 100644 index 00000000000..9368fe8b161 --- /dev/null +++ b/app/components/pajamas/progress_component.html.haml @@ -0,0 +1,2 @@ +.progress + .progress-bar{ class: "bg-#{@variant}", style: "width: #{@value}%;" } diff --git a/app/components/pajamas/progress_component.rb b/app/components/pajamas/progress_component.rb new file mode 100644 index 00000000000..1365da13863 --- /dev/null +++ b/app/components/pajamas/progress_component.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Pajamas + class ProgressComponent < Pajamas::Component + def initialize(value: 0, variant: :primary) + @value = value + @variant = filter_attribute(variant, VARIANT_OPTIONS, default: :primary) + end + + VARIANT_OPTIONS = [:primary, :success].freeze + end +end diff --git a/app/helpers/time_helper.rb b/app/helpers/time_helper.rb index ecedbfb2a4f..cb6f60ab79b 100644 --- a/app/helpers/time_helper.rb +++ b/app/helpers/time_helper.rb @@ -8,12 +8,12 @@ module TimeHelper if minutes >= 1 if seconds % 60 == 0 - pluralize(minutes, "minute") + n_('%d minute', '%d minutes', minutes) % minutes else - [pluralize(minutes, "minute"), pluralize(seconds, "second")].to_sentence + [n_('%d minute', '%d minutes', minutes) % minutes, n_('%d second', '%d seconds', seconds) % seconds].to_sentence end else - pluralize(seconds, "second") + n_('%d second', '%d seconds', seconds) % seconds end end diff --git a/app/helpers/timeboxes_helper.rb b/app/helpers/timeboxes_helper.rb index 11d09a79dcf..e0e6229bc6d 100644 --- a/app/helpers/timeboxes_helper.rb +++ b/app/helpers/timeboxes_helper.rb @@ -77,14 +77,10 @@ module TimeboxesHelper end def milestone_progress_bar(milestone) - options = { - class: 'progress-bar bg-success', - style: "width: #{milestone.percent_complete}%;" - } - - content_tag :div, class: 'progress' do - content_tag :div, nil, options - end + render Pajamas::ProgressComponent.new( + value: milestone.percent_complete, + variant: :success + ) end def milestone_time_for(date, date_type) diff --git a/app/presenters/ci/pipeline_presenter.rb b/app/presenters/ci/pipeline_presenter.rb index 32a7d205f46..fed4ae7837b 100644 --- a/app/presenters/ci/pipeline_presenter.rb +++ b/app/presenters/ci/pipeline_presenter.rb @@ -92,7 +92,7 @@ module Ci if all_related_merge_requests.none? _("No related merge requests found.") else - _("%{count} related %{pluralized_subject}: %{links}" % { + (_("%{count} related %{pluralized_subject}: %{links}") % { count: all_related_merge_requests.count, pluralized_subject: n_('merge request', 'merge requests', all_related_merge_requests.count), links: all_related_merge_request_links(limit: limit).join(', ') diff --git a/app/views/projects/pipelines/_info.html.haml b/app/views/projects/pipelines/_info.html.haml index 07e299d71ea..5db898067db 100644 --- a/app/views/projects/pipelines/_info.html.haml +++ b/app/views/projects/pipelines/_info.html.haml @@ -9,13 +9,14 @@ .well-segment.pipeline-info{ class: "gl-align-items-baseline!" } .icon-container = sprite_icon('clock', css_class: 'gl-top-0!') - = pluralize @pipeline.total_size, "job" - = @pipeline.ref_text + - jobs = n_('%d job', '%d jobs', @pipeline.total_size) % @pipeline.total_size - if @pipeline.duration - in - = time_interval_in_words(@pipeline.duration) + = s_('Pipelines|%{jobs} %{ref_text} in %{duration}').html_safe % { jobs: jobs, ref_text: @pipeline.ref_text, duration: time_interval_in_words(@pipeline.duration) } + - else + = jobs + = @pipeline.ref_text - if @pipeline.queued_duration - = "(queued for #{time_interval_in_words(@pipeline.queued_duration)})" + = s_("Pipelines|(queued for %{queued_duration})") % { queued_duration: time_interval_in_words(@pipeline.queued_duration)} - if has_pipeline_badges?(@pipeline) .well-segment.qa-pipeline-badges diff --git a/db/post_migrate/20220919023208_drop_unused_fields_from_merge_request_assignees.rb b/db/post_migrate/20220919023208_drop_unused_fields_from_merge_request_assignees.rb new file mode 100644 index 00000000000..f1afbb41893 --- /dev/null +++ b/db/post_migrate/20220919023208_drop_unused_fields_from_merge_request_assignees.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +class DropUnusedFieldsFromMergeRequestAssignees < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + def up + with_lock_retries do + if column_exists?(:merge_request_assignees, :state) # rubocop:disable Style/IfUnlessModifier + remove_column :merge_request_assignees, :state + end + + if column_exists?(:merge_request_assignees, :updated_state_by_user_id) + remove_column :merge_request_assignees, :updated_state_by_user_id + end + end + end + + def down + with_lock_retries do + unless column_exists?(:merge_request_assignees, :state) + add_column :merge_request_assignees, :state, :smallint, default: 0, null: false + end + + unless column_exists?(:merge_request_assignees, :updated_state_by_user_id) + add_column :merge_request_assignees, :updated_state_by_user_id, :bigint + end + end + + add_concurrent_index :merge_request_assignees, [:user_id, :state], + where: 'state = 2', + name: 'index_on_merge_request_assignees_user_id_and_state' + + add_concurrent_index :merge_request_assignees, :updated_state_by_user_id, + name: 'index_on_merge_request_assignees_updated_state_by_user_id' + + add_concurrent_foreign_key :merge_request_assignees, :users, + column: :updated_state_by_user_id, + on_delete: :nullify + end +end diff --git a/db/schema_migrations/20220919023208 b/db/schema_migrations/20220919023208 new file mode 100644 index 00000000000..30c305baaeb --- /dev/null +++ b/db/schema_migrations/20220919023208 @@ -0,0 +1 @@ +e4e86511961bf3618bd3683e1bc97a8382bfa1369bd76186f01cfac9e80e0593 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index fb1f550625e..7cbe648f4f0 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -17275,9 +17275,7 @@ CREATE TABLE merge_request_assignees ( id bigint NOT NULL, user_id integer NOT NULL, merge_request_id integer NOT NULL, - created_at timestamp with time zone, - state smallint DEFAULT 0 NOT NULL, - updated_state_by_user_id bigint + created_at timestamp with time zone ); CREATE SEQUENCE merge_request_assignees_id_seq @@ -29554,10 +29552,6 @@ CREATE INDEX index_on_issues_closed_incidents_by_project_id_and_closed_at ON iss CREATE INDEX index_on_label_links_all_columns ON label_links USING btree (target_id, label_id, target_type); -CREATE INDEX index_on_merge_request_assignees_updated_state_by_user_id ON merge_request_assignees USING btree (updated_state_by_user_id); - -CREATE INDEX index_on_merge_request_assignees_user_id_and_state ON merge_request_assignees USING btree (user_id, state) WHERE (state = 2); - CREATE INDEX index_on_merge_request_reviewers_user_id_and_state ON merge_request_reviewers USING btree (user_id, state) WHERE (state = 2); CREATE INDEX index_on_merge_requests_for_latest_diffs ON merge_requests USING btree (target_project_id) INCLUDE (id, latest_merge_request_diff_id); @@ -32907,9 +32901,6 @@ ALTER TABLE ONLY vulnerability_reads ALTER TABLE ONLY dast_profile_schedules ADD CONSTRAINT fk_aef03d62e5 FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL; -ALTER TABLE ONLY merge_request_assignees - ADD CONSTRAINT fk_af036e3261 FOREIGN KEY (updated_state_by_user_id) REFERENCES users(id) ON DELETE SET NULL; - ALTER TABLE ONLY analytics_cycle_analytics_group_stages ADD CONSTRAINT fk_analytics_cycle_analytics_group_stages_group_value_stream_id FOREIGN KEY (group_value_stream_id) REFERENCES analytics_cycle_analytics_group_value_streams(id) ON DELETE CASCADE; diff --git a/doc/ci/secure_files/index.md b/doc/ci/secure_files/index.md index 7a5d915a7c0..bba8a3e4c27 100644 --- a/doc/ci/secure_files/index.md +++ b/doc/ci/secure_files/index.md @@ -13,7 +13,13 @@ FLAG: On self-managed GitLab, by default this feature is not available. To make it available, ask an administrator to [enable the feature flag](../../administration/feature_flags.md) named `ci_secure_files`. Limited to 100 secure files per project. Files must be smaller -than 5 MB. The feature is not ready for production use. +than 5 MB. Project-level Secure Files is an experimental feature developed by [GitLab Incubation Engineering](https://about.gitlab.com/handbook/engineering/incubation/). + +Project-level Secure Files is still in development, but you can: + +- [Request a feature](https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/feedback/-/issues/new?issuable_template=feature_request). +- [Report a bug](https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/feedback/-/issues/new?issuable_template=report_bug). +- [Share feedback](https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/feedback/-/issues/new?issuable_template=general_feedback). You can securely store files for use in CI/CD pipelines as "secure files". These files are stored securely outside of your project's repository, and are not version controlled. diff --git a/doc/ci/yaml/index.md b/doc/ci/yaml/index.md index bd69c5c4912..478818ad361 100644 --- a/doc/ci/yaml/index.md +++ b/doc/ci/yaml/index.md @@ -3260,8 +3260,19 @@ branch or merge request pipelines. **Possible inputs**: -- An array of file paths. In GitLab 13.6 and later, [file paths can include variables](../jobs/job_control.md#variables-in-ruleschanges). -- Alternatively, the array of file paths can be in [`rules:changes:paths`](#ruleschangespaths). +An array including any number of: + +- Paths to files. In GitLab 13.6 and later, [file paths can include variables](../jobs/job_control.md#variables-in-ruleschanges). + A file path array can also be in [`rules:changes:paths`](#ruleschangespaths). +- Wildcard paths for: + - Single directories, for example `path/to/directory/*`. + - A directory and all its subdirectories, for example `path/to/directory/**/*`. +- Wildcard [glob](https://en.wikipedia.org/wiki/Glob_(programming)) paths for all files + with the same extension or multiple extensions, for example `*.md` or `path/to/directory/*.{rb,py,sh}`. + See the [Ruby `fnmatch` documentation](https://docs.ruby-lang.org/en/master/File.html#method-c-fnmatch) + for the supported syntax list. +- Wildcard paths to files in the root directory, or all directories, wrapped in double quotes. + For example `"*.json"` or `"**/*.json"`. **Example of `rules:changes`**: diff --git a/doc/user/project/repository/web_editor.md b/doc/user/project/repository/web_editor.md index 19bf6349793..05bc0207fa9 100644 --- a/doc/user/project/repository/web_editor.md +++ b/doc/user/project/repository/web_editor.md @@ -122,7 +122,7 @@ There are multiple ways to create a branch from the GitLab web interface. If your development workflow requires an issue for every merge request, you can create a branch directly from the issue to speed the process up. The new branch, and later its merge request, are marked as related to this issue. -Once merged, the merge request closes the issue. +After merging the merge request, the issue is closed automatically, unless [automatic issue closing is disabled](../issues/managing_issues.md#disable-automatic-issue-closing). You can see a **Create merge request** dropdown below the issue description. NOTE: diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 454d086f7a6..7d3a8a6ec34 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -29386,6 +29386,12 @@ msgstr "" msgid "Pipelines|\"Hello world\" with GitLab CI" msgstr "" +msgid "Pipelines|%{jobs} %{ref_text} in %{duration}" +msgstr "" + +msgid "Pipelines|(queued for %{queued_duration})" +msgstr "" + msgid "Pipelines|1. Set up a runner" msgstr "" diff --git a/spec/components/pajamas/progress_component_spec.rb b/spec/components/pajamas/progress_component_spec.rb new file mode 100644 index 00000000000..5172f459a84 --- /dev/null +++ b/spec/components/pajamas/progress_component_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require "spec_helper" + +RSpec.describe Pajamas::ProgressComponent, type: :component do + before do + render_inline(described_class.new(value: value, variant: variant)) + end + + let(:value) { 33 } + let(:variant) { nil } + + describe "value" do + it "sets the width of the progressbar" do + expect(page).to have_css ".progress-bar[style='width: #{value}%;']" + end + end + + describe "variant" do + where(:variant) { [:primary, :success] } + + with_them do + it "adds variant class" do + expect(page).to have_css ".progress-bar.bg-#{variant}" + end + end + + context "with unknown variant" do + let(:variant) { :nope } + + it "adds the default variant class" do + expect(page).to have_css ".progress-bar.bg-primary" + end + end + end +end diff --git a/spec/components/previews/pajamas/progress_component_preview.rb b/spec/components/previews/pajamas/progress_component_preview.rb new file mode 100644 index 00000000000..4de07872a80 --- /dev/null +++ b/spec/components/previews/pajamas/progress_component_preview.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Pajamas + class ProgressComponentPreview < ViewComponent::Preview + # Progress + # --- + # + # See its design reference [here](https://design.gitlab.com/components/progress-bar). + # + # @param value number + # @param variant select [primary, success] + def default(value: 50, variant: :primary) + render Pajamas::ProgressComponent.new(value: value, variant: variant) + end + end +end