Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
c5d637a04a
commit
302967a6dc
|
|
@ -1164,7 +1164,6 @@ Layout/LineLength:
|
|||
- 'ee/lib/system_check/geo/geo_database_configured_check.rb'
|
||||
- 'ee/lib/tasks/geo.rake'
|
||||
- 'ee/lib/tasks/gitlab/elastic/test.rake'
|
||||
- 'ee/lib/tasks/gitlab/seed/metrics.rake'
|
||||
- 'ee/lib/world.rb'
|
||||
- 'ee/spec/controllers/admin/elasticsearch_controller_spec.rb'
|
||||
- 'ee/spec/controllers/admin/impersonations_controller_spec.rb'
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ Rails/FilePath:
|
|||
- 'ee/lib/ee/gitlab/audit/type/definition.rb'
|
||||
- 'ee/lib/ee/gitlab/usage/metric_definition.rb'
|
||||
- 'ee/lib/gitlab/geo/health_check.rb'
|
||||
- 'ee/lib/tasks/gitlab/seed/metrics.rake'
|
||||
- 'ee/spec/db/production/license_spec.rb'
|
||||
- 'ee/spec/factories/spdx_catalogue.rb'
|
||||
- 'ee/spec/factories/vulnerabilities/findings.rb'
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const dismissUserBroadcastMessage = (id, expireDate, dismissalPath) => {
|
|||
};
|
||||
|
||||
const setBroadcastMessageHeightOffset = () => {
|
||||
const broadcastMessages = [...document.querySelectorAll('.gl-broadcast-message')];
|
||||
const broadcastMessages = [...document.querySelectorAll('[data-broadcast-banner]')];
|
||||
const broadcastMessageHeight = broadcastMessages.reduce(
|
||||
(acc, banner) => acc + banner.getBoundingClientRect().height,
|
||||
0,
|
||||
|
|
|
|||
|
|
@ -274,13 +274,13 @@ export default {
|
|||
Object.assign(line, { discussionsExpanded: expanded });
|
||||
});
|
||||
});
|
||||
} else {
|
||||
const discussions = file.discussions.map((discussion) => {
|
||||
Object.assign(discussion, { expandedOnDiff: expanded });
|
||||
return discussion;
|
||||
});
|
||||
Object.assign(file, { discussions });
|
||||
}
|
||||
|
||||
const discussions = file.discussions.map((discussion) => {
|
||||
Object.assign(discussion, { expandedOnDiff: expanded });
|
||||
return discussion;
|
||||
});
|
||||
Object.assign(file, { discussions });
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import jsYaml from 'js-yaml';
|
|||
import { isEmpty } from 'lodash';
|
||||
import {
|
||||
GlForm,
|
||||
GlIcon,
|
||||
GlLink,
|
||||
GlButton,
|
||||
GlSprintf,
|
||||
|
|
@ -122,7 +121,6 @@ export default {
|
|||
cancel: s__('WikiPage|Cancel'),
|
||||
},
|
||||
components: {
|
||||
GlIcon,
|
||||
GlForm,
|
||||
GlFormGroup,
|
||||
GlFormCheckbox,
|
||||
|
|
@ -148,10 +146,7 @@ export default {
|
|||
data() {
|
||||
const title = window.location.href.includes('random_title=true')
|
||||
? ''
|
||||
: getTitle(
|
||||
this.pageInfo,
|
||||
this.glFeatures.wikiFrontMatterTitle ? this.pageInfo.frontMatter : {},
|
||||
);
|
||||
: getTitle(this.pageInfo, this.pageInfo.frontMatter);
|
||||
const path = window.location.href.includes('random_title=true') ? '' : this.pageInfo.slug;
|
||||
return {
|
||||
editingMode: 'source',
|
||||
|
|
@ -304,8 +299,6 @@ export default {
|
|||
},
|
||||
|
||||
updateFrontMatterTitle() {
|
||||
if (!this.glFeatures.wikiFrontMatterTitle) return;
|
||||
|
||||
if (this.generatePathFromTitle) {
|
||||
delete this.frontMatter.title;
|
||||
this.path = this.title.replace(/ +/g, '-');
|
||||
|
|
@ -434,15 +427,6 @@ export default {
|
|||
label-for="wiki_title"
|
||||
:class="{ 'gl-hidden': isCustomSidebar }"
|
||||
>
|
||||
<template v-if="!isTemplate && !glFeatures.wikiFrontMatterTitle" #description>
|
||||
<div class="gl-mt-3">
|
||||
<gl-icon name="bulb" />
|
||||
{{ titleHelpText }}
|
||||
<gl-link :href="helpPath" target="_blank">
|
||||
{{ $options.i18n.title.helpText.learnMore }}
|
||||
</gl-link>
|
||||
</div>
|
||||
</template>
|
||||
<gl-form-input
|
||||
id="wiki_title"
|
||||
v-model="pageTitle"
|
||||
|
|
@ -453,16 +437,10 @@ export default {
|
|||
:autofocus="!pageInfo.persisted"
|
||||
:placeholder="titlePlaceholder"
|
||||
/>
|
||||
<input
|
||||
v-if="!glFeatures.wikiFrontMatterTitle"
|
||||
v-model="title"
|
||||
type="hidden"
|
||||
name="wiki[title]"
|
||||
/>
|
||||
</gl-form-group>
|
||||
</div>
|
||||
|
||||
<div v-if="glFeatures.wikiFrontMatterTitle" class="col-12">
|
||||
<div class="col-12">
|
||||
<gl-form-group :label="$options.i18n.path.label" label-for="wiki_path">
|
||||
<template #description>
|
||||
<gl-form-checkbox v-model="generatePathFromTitle" class="gl-pt-2">{{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
.gl-broadcast-message.broadcast-banner-message.banner{ role: 'alert',
|
||||
class: "js-broadcast-notification-#{@id} #{@theme}", data: { testid: 'banner-broadcast-message' } }
|
||||
class: "js-broadcast-notification-#{@id} #{@theme}", data: { testid: 'banner-broadcast-message', 'broadcast-banner': @banner } }
|
||||
.gl-broadcast-message-content
|
||||
.gl-broadcast-message-icon
|
||||
= sprite_icon('bullhorn')
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ module Pajamas
|
|||
# @param [String] button_testid
|
||||
def initialize(
|
||||
message:, id:, theme:, dismissable:, expire_date:, cookie_key:, dismissal_path: nil,
|
||||
button_testid: nil)
|
||||
button_testid: nil, banner: nil)
|
||||
@message = message
|
||||
@id = id
|
||||
@theme = theme
|
||||
|
|
@ -21,6 +21,7 @@ module Pajamas
|
|||
@cookie_key = cookie_key
|
||||
@dismissal_path = dismissal_path
|
||||
@button_testid = button_testid
|
||||
@banner = banner
|
||||
end
|
||||
|
||||
delegate :sprite_icon, to: :helpers
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
- empty_state_class = @compact ? 'gl-flex-direction-row' : 'gl-text-center gl-flex-direction-column'
|
||||
- empty_state_class = @compact ? 'gl-flex-row' : 'gl-text-center gl-flex-col'
|
||||
|
||||
%section.gl-display-flex.gl-empty-state{ **@empty_state_options, class: empty_state_class }
|
||||
%section.gl-flex.gl-empty-state{ **@empty_state_options, class: empty_state_class }
|
||||
- if @svg_path.present?
|
||||
- image_class = @compact ? 'gl-hidden sm:gl-block gl-px-4' : 'gl-max-w-full'
|
||||
%div{ class: image_class }
|
||||
= image_tag @svg_path, alt: "", class: 'gl-dark-invert-keep-hue'
|
||||
|
||||
- content_wrapper_class = @compact ? 'gl-flex-grow-1 gl-flex-basis-0 gl-px-4' : 'gl-m-auto gl-p-5'
|
||||
- content_wrapper_class = @compact ? 'gl-grow gl-basis-0 gl-px-4' : 'gl-m-auto gl-p-5'
|
||||
.gl-empty-state-content.gl-mx-auto.gl-my-0{ class: content_wrapper_class }
|
||||
- title_class = @compact ? 'h5' : 'h4'
|
||||
%h1.gl-font-size-h-display.gl-leading-36.gl-mt-0.gl-mb-0{ class: title_class }
|
||||
%h1.gl-text-size-h-display.gl-leading-36.gl-mt-0.gl-mb-0{ class: title_class }
|
||||
= @title
|
||||
|
||||
- if description?
|
||||
|
|
@ -17,13 +17,13 @@
|
|||
= description
|
||||
|
||||
- if @primary_button_text.present? || @secondary_button_text.present?
|
||||
- button_wrapper_class = @compact.present? ? '' : 'gl-justify-content-center'
|
||||
.gl-display-flex.gl-flex-wrap.gl-mt-5.gl-gap-3{ class: button_wrapper_class }
|
||||
- button_wrapper_class = @compact.present? ? '' : 'gl-justify-center'
|
||||
.gl-flex.gl-flex-wrap.gl-mt-5.gl-gap-3{ class: button_wrapper_class }
|
||||
|
||||
- if @primary_button_text.present?
|
||||
= render Pajamas::ButtonComponent.new(variant: :confirm, href: @primary_button_link, button_options: { class: 'gl-ml-0!', **@primary_button_options }) do
|
||||
= render Pajamas::ButtonComponent.new(variant: :confirm, href: @primary_button_link, button_options: { class: '!gl-ml-0', **@primary_button_options }) do
|
||||
= @primary_button_text
|
||||
|
||||
- if @secondary_button_text.present?
|
||||
= render Pajamas::ButtonComponent.new(variant: :default, href: @secondary_button_link, button_options: { class: ('gl-ml-0!' unless @primary_button_text.present?), **@secondary_button_options }) do
|
||||
= render Pajamas::ButtonComponent.new(variant: :default, href: @secondary_button_link, button_options: { class: ('!gl-ml-0' unless @primary_button_text.present?), **@secondary_button_options }) do
|
||||
= @secondary_button_text
|
||||
|
|
|
|||
|
|
@ -8,8 +8,4 @@ class Projects::WikisController < Projects::ApplicationController
|
|||
alias_method :container, :project
|
||||
|
||||
feature_category :wiki
|
||||
|
||||
before_action do
|
||||
push_frontend_feature_flag(:wiki_front_matter_title, project)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class WikiPage
|
|||
alias_method :to_param, :slug
|
||||
|
||||
def human_title
|
||||
return front_matter_title if Feature.enabled?(:wiki_front_matter_title, container) && front_matter_title.present?
|
||||
return front_matter_title if front_matter_title.present?
|
||||
return 'Home' if title == Wiki::HOMEPAGE
|
||||
|
||||
title
|
||||
|
|
@ -333,7 +333,6 @@ class WikiPage
|
|||
end
|
||||
|
||||
def update_front_matter(attrs)
|
||||
return unless Gitlab::WikiPages::FrontMatterParser.enabled?(container)
|
||||
return unless attrs.has_key?(:front_matter)
|
||||
|
||||
fm_yaml = serialize_front_matter(attrs[:front_matter])
|
||||
|
|
@ -344,7 +343,7 @@ class WikiPage
|
|||
|
||||
def parsed_content
|
||||
strong_memoize(:parsed_content) do
|
||||
Gitlab::WikiPages::FrontMatterParser.new(raw_content, container).parse
|
||||
Gitlab::WikiPages::FrontMatterParser.new(raw_content).parse
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@
|
|||
= render Pajamas::BroadcastBannerComponent.new(message: content, id: message.id, theme: nil, dismissable: true, expire_date: expire_date, cookie_key: cookie_key, dismissal_path: dismissal_path, button_testid: 'close-button')
|
||||
|
||||
- else
|
||||
= render Pajamas::BroadcastBannerComponent.new(message: content, id: message.id, theme: message.theme, dismissable: message.dismissable?, expire_date: expire_date, cookie_key: cookie_key, dismissal_path: dismissal_path)
|
||||
= render Pajamas::BroadcastBannerComponent.new(message: content, id: message.id, theme: message.theme, dismissable: message.dismissable?, expire_date: expire_date, cookie_key: cookie_key, dismissal_path: dismissal_path, banner: true)
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
name: wiki_front_matter
|
||||
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/27706
|
||||
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/435056
|
||||
milestone: '12.10'
|
||||
type: development
|
||||
group: group::knowledge
|
||||
default_enabled: true
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
name: wiki_front_matter_title
|
||||
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/133521
|
||||
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/428259
|
||||
milestone: '16.6'
|
||||
type: development
|
||||
group: group::knowledge
|
||||
default_enabled: true
|
||||
|
|
@ -32393,12 +32393,12 @@ ALTER TABLE ONLY protected_tag_create_access_levels
|
|||
ALTER TABLE ONLY incident_management_timeline_events
|
||||
ADD CONSTRAINT fk_38a74279df FOREIGN KEY (updated_by_user_id) REFERENCES users(id) ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE ONLY approval_group_rules_users
|
||||
ADD CONSTRAINT fk_3995d73930 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY import_export_uploads
|
||||
ADD CONSTRAINT fk_38e11735aa FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL;
|
||||
|
||||
ALTER TABLE ONLY approval_group_rules_users
|
||||
ADD CONSTRAINT fk_3995d73930 FOREIGN KEY (group_id) REFERENCES namespaces(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY bulk_import_exports
|
||||
ADD CONSTRAINT fk_39c726d3b5 FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
|
||||
|
||||
|
|
|
|||
|
|
@ -459,18 +459,6 @@ You should not use the task for routine checks as database inconsistencies might
|
|||
gitlab-rake gitlab:db:schema_checker:run
|
||||
```
|
||||
|
||||
## Import common metrics
|
||||
|
||||
Sometimes you may need to re-import the common metrics that power the Metrics dashboards.
|
||||
|
||||
This could be as a result of [updating existing metrics](../../development/prometheus_metrics.md#update-existing-metrics).
|
||||
|
||||
To re-import the metrics you can run:
|
||||
|
||||
```shell
|
||||
sudo gitlab-rake metrics:setup_common_metrics
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Advisory lock connection information
|
||||
|
|
|
|||
|
|
@ -4,59 +4,12 @@ group: Respond
|
|||
info: Any user with at least the Maintainer role can merge updates to this content. For details, see https://docs.gitlab.com/ee/development/development_processes.html#development-guidelines-review.
|
||||
---
|
||||
|
||||
# Prometheus metrics development guidelines
|
||||
|
||||
## Adding to the library
|
||||
|
||||
We strive to support the 2-4 most important metrics for each common system service that supports Prometheus. If you are looking for support for a particular exporter which has not yet been added to the library, additions can be made [to the `common_metrics.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/prometheus/common_metrics.yml) file.
|
||||
|
||||
### Query identifier
|
||||
|
||||
The requirement for adding a new metric is to make each query to have an unique identifier which is used to update the metric later when changed:
|
||||
|
||||
```yaml
|
||||
- group: Response metrics (NGINX Ingress)
|
||||
metrics:
|
||||
- title: "Throughput"
|
||||
y_axis:
|
||||
name: "Requests / Sec"
|
||||
format: "number"
|
||||
precision: 2
|
||||
queries:
|
||||
- id: response_metrics_nginx_ingress_throughput_status_code
|
||||
query_range: 'sum(rate(nginx_upstream_responses_total{upstream=~"%{kube_namespace}-%{ci_environment_slug}-.*"}[2m])) by (status_code)'
|
||||
unit: req / sec
|
||||
label: Status Code
|
||||
```
|
||||
|
||||
### Update existing metrics
|
||||
|
||||
After you add or change an existing common metric, you must [re-run the import script](../administration/raketasks/maintenance.md#import-common-metrics) that queries and updates all existing metrics.
|
||||
|
||||
Or, you can create a database migration:
|
||||
|
||||
```ruby
|
||||
class ImportCommonMetrics < Gitlab::Database::Migration[2.1]
|
||||
def up
|
||||
::Gitlab::DatabaseImporters::CommonMetrics::Importer.new.execute
|
||||
end
|
||||
|
||||
def down
|
||||
# no-op
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
If a query metric (which is identified by `id:`) is removed, it isn't removed from database by default.
|
||||
You might want to add additional database migration that makes a decision what to do with removed one.
|
||||
For example: you might be interested in migrating all dependent data to a different metric.
|
||||
|
||||
## GitLab Prometheus metrics
|
||||
# GitLab Prometheus metrics development guidelines
|
||||
|
||||
GitLab provides [Prometheus metrics](../administration/monitoring/prometheus/gitlab_metrics.md)
|
||||
to monitor itself.
|
||||
|
||||
### Adding a new metric
|
||||
## Adding a new metric
|
||||
|
||||
This section describes how to add new metrics for self-monitoring
|
||||
([example](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/15440)).
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ for previously created wikis.
|
|||
## Create the wiki home page
|
||||
|
||||
> - Separation of page title and path [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/30758) in GitLab 17.2 [with flags](../../../administration/feature_flags.md) named `wiki_front_matter` and `wiki_front_matter_title`. Enabled by default.
|
||||
> - Feature flags `wiki_front_matter` and `wiki_front_matter_title` removed in GitLab 17.3.
|
||||
|
||||
When a wiki is created, it is empty. On your first visit, you can create the
|
||||
home page users see when viewing the wiki. This page requires a specific path
|
||||
|
|
@ -72,6 +73,7 @@ to be used as your wiki's home page. To create it:
|
|||
## Create a new wiki page
|
||||
|
||||
> - Separation of page title and path [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/30758) in GitLab 17.2 [with flags](../../../administration/feature_flags.md) named `wiki_front_matter` and `wiki_front_matter_title`. Enabled by default.
|
||||
> - Feature flags `wiki_front_matter` and `wiki_front_matter_title` removed in GitLab 17.3.
|
||||
|
||||
Prerequisites:
|
||||
|
||||
|
|
@ -114,6 +116,7 @@ Files with unsupported extensions don't display when pushed to GitLab:
|
|||
|
||||
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/133521) front matter based titles in GitLab 16.7 [with flags](../../../administration/feature_flags.md) named `wiki_front_matter` and `wiki_front_matter_title`. Disabled by default.
|
||||
> - Feature flags [`wiki_front_matter`](https://gitlab.com/gitlab-org/gitlab/-/issues/435056) and [`wiki_front_matter_title`](https://gitlab.com/gitlab-org/gitlab/-/issues/428259) enabled by default in GitLab 17.2.
|
||||
> - Feature flags `wiki_front_matter` and `wiki_front_matter_title` removed in GitLab 17.3.
|
||||
|
||||
Wiki pages are stored as files in a Git repository, and by default, the filename of
|
||||
a page is also its title. Certain characters in the filename have a special meaning:
|
||||
|
|
@ -193,6 +196,7 @@ Prerequisites:
|
|||
|
||||
> - Redirects for moved or renamed wiki pages [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/257892) in GitLab 17.1 [with a flag](../../../administration/feature_flags.md) named `wiki_redirection`. Enabled by default.
|
||||
> - Separation of page title and path [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/30758) in GitLab 17.2 [with flags](../../../administration/feature_flags.md) named `wiki_front_matter` and `wiki_front_matter_title`. Enabled by default.
|
||||
> - Feature flags `wiki_front_matter` and `wiki_front_matter_title` removed in GitLab 17.3.
|
||||
|
||||
In GitLab 17.1 and later, when you move or rename a page, a redirect is
|
||||
automatically set up from the old page to the new page. A list of redirects
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ module API
|
|||
wiki_page.content.encoding.name
|
||||
end
|
||||
|
||||
expose :front_matter, documentation: { type: 'Hash', example: { title: "deploy" } }, if: ->(wiki_page) {
|
||||
::Feature.enabled?(:wiki_front_matter_title, wiki_page.container)
|
||||
}
|
||||
expose :front_matter, documentation: { type: 'Hash', example: { title: "deploy" } }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
module Gitlab
|
||||
module WikiPages
|
||||
class FrontMatterParser
|
||||
FEATURE_FLAG = :wiki_front_matter
|
||||
|
||||
# We limit the maximum length of text we are prepared to parse as YAML, to
|
||||
# avoid exploitations and attempts to consume memory and CPU. We allow for:
|
||||
# - a title line
|
||||
|
|
@ -30,18 +28,12 @@ module Gitlab
|
|||
end
|
||||
|
||||
# @param [String] wiki_content
|
||||
# @param [FeatureGate] feature_gate The scope for feature availability
|
||||
def initialize(wiki_content, feature_gate)
|
||||
def initialize(wiki_content)
|
||||
@wiki_content = wiki_content
|
||||
@feature_gate = feature_gate
|
||||
end
|
||||
|
||||
def self.enabled?(gate = nil)
|
||||
Feature.enabled?(FEATURE_FLAG, gate)
|
||||
end
|
||||
|
||||
def parse
|
||||
return empty_result unless enabled? && wiki_content.present?
|
||||
return empty_result unless wiki_content.present?
|
||||
return empty_result(block.error) unless block.valid?
|
||||
|
||||
Result.new(front_matter: block.data, content: strip_front_matter_block)
|
||||
|
|
@ -94,16 +86,12 @@ module Gitlab
|
|||
|
||||
private
|
||||
|
||||
attr_reader :wiki_content, :feature_gate
|
||||
attr_reader :wiki_content
|
||||
|
||||
def empty_result(reason = nil, error = nil)
|
||||
Result.new(content: wiki_content, reason: reason, error: error)
|
||||
end
|
||||
|
||||
def enabled?
|
||||
self.class.enabled?(feature_gate)
|
||||
end
|
||||
|
||||
def block
|
||||
@block ||= parse_front_matter_block
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ RSpec.describe Pajamas::BroadcastBannerComponent, :aggregate_failures, type: :co
|
|||
expire_date: expire_date,
|
||||
cookie_key: cookie_key,
|
||||
dismissal_path: dismissal_path,
|
||||
button_testid: button_testid
|
||||
button_testid: button_testid,
|
||||
banner: banner
|
||||
)
|
||||
end
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ RSpec.describe Pajamas::BroadcastBannerComponent, :aggregate_failures, type: :co
|
|||
let(:cookie_key) { '_cookie_key_' }
|
||||
let(:dismissal_path) { '/-/my-path' }
|
||||
let(:button_testid) { 'my-close-button' }
|
||||
let(:banner) { true }
|
||||
|
||||
it 'sets the correct classes' do
|
||||
expect(page).to have_selector(".js-broadcast-notification-#{id}")
|
||||
|
|
@ -66,4 +68,8 @@ RSpec.describe Pajamas::BroadcastBannerComponent, :aggregate_failures, type: :co
|
|||
it 'sets the button testid' do
|
||||
expect(page).to have_selector("button[data-testid='#{button_testid}']")
|
||||
end
|
||||
|
||||
it 'adds data-broadcast-banner when banner is true' do
|
||||
expect(page).to have_selector("[data-broadcast-banner]")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ RSpec.describe Pajamas::EmptyStateComponent, type: :component, feature_category:
|
|||
|
||||
it 'renders section with flex direction column' do
|
||||
expect(find_section[:id]).to eq(empty_state_options[:id])
|
||||
expect(find_section[:class]).to eq("gl-display-flex gl-empty-state gl-text-center gl-flex-direction-column")
|
||||
expect(find_section[:class]).to eq("gl-flex gl-empty-state gl-text-center gl-flex-col")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ RSpec.describe Pajamas::EmptyStateComponent, type: :component, feature_category:
|
|||
let(:compact) { true }
|
||||
|
||||
it 'renders section with flex direction row' do
|
||||
expect(find_section[:class]).to eq("gl-display-flex gl-empty-state gl-flex-direction-row")
|
||||
expect(find_section[:class]).to eq("gl-flex gl-empty-state gl-flex-row")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@ RSpec.describe 'Broadcast Messages', feature_category: :notifications do
|
|||
|
||||
expect_to_be_on_explore_projects_page
|
||||
|
||||
find(".js-dismiss-current-broadcast-notification[data-id='#{broadcast_message.id}']").click
|
||||
within('body.page-initialised') do
|
||||
find(".js-dismiss-current-broadcast-notification[data-id='#{broadcast_message.id}']").click
|
||||
end
|
||||
|
||||
expect_message_dismissed
|
||||
end
|
||||
|
|
@ -41,7 +43,9 @@ RSpec.describe 'Broadcast Messages', feature_category: :notifications do
|
|||
|
||||
expect_to_be_on_explore_projects_page
|
||||
|
||||
find(".js-dismiss-current-broadcast-notification[data-id='#{broadcast_message.id}']").click
|
||||
within('body.page-initialised') do
|
||||
find(".js-dismiss-current-broadcast-notification[data-id='#{broadcast_message.id}']").click
|
||||
end
|
||||
|
||||
expect_message_dismissed
|
||||
|
||||
|
|
@ -57,7 +61,9 @@ RSpec.describe 'Broadcast Messages', feature_category: :notifications do
|
|||
|
||||
expect_to_be_on_explore_projects_page
|
||||
|
||||
find(".js-dismiss-current-broadcast-notification[data-id='#{broadcast_message.id}']").click
|
||||
within('body.page-initialised') do
|
||||
find(".js-dismiss-current-broadcast-notification[data-id='#{broadcast_message.id}']").click
|
||||
end
|
||||
|
||||
expect_message_dismissed
|
||||
|
||||
|
|
@ -98,9 +104,7 @@ RSpec.describe 'Broadcast Messages', feature_category: :notifications do
|
|||
|
||||
it_behaves_like 'a Broadcast Messages'
|
||||
|
||||
context 'when quarantined shared example', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/474308' do
|
||||
it_behaves_like 'a dismissible Broadcast Messages'
|
||||
end
|
||||
it_behaves_like 'a dismissible Broadcast Messages'
|
||||
end
|
||||
|
||||
describe 'notification type' do
|
||||
|
|
|
|||
|
|
@ -113,10 +113,10 @@ describe('broadcast message on dismiss', () => {
|
|||
describe('setBroadcastMessageHeightOffset', () => {
|
||||
beforeEach(() => {
|
||||
setHTMLFixture(`
|
||||
<div class="gl-broadcast-message">
|
||||
<div data-broadcast-banner class="gl-broadcast-message">
|
||||
Here is a broadcast message
|
||||
</div>
|
||||
<div class="gl-broadcast-message">
|
||||
<div data-broadcast-banner class="gl-broadcast-message">
|
||||
Here is another broadcast message
|
||||
</div>
|
||||
`);
|
||||
|
|
|
|||
|
|
@ -1322,6 +1322,7 @@ describe('DiffsStoreMutations', () => {
|
|||
[INLINE_DIFF_LINES_KEY]: [
|
||||
{ line_code: 'foo', discussions: [{}], discussionsExpanded: false },
|
||||
],
|
||||
discussions: [{ expandedOnDiff: false }],
|
||||
},
|
||||
{
|
||||
[INLINE_DIFF_LINES_KEY]: [],
|
||||
|
|
@ -1333,6 +1334,7 @@ describe('DiffsStoreMutations', () => {
|
|||
mutations[types.SET_EXPAND_ALL_DIFF_DISCUSSIONS](state, true);
|
||||
|
||||
expect(state.diffFiles[0][INLINE_DIFF_LINES_KEY][0].discussionsExpanded).toBe(true);
|
||||
expect(state.diffFiles[0].discussions[0].expandedOnDiff).toBe(true);
|
||||
expect(state.diffFiles[1].discussions[0].expandedOnDiff).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ describe('WikiForm', () => {
|
|||
const findMarkdownEditor = () => wrapper.findComponent(MarkdownEditor);
|
||||
const findSubmitButton = () => wrapper.findByTestId('wiki-submit-button');
|
||||
const findCancelButton = () => wrapper.findByTestId('wiki-cancel-button');
|
||||
const findTitleHelpLink = () => wrapper.findByText('Learn more.');
|
||||
|
||||
const findMarkdownHelpLink = () => wrapper.findByTestId('wiki-markdown-help-link');
|
||||
const findTemplatesDropdown = () => wrapper.findComponent(WikiTemplate);
|
||||
|
||||
|
|
@ -67,6 +67,7 @@ describe('WikiForm', () => {
|
|||
const pageInfoPersisted = {
|
||||
...pageInfoNew,
|
||||
persisted: true,
|
||||
slug: 'My-page',
|
||||
title: 'My page',
|
||||
content: ' My page content ',
|
||||
format: 'markdown',
|
||||
|
|
@ -327,20 +328,6 @@ describe('WikiForm', () => {
|
|||
expect(wrapper.text()).toContain(text);
|
||||
});
|
||||
|
||||
it.each`
|
||||
persisted | titleHelpText | titleHelpLink
|
||||
${true} | ${'You can move this page by adding the path to the beginning of the title.'} | ${'/help/user/project/wiki/index#move-a-wiki-page'}
|
||||
${false} | ${'You can specify the full path for the new file. We will automatically create any missing directories.'} | ${'/help/user/project/wiki/index#create-a-new-wiki-page'}
|
||||
`(
|
||||
'shows appropriate title help text and help link for when persisted=$persisted',
|
||||
({ persisted, titleHelpLink, titleHelpText }) => {
|
||||
createWrapper({ persisted });
|
||||
|
||||
expect(wrapper.text()).toContain(titleHelpText);
|
||||
expect(findTitleHelpLink().attributes().href).toBe(titleHelpLink);
|
||||
},
|
||||
);
|
||||
|
||||
it('shows correct link for wiki specific markdown docs', () => {
|
||||
createWrapper({ mountFn: mount });
|
||||
|
||||
|
|
@ -366,7 +353,7 @@ describe('WikiForm', () => {
|
|||
['authenticity_token', ''],
|
||||
['_method', 'put'],
|
||||
['wiki[last_commit_sha]', ''],
|
||||
['wiki[title]', 'My page'],
|
||||
['wiki[title]', 'My-page'],
|
||||
['wiki[format]', 'markdown'],
|
||||
['wiki[content]', ' Lorem ipsum dolar sit! '],
|
||||
['wiki[message]', 'Update My page'],
|
||||
|
|
@ -506,12 +493,11 @@ describe('WikiForm', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('when wiki_front_matter_title feature flag is enabled', () => {
|
||||
describe('path field', () => {
|
||||
beforeEach(() => {
|
||||
createWrapper({
|
||||
mountFn: mount,
|
||||
pageInfo: pageInfoWithFrontmatter(),
|
||||
provide: { glFeatures: { wikiFrontMatterTitle: true } },
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -571,32 +557,4 @@ describe('WikiForm', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when wiki_front_matter_title feature flag is disabled', () => {
|
||||
beforeEach(() => {
|
||||
createWrapper({
|
||||
mountFn: mount,
|
||||
pageInfo: pageInfoWithFrontmatter(),
|
||||
provide: { glFeatures: { wikiFrontMatterTitle: false } },
|
||||
});
|
||||
});
|
||||
|
||||
it('does not show the path field', () => {
|
||||
expect(findPath().exists()).toBe(false);
|
||||
});
|
||||
|
||||
it("retains page's frontmatter on form submit", async () => {
|
||||
await findForm().trigger('submit');
|
||||
|
||||
expect([...getFormData().entries()]).toEqual([
|
||||
['authenticity_token', ''],
|
||||
['_method', 'put'],
|
||||
['wiki[last_commit_sha]', 'abcdef123'],
|
||||
['wiki[title]', 'bar'],
|
||||
['wiki[format]', 'markdown'],
|
||||
['wiki[content]', '---\nfoo: bar\ntitle: real page title\n---\nfoo bar'],
|
||||
['wiki[message]', 'Update bar'],
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,11 +3,10 @@
|
|||
require 'spec_helper'
|
||||
|
||||
RSpec.describe Gitlab::WikiPages::FrontMatterParser do
|
||||
subject(:parser) { described_class.new(raw_content, gate) }
|
||||
subject(:parser) { described_class.new(raw_content) }
|
||||
|
||||
let(:content) { 'This is the content' }
|
||||
let(:end_divider) { '---' }
|
||||
let(:gate) { stub_feature_flag_gate('Gate') }
|
||||
|
||||
let(:with_front_matter) do
|
||||
<<~MD
|
||||
|
|
@ -62,23 +61,9 @@ RSpec.describe Gitlab::WikiPages::FrontMatterParser do
|
|||
it { is_expected.to have_attributes(reason: :no_match) }
|
||||
end
|
||||
|
||||
context 'the feature flag is disabled' do
|
||||
context 'default' do
|
||||
let(:raw_content) { with_front_matter }
|
||||
|
||||
before do
|
||||
stub_feature_flags(Gitlab::WikiPages::FrontMatterParser::FEATURE_FLAG => false)
|
||||
end
|
||||
|
||||
it { is_expected.to have_attributes(front_matter: be_empty, content: raw_content) }
|
||||
end
|
||||
|
||||
context 'the feature flag is enabled for the gated object' do
|
||||
let(:raw_content) { with_front_matter }
|
||||
|
||||
before do
|
||||
stub_feature_flags(Gitlab::WikiPages::FrontMatterParser::FEATURE_FLAG => gate)
|
||||
end
|
||||
|
||||
it do
|
||||
is_expected.to have_attributes(
|
||||
front_matter: have_correct_front_matter,
|
||||
|
|
|
|||
|
|
@ -33,14 +33,6 @@ RSpec.describe WikiPage, feature_category: :wiki do
|
|||
build(:wiki_page, wiki_page_attrs)
|
||||
end
|
||||
|
||||
def disable_front_matter
|
||||
stub_feature_flags(Gitlab::WikiPages::FrontMatterParser::FEATURE_FLAG => false)
|
||||
end
|
||||
|
||||
def enable_front_matter_for(thing)
|
||||
stub_feature_flags(Gitlab::WikiPages::FrontMatterParser::FEATURE_FLAG => thing)
|
||||
end
|
||||
|
||||
def force_wiki_change_branch
|
||||
old_default_branch = wiki.default_branch
|
||||
wiki.repository.add_branch(user, 'another_branch', old_default_branch)
|
||||
|
|
@ -92,22 +84,6 @@ RSpec.describe WikiPage, feature_category: :wiki do
|
|||
it 'strips the front matter from the content' do
|
||||
expect(wiki_page.content.strip).to eq('My actual content')
|
||||
end
|
||||
|
||||
context 'the feature flag is off' do
|
||||
before do
|
||||
disable_front_matter
|
||||
end
|
||||
|
||||
it_behaves_like 'a page without front-matter'
|
||||
|
||||
context 'but enabled for the container' do
|
||||
before do
|
||||
enable_front_matter_for(container)
|
||||
end
|
||||
|
||||
it_behaves_like 'a page with front-matter'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'the wiki page does not have front matter' do
|
||||
|
|
@ -526,29 +502,6 @@ RSpec.describe WikiPage, feature_category: :wiki do
|
|||
end
|
||||
end
|
||||
|
||||
context 'the front-matter feature flag is not enabled' do
|
||||
before do
|
||||
disable_front_matter
|
||||
end
|
||||
|
||||
it 'does not update the front-matter' do
|
||||
content = subject.content
|
||||
subject.update(front_matter: { slugs: ['x'] })
|
||||
|
||||
page = wiki.find_page(subject.title)
|
||||
|
||||
expect([subject, page]).to all(have_attributes(front_matter: be_empty, content: content))
|
||||
end
|
||||
|
||||
context 'but it is enabled for the container' do
|
||||
before do
|
||||
enable_front_matter_for(container)
|
||||
end
|
||||
|
||||
it_behaves_like 'able to update front-matter'
|
||||
end
|
||||
end
|
||||
|
||||
it 'updates the wiki-page front-matter and content together' do
|
||||
content = 'totally new content'
|
||||
subject.update(content: content, front_matter: { slugs: ['x'] })
|
||||
|
|
@ -1112,20 +1065,8 @@ RSpec.describe WikiPage, feature_category: :wiki do
|
|||
let(:content_with_front_matter_title) { "---\ntitle: #{front_matter_title}\n---\nHome Page" }
|
||||
let(:wiki_page) { create(:wiki_page, container: container, content: content_with_front_matter_title) }
|
||||
|
||||
context "when wiki_front_matter_title enabled" do
|
||||
it 'returns the front matter title' do
|
||||
expect(wiki_page.human_title).to eq front_matter_title
|
||||
end
|
||||
end
|
||||
|
||||
context "when wiki_front_matter_title disabled" do
|
||||
before do
|
||||
stub_feature_flags(wiki_front_matter_title: false)
|
||||
end
|
||||
|
||||
it 'returns the page title' do
|
||||
expect(wiki_page.human_title).to eq wiki_page.title
|
||||
end
|
||||
it 'returns the front matter title' do
|
||||
expect(wiki_page.human_title).to eq front_matter_title
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,28 +38,3 @@ RSpec.shared_context 'self-managed prometheus alert attributes' do
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.shared_context 'gitlab-managed prometheus alert attributes' do
|
||||
let_it_be(:prometheus_alert) { create(:prometheus_alert, project: project) }
|
||||
let(:prometheus_metric_id) { prometheus_alert.prometheus_metric_id }
|
||||
|
||||
let(:payload) do
|
||||
{
|
||||
'startsAt' => '2018-03-12T09:06:00Z',
|
||||
'labels' => {
|
||||
'gitlab_alert_id' => prometheus_metric_id
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
let(:dashboard_url_for_alert) do
|
||||
Gitlab::Routing.url_helpers.metrics_dashboard_project_prometheus_alert_url(
|
||||
project,
|
||||
prometheus_metric_id,
|
||||
environment_id: prometheus_alert.environment_id,
|
||||
embedded: true,
|
||||
end: '2018-03-12T09:36:00Z',
|
||||
start: '2018-03-12T08:36:00Z'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -79,35 +79,6 @@ RSpec.shared_examples 'User updates wiki page' do
|
|||
expect(page).to have_content('My awesome wiki!')
|
||||
end
|
||||
|
||||
context 'when :wiki_front_matter feature flags are disabled' do
|
||||
before do
|
||||
stub_feature_flags(
|
||||
wiki_front_matter: false,
|
||||
wiki_front_matter_title: false
|
||||
)
|
||||
|
||||
visit(wiki_path(wiki))
|
||||
click_on('Edit')
|
||||
end
|
||||
|
||||
it 'updates entry in redirects.yml file on changing page title' do
|
||||
wiki.repository.update_file(
|
||||
user, '.gitlab/redirects.yml',
|
||||
"home2: home\nfoo: bar",
|
||||
message: 'Add redirect', branch_name: 'master'
|
||||
)
|
||||
|
||||
fill_in(:wiki_title, with: 'home2')
|
||||
fill_in(:wiki_content, with: 'My awesome wiki!')
|
||||
click_button('Save changes')
|
||||
|
||||
expect(page).to have_content('Home')
|
||||
expect(page).to have_content('My awesome wiki!')
|
||||
|
||||
expect(wiki.repository.blob_at('master', '.gitlab/redirects.yml').data).to eq("---\nfoo: bar\nhome: home2\n")
|
||||
end
|
||||
end
|
||||
|
||||
it 'updates entry in redirects.yml file on changing page path' do
|
||||
wiki.repository.update_file(
|
||||
user, '.gitlab/redirects.yml',
|
||||
|
|
@ -239,65 +210,6 @@ RSpec.shared_examples 'User updates wiki page' do
|
|||
visit wiki_page_path(wiki, wiki_page, action: :edit)
|
||||
end
|
||||
|
||||
context 'when wiki_front_matter feature flags are disabled' do
|
||||
before do
|
||||
stub_feature_flags(
|
||||
wiki_front_matter: false,
|
||||
wiki_front_matter_title: false
|
||||
)
|
||||
|
||||
visit wiki_page_path(wiki, wiki_page, action: :edit)
|
||||
end
|
||||
|
||||
it 'moves the page to the root folder on changing the title', :js do
|
||||
fill_in(:wiki_title, with: "/#{page_name}")
|
||||
|
||||
click_button('Save changes')
|
||||
|
||||
expect(page).to have_current_path(wiki_page_path(wiki, page_name), ignore_query: true)
|
||||
end
|
||||
|
||||
it 'moves the page to other dir on changing the title', :js do
|
||||
new_page_dir = "foo1/bar1/#{page_name}"
|
||||
|
||||
fill_in(:wiki_title, with: new_page_dir)
|
||||
|
||||
click_button('Save changes')
|
||||
|
||||
expect(page).to have_current_path(wiki_page_path(wiki, new_page_dir), ignore_query: true)
|
||||
end
|
||||
|
||||
it 'can be moved to a different dir with a different name by changing the title', :js do
|
||||
new_page_dir = "foo1/bar1/new_page_name"
|
||||
|
||||
fill_in(:wiki_title, with: new_page_dir)
|
||||
|
||||
click_button('Save changes')
|
||||
|
||||
expect(page).to have_current_path(wiki_page_path(wiki, new_page_dir), ignore_query: true)
|
||||
end
|
||||
|
||||
it 'can be renamed and moved to the root folder by changing the title', :js do
|
||||
new_name = 'new_page_name'
|
||||
|
||||
fill_in(:wiki_title, with: "/#{new_name}")
|
||||
|
||||
click_button('Save changes')
|
||||
|
||||
expect(page).to have_current_path(wiki_page_path(wiki, new_name), ignore_query: true)
|
||||
end
|
||||
|
||||
it 'squishes the title before creating the page', :js do
|
||||
new_page_dir = " foo1 / bar1 / #{page_name} "
|
||||
|
||||
fill_in(:wiki_title, with: new_page_dir)
|
||||
|
||||
click_button('Save changes')
|
||||
|
||||
expect(page).to have_current_path(wiki_page_path(wiki, "foo1/bar1/#{page_name}"), ignore_query: true)
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not move the page to root folder on changing the title' do
|
||||
fill_in(:wiki_title, with: "/#{page_name}")
|
||||
|
||||
|
|
@ -386,24 +298,6 @@ RSpec.shared_examples 'User updates wiki page' do
|
|||
visit wiki_page_path(wiki_page.wiki, wiki_page, action: :edit)
|
||||
end
|
||||
|
||||
context 'when wiki_front_matter feature flags are disabled' do
|
||||
before do
|
||||
stub_feature_flags(
|
||||
wiki_front_matter: false,
|
||||
wiki_front_matter_title: false
|
||||
)
|
||||
|
||||
visit wiki_page_path(wiki_page.wiki, wiki_page, action: :edit)
|
||||
end
|
||||
|
||||
it 'allows changing the title if the content does not change', :js do
|
||||
fill_in :wiki_title, with: 'new title'
|
||||
click_on 'Save changes'
|
||||
|
||||
expect(page).to have_content('Wiki page was successfully updated.')
|
||||
end
|
||||
end
|
||||
|
||||
it 'allows changing the path if the content does not change', :js do
|
||||
fill_in :wiki_path, with: 'new-path'
|
||||
click_on 'Save changes'
|
||||
|
|
|
|||
|
|
@ -1,31 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.shared_examples 'regex which matches url when expected' do
|
||||
it { is_expected.to be_a Regexp }
|
||||
|
||||
it 'matches a metrics dashboard link with named params' do
|
||||
expect(subject).to match url
|
||||
|
||||
subject.match(url) do |m|
|
||||
expect(m.named_captures).to eq expected_params
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not match other gitlab urls that contain the term metrics' do
|
||||
url = Gitlab::Routing.url_helpers.active_common_namespace_project_prometheus_metrics_url('foo', 'bar', :json)
|
||||
|
||||
expect(subject).not_to match url
|
||||
end
|
||||
|
||||
it 'does not match other gitlab urls' do
|
||||
url = Gitlab.config.gitlab.url
|
||||
|
||||
expect(subject).not_to match url
|
||||
end
|
||||
|
||||
it 'does not match non-gitlab urls' do
|
||||
url = 'https://www.super_awesome_site.com/'
|
||||
|
||||
expect(subject).not_to match url
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue