From dad16033c2b7cfd54ffe20ca5cc1d844e9e41be6 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 5 May 2022 15:08:47 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .gitlab/CODEOWNERS | 4 - .rubocop_todo/layout/hash_alignment.yml | 1 - .rubocop_todo/layout/line_length.yml | 1 - .rubocop_todo/rails/time_zone.yml | 2 - .rubocop_todo/rspec/verified_doubles.yml | 2 - .rubocop_todo/style/percent_literal_delimiters.yml | 1 - .../components/bubble_menus/formatting.vue | 13 +- .../components/bubble_menus/link.vue | 18 +- .../components/bubble_menus/media.vue | 288 +++++++++++++++++++++ .../content_editor/components/content_editor.vue | 3 + .../content_editor/components/wrappers/media.vue | 51 ---- .../javascripts/content_editor/extensions/image.js | 5 - .../content_editor/extensions/playable.js | 6 - .../content_editor/services/asset_resolver.js | 13 + .../content_editor/services/content_editor.js | 28 +- .../services/create_content_editor.js | 11 +- .../content_editor/services/upload_helpers.js | 4 + .../javascripts/content_editor/services/utils.js | 2 +- .../pages/projects/services/edit/index.js | 3 - .../prometheus_alerts/components/reset_key.vue | 149 ----------- app/assets/javascripts/prometheus_alerts/index.js | 28 -- .../runner/admin_runners/admin_runners_app.vue | 104 ++++---- .../runner/group_runners/group_runners_app.vue | 111 ++++---- .../components/states/ready_to_merge.vue | 6 +- .../vue_shared/components/markdown/field.vue | 2 - .../stylesheets/components/content_editor.scss | 6 +- .../profiles/personal_access_tokens_controller.rb | 2 - .../on_direct_membership_finder.rb | 62 +++++ app/finders/personal_access_tokens_finder.rb | 2 - app/helpers/personal_access_tokens_helper.rb | 7 - app/models/application_setting.rb | 1 + app/models/personal_access_token.rb | 4 - .../_account_and_limit.html.haml | 1 - .../application_settings/_note_limits.html.haml | 2 +- .../_users_api_limits.html.haml | 2 +- .../services/prometheus/_external_alerts.html.haml | 8 - .../projects/services/prometheus/_show.html.haml | 2 - .../projects/services/prometheus/_top.html.haml | 9 - app/views/shared/access_tokens/_table.html.haml | 15 +- config/initializers/1_settings.rb | 3 - .../20210216175446_network_policy_forwards.yml | 4 +- .../20210216175448_network_policy_drops.yml | 4 +- config/sidekiq_queues.yml | 2 + .../14-7-deprecate-static-site-editor.yml | 4 +- ...ject_group_link_with_group_id_and_project_id.rb | 18 ++ ...502150408_add_slack_integrations_bot_columns.rb | 11 + ...dd_slack_integrations_bot_user_id_text_limit.rb | 13 + ...dex_for_group_group_link_with_both_group_ids.rb | 18 ++ db/schema_migrations/20220502125053 | 1 + db/schema_migrations/20220502150408 | 1 + db/schema_migrations/20220502152633 | 1 + db/schema_migrations/20220503073401 | 1 + db/structure.sql | 10 +- doc/administration/index.md | 4 - doc/administration/object_storage.md | 3 +- doc/administration/pseudonymizer.md | 123 +-------- .../reference_architectures/10k_users.md | 1 - .../reference_architectures/25k_users.md | 1 - .../reference_architectures/2k_users.md | 1 - .../reference_architectures/3k_users.md | 1 - .../reference_architectures/50k_users.md | 1 - .../reference_architectures/5k_users.md | 1 - doc/administration/terraform_state.md | 2 +- doc/api/settings.md | 1 - doc/ci/variables/index.md | 4 +- doc/update/deprecations.md | 4 +- doc/user/admin_area/credentials_inventory.md | 13 +- .../settings/account_and_limit_settings.md | 16 +- doc/user/admin_area/settings/index.md | 2 - .../img/confidential_comments_v13_9.png | Bin 8311 -> 0 bytes .../img/confidential_comments_v15_0.png | Bin 0 -> 12775 bytes doc/user/discussions/index.md | 4 +- doc/user/group/index.md | 16 +- doc/user/profile/personal_access_tokens.md | 2 - .../integrations/gitlab_slack_application.md | 22 +- .../img/edit_this_page_button_v12_10.png | Bin 28949 -> 0 bytes .../img/front_matter_ui_v13_4.png | Bin 36431 -> 0 bytes .../img/wysiwyg_editor_v13_3.png | Bin 57177 -> 0 bytes doc/user/project/static_site_editor/index.md | 264 +------------------ locale/gitlab.pot | 118 ++++----- .../gitaly/praefect_replication_queue_spec.rb | 5 +- spec/db/schema_spec.rb | 2 +- ..._issue_for_discussions_in_merge_request_spec.rb | 6 +- .../user_accepts_merge_request_spec.rb | 14 +- .../merge_request/user_assigns_themselves_spec.rb | 6 - .../merge_request/user_awards_emoji_spec.rb | 4 + .../user_customizes_merge_commit_message_spec.rb | 8 +- .../merge_request/user_merges_immediately_spec.rb | 10 +- .../user_merges_merge_request_spec.rb | 1 + .../user_merges_only_if_pipeline_succeeds_spec.rb | 2 +- .../user_merges_when_pipeline_succeeds_spec.rb | 13 +- .../merge_request/user_sees_merge_widget_spec.rb | 8 +- .../user_squashes_merge_request_spec.rb | 2 +- .../prometheus_external_alerts_spec.rb | 34 --- .../on_direct_membership_finder_spec.rb | 73 ++++++ spec/finders/personal_access_tokens_finder_spec.rb | 18 -- .../components/bubble_menus/link_spec.js | 22 +- .../components/bubble_menus/media_spec.js | 234 +++++++++++++++++ .../components/wrappers/media_spec.js | 69 ----- .../content_editor/extensions/attachment_spec.js | 32 +-- .../content_editor/services/asset_resolver_spec.js | 23 ++ .../content_editor/services/content_editor_spec.js | 2 +- spec/frontend/content_editor/test_constants.js | 25 ++ .../prometheus_alerts/components/reset_key_spec.js | 99 ------- .../runner/admin_runners/admin_runners_app_spec.js | 82 +++++- .../runner/group_runners/group_runners_app_spec.js | 82 +++++- .../states/mr_widget_ready_to_merge_spec.js | 3 - .../container_repositories/destroy_spec.rb | 2 +- .../container_repositories/destroy_tags_spec.rb | 8 +- .../customer_relations/contacts/create_spec.rb | 6 +- .../mutations/discussions/toggle_resolve_spec.rb | 8 +- .../environments/canary_ingress/update_spec.rb | 2 +- .../mutations/release_asset_links/delete_spec.rb | 4 +- .../mutations/release_asset_links/update_spec.rb | 4 +- spec/graphql/mutations/timelogs/delete_spec.rb | 6 +- .../resolvers/concerns/resolves_ids_spec.rb | 14 +- .../design_at_version_resolver_spec.rb | 2 +- .../design_management/design_resolver_spec.rb | 4 +- .../design_management/designs_resolver_spec.rb | 4 +- .../sentry_detailed_error_resolver_spec.rb | 2 +- spec/graphql/resolvers/timelog_resolver_spec.rb | 2 +- spec/graphql/resolvers/work_item_resolver_spec.rb | 2 +- .../types/terraform/state_version_type_spec.rb | 4 +- spec/models/personal_access_token_spec.rb | 8 - .../api/graphql/boards/board_lists_query_spec.rb | 6 +- spec/requests/api/graphql/ci/job_spec.rb | 15 +- .../container_repository_details_spec.rb | 8 +- .../api/graphql/current_user_todos_spec.rb | 8 +- .../group/dependency_proxy_manifests_spec.rb | 4 +- .../api/graphql/group/group_members_spec.rb | 8 +- .../api/graphql/group/merge_requests_spec.rb | 2 +- spec/requests/api/graphql/group/milestones_spec.rb | 8 +- spec/requests/api/graphql/issue/issue_spec.rb | 5 +- .../graphql/merge_request/merge_request_spec.rb | 2 +- .../mutations/issues/set_crm_contacts_spec.rb | 22 +- .../graphql/mutations/notes/create/note_spec.rb | 2 +- .../notes/reposition_image_diff_note_spec.rb | 4 +- .../graphql/mutations/todos/mark_all_done_spec.rb | 8 +- .../graphql/mutations/todos/restore_many_spec.rb | 8 +- spec/requests/api/graphql/packages/conan_spec.rb | 21 +- spec/requests/api/graphql/packages/maven_spec.rb | 8 +- spec/requests/api/graphql/packages/nuget_spec.rb | 17 +- spec/requests/api/graphql/packages/pypi_spec.rb | 5 +- .../project/alert_management/integrations_spec.rb | 57 ++-- .../api/graphql/project/cluster_agents_spec.rb | 8 +- .../issue/design_collection/version_spec.rb | 29 +-- .../graphql/project/issue/designs/designs_spec.rb | 14 +- .../graphql/project/issue/designs/notes_spec.rb | 2 +- spec/requests/api/graphql/project/issue_spec.rb | 7 +- .../api/graphql/project/merge_request_spec.rb | 2 +- .../api/graphql/project/merge_requests_spec.rb | 14 +- .../api/graphql/project/milestones_spec.rb | 2 +- spec/requests/api/graphql/project/pipeline_spec.rb | 19 +- .../api/graphql/project/project_members_spec.rb | 9 +- spec/requests/api/graphql/project/release_spec.rb | 40 +-- .../api/graphql/project/terraform/state_spec.rb | 18 +- .../api/graphql/project/terraform/states_spec.rb | 17 +- spec/requests/api/graphql/query_spec.rb | 16 +- .../graphql/user/starred_projects_query_spec.rb | 18 +- spec/requests/api/graphql/user_query_spec.rb | 72 +++--- spec/requests/api/graphql/users_spec.rb | 24 +- spec/spec_helper.rb | 3 - spec/support/graphql/arguments.rb | 4 +- spec/support/helpers/graphql_helpers.rb | 94 ++++++- .../graphql/requests/packages_shared_context.rb | 2 +- .../sorted_paginated_query_shared_examples.rb | 10 +- .../api/graphql/noteable_shared_examples.rb | 16 +- ...up_and_project_packages_list_shared_examples.rb | 2 +- .../packages/package_details_shared_examples.rb | 12 +- .../integrations_shared_examples.rb | 10 +- spec/support_specs/helpers/graphql_helpers_spec.rb | 75 ++++++ .../shared/access_tokens/_table.html.haml_spec.rb | 41 +-- spec/workers/every_sidekiq_worker_spec.rb | 1 - 173 files changed, 1758 insertions(+), 1676 deletions(-) create mode 100644 app/assets/javascripts/content_editor/components/bubble_menus/media.vue delete mode 100644 app/assets/javascripts/content_editor/components/wrappers/media.vue create mode 100644 app/assets/javascripts/content_editor/services/asset_resolver.js delete mode 100644 app/assets/javascripts/prometheus_alerts/components/reset_key.vue delete mode 100644 app/assets/javascripts/prometheus_alerts/index.js create mode 100644 app/finders/groups/projects_requiring_authorizations_refresh/on_direct_membership_finder.rb delete mode 100644 app/helpers/personal_access_tokens_helper.rb delete mode 100644 app/views/projects/services/prometheus/_external_alerts.html.haml delete mode 100644 app/views/projects/services/prometheus/_top.html.haml create mode 100644 db/migrate/20220502125053_recreate_index_for_project_group_link_with_group_id_and_project_id.rb create mode 100644 db/migrate/20220502150408_add_slack_integrations_bot_columns.rb create mode 100644 db/migrate/20220502152633_add_slack_integrations_bot_user_id_text_limit.rb create mode 100644 db/migrate/20220503073401_recreate_index_for_group_group_link_with_both_group_ids.rb create mode 100644 db/schema_migrations/20220502125053 create mode 100644 db/schema_migrations/20220502150408 create mode 100644 db/schema_migrations/20220502152633 create mode 100644 db/schema_migrations/20220503073401 delete mode 100644 doc/user/discussions/img/confidential_comments_v13_9.png create mode 100644 doc/user/discussions/img/confidential_comments_v15_0.png delete mode 100644 doc/user/project/static_site_editor/img/edit_this_page_button_v12_10.png delete mode 100644 doc/user/project/static_site_editor/img/front_matter_ui_v13_4.png delete mode 100644 doc/user/project/static_site_editor/img/wysiwyg_editor_v13_3.png delete mode 100644 spec/features/projects/integrations/prometheus_external_alerts_spec.rb create mode 100644 spec/finders/groups/projects_requiring_authorizations_refresh/on_direct_membership_finder_spec.rb create mode 100644 spec/frontend/content_editor/components/bubble_menus/media_spec.js delete mode 100644 spec/frontend/content_editor/components/wrappers/media_spec.js create mode 100644 spec/frontend/content_editor/services/asset_resolver_spec.js create mode 100644 spec/frontend/content_editor/test_constants.js delete mode 100644 spec/frontend/prometheus_alerts/components/reset_key_spec.js diff --git a/.gitlab/CODEOWNERS b/.gitlab/CODEOWNERS index 3e57949eeda..1a4d182c3d1 100644 --- a/.gitlab/CODEOWNERS +++ b/.gitlab/CODEOWNERS @@ -118,14 +118,10 @@ Dangerfile @gl-quality/eng-prod /spec/models/clusters/applications/cilium_spec.rb @gitlab-org/protect/container-security-backend /ee/app/controllers/projects/security/network_policies_controller.rb @gitlab-org/protect/container-security-backend /ee/spec/controllers/projects/security/network_policies_controller_spec.rb @gitlab-org/protect/container-security-backend -/ee/app/workers/network_policy_metrics_worker.rb @gitlab-org/protect/container-security-backend -/ee/spec/workers/network_policy_metrics_worker_spec.rb @gitlab-org/protect/container-security-backend /ee/app/services/network_policies/** @gitlab-org/protect/container-security-backend /ee/spec/services/network_policies/** @gitlab-org/protect/container-security-backend /ee/app/services/security/orchestration/** @gitlab-org/protect/container-security-backend /ee/spec/services/security/orchestration/** @gitlab-org/protect/container-security-backend -/ee/lib/gitlab/usage_data_counters/network_policy_counter.rb @gitlab-org/protect/container-security-backend -/ee/spec/lib/gitlab/usage_data_counters/network_policy_counter_spec.rb @gitlab-org/protect/container-security-backend ^[Code Owners] /ee/lib/gitlab/code_owners.rb @reprazent @kerrizor @garyh diff --git a/.rubocop_todo/layout/hash_alignment.yml b/.rubocop_todo/layout/hash_alignment.yml index aafacd5f265..b13a561958e 100644 --- a/.rubocop_todo/layout/hash_alignment.yml +++ b/.rubocop_todo/layout/hash_alignment.yml @@ -383,7 +383,6 @@ Layout/HashAlignment: - 'ee/lib/gitlab/elastic/helper.rb' - 'ee/lib/gitlab/elastic/indexer.rb' - 'ee/lib/gitlab/geo/replication/base_transfer.rb' - - 'ee/lib/gitlab/prometheus/queries/packet_flow_query.rb' - 'ee/spec/controllers/ee/projects/variables_controller_spec.rb' - 'ee/spec/controllers/groups/epic_boards_controller_spec.rb' - 'ee/spec/controllers/groups/issues_controller_spec.rb' diff --git a/.rubocop_todo/layout/line_length.yml b/.rubocop_todo/layout/line_length.yml index d46c7a6da62..f80c3f20437 100644 --- a/.rubocop_todo/layout/line_length.yml +++ b/.rubocop_todo/layout/line_length.yml @@ -4424,7 +4424,6 @@ Layout/LineLength: - 'spec/features/projects/files/user_browses_files_spec.rb' - 'spec/features/projects/files/user_edits_files_spec.rb' - 'spec/features/projects/infrastructure_registry_spec.rb' - - 'spec/features/projects/integrations/prometheus_external_alerts_spec.rb' - 'spec/features/projects/integrations/user_activates_issue_tracker_spec.rb' - 'spec/features/projects/integrations/user_activates_jira_spec.rb' - 'spec/features/projects/integrations/user_uses_inherited_settings_spec.rb' diff --git a/.rubocop_todo/rails/time_zone.yml b/.rubocop_todo/rails/time_zone.yml index 86d0632ac47..ff97dfeb444 100644 --- a/.rubocop_todo/rails/time_zone.yml +++ b/.rubocop_todo/rails/time_zone.yml @@ -13,7 +13,6 @@ Rails/TimeZone: - ee/lib/gitlab/geo/log_cursor/logger.rb - ee/lib/gitlab/geo/oauth/login_state.rb - ee/lib/gitlab/prometheus/queries/cluster_query.rb - - ee/lib/gitlab/prometheus/queries/packet_flow_query.rb - ee/spec/lib/ee/gitlab/checks/push_rules/commit_check_spec.rb - ee/spec/lib/ee/gitlab/ci/pipeline/quota/job_activity_spec.rb - ee/spec/lib/gitlab/analytics/cycle_analytics/data_collector_spec.rb @@ -44,7 +43,6 @@ Rails/TimeZone: - ee/spec/lib/gitlab/git_access_spec.rb - ee/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb - ee/spec/lib/gitlab/prometheus/queries/cluster_query_spec.rb - - ee/spec/lib/gitlab/prometheus/queries/packet_flow_query_spec.rb - lib/api/helpers.rb - lib/api/sidekiq_metrics.rb - lib/backup/manager.rb diff --git a/.rubocop_todo/rspec/verified_doubles.yml b/.rubocop_todo/rspec/verified_doubles.yml index e272fbc555c..70fb8414f55 100644 --- a/.rubocop_todo/rspec/verified_doubles.yml +++ b/.rubocop_todo/rspec/verified_doubles.yml @@ -90,8 +90,6 @@ RSpec/VerifiedDoubles: - ee/spec/lib/gitlab/middleware/ip_restrictor_spec.rb - ee/spec/lib/gitlab/patch/legacy_database_config_spec.rb - ee/spec/lib/gitlab/prometheus/queries/cluster_query_spec.rb - - ee/spec/lib/gitlab/prometheus/queries/packet_flow_metrics_query_spec.rb - - ee/spec/lib/gitlab/prometheus/queries/packet_flow_query_spec.rb - ee/spec/lib/gitlab/subscription_portal/clients/rest_spec.rb - ee/spec/lib/sidebars/groups/menus/analytics_menu_spec.rb - ee/spec/lib/system_check/app/elasticsearch_check_spec.rb diff --git a/.rubocop_todo/style/percent_literal_delimiters.yml b/.rubocop_todo/style/percent_literal_delimiters.yml index 4673f0d71d2..bf50c4c1922 100644 --- a/.rubocop_todo/style/percent_literal_delimiters.yml +++ b/.rubocop_todo/style/percent_literal_delimiters.yml @@ -324,7 +324,6 @@ Style/PercentLiteralDelimiters: - 'ee/lib/gitlab/ci/parsers/security/formatters/dast.rb' - 'ee/lib/gitlab/geo.rb' - 'ee/lib/gitlab/geo/replicator.rb' - - 'ee/lib/gitlab/prometheus/queries/packet_flow_query.rb' - 'ee/lib/gitlab/usage/metrics/instrumentations/license_metric.rb' - 'ee/lib/tasks/gitlab/elastic/test.rake' - 'ee/spec/config/metrics/every_metric_definition_spec.rb' diff --git a/app/assets/javascripts/content_editor/components/bubble_menus/formatting.vue b/app/assets/javascripts/content_editor/components/bubble_menus/formatting.vue index 46c15de6b2c..e35fbf14de5 100644 --- a/app/assets/javascripts/content_editor/components/bubble_menus/formatting.vue +++ b/app/assets/javascripts/content_editor/components/bubble_menus/formatting.vue @@ -3,6 +3,9 @@ import { GlButtonGroup } from '@gitlab/ui'; import { BubbleMenu } from '@tiptap/vue-2'; import { BUBBLE_MENU_TRACKING_ACTION } from '../../constants'; import trackUIControl from '../../services/track_ui_control'; +import Image from '../../extensions/image'; +import Audio from '../../extensions/audio'; +import Video from '../../extensions/video'; import Code from '../../extensions/code'; import CodeBlockHighlight from '../../extensions/code_block_highlight'; import Diagram from '../../extensions/diagram'; @@ -24,7 +27,15 @@ export default { shouldShow: ({ editor, from, to }) => { if (from === to) return false; - const exclude = [Code.name, CodeBlockHighlight.name, Diagram.name, Frontmatter.name]; + const exclude = [ + Code.name, + CodeBlockHighlight.name, + Diagram.name, + Frontmatter.name, + Image.name, + Audio.name, + Video.name, + ]; return !exclude.some((type) => editor.isActive(type)); }, diff --git a/app/assets/javascripts/content_editor/components/bubble_menus/link.vue b/app/assets/javascripts/content_editor/components/bubble_menus/link.vue index 2f446832516..abd225c0b1a 100644 --- a/app/assets/javascripts/content_editor/components/bubble_menus/link.vue +++ b/app/assets/javascripts/content_editor/components/bubble_menus/link.vue @@ -26,7 +26,7 @@ export default { directives: { GlTooltip, }, - inject: ['tiptapEditor'], + inject: ['tiptapEditor', 'contentEditor'], data() { return { linkHref: undefined, @@ -57,9 +57,11 @@ export default { this.isEditing = true; }, - endEditingLink() { + async endEditingLink() { this.isEditing = false; + this.linkHref = await this.contentEditor.resolveLink(this.linkCanonicalSrc); + if (!this.linkCanonicalSrc && !this.linkHref) { this.removeLink(); } @@ -70,7 +72,7 @@ export default { this.updateLinkToState(); }, - saveEditedLink() { + async saveEditedLink() { if (!this.linkCanonicalSrc) { this.removeLink(); } else { @@ -166,12 +168,12 @@ export default { @click="removeLink" /> - - - + + + - - + +
diff --git a/app/assets/javascripts/content_editor/components/bubble_menus/media.vue b/app/assets/javascripts/content_editor/components/bubble_menus/media.vue new file mode 100644 index 00000000000..d1bc5c83948 --- /dev/null +++ b/app/assets/javascripts/content_editor/components/bubble_menus/media.vue @@ -0,0 +1,288 @@ + + diff --git a/app/assets/javascripts/content_editor/components/content_editor.vue b/app/assets/javascripts/content_editor/components/content_editor.vue index a3247298b19..74ae37b6d06 100644 --- a/app/assets/javascripts/content_editor/components/content_editor.vue +++ b/app/assets/javascripts/content_editor/components/content_editor.vue @@ -7,6 +7,7 @@ import EditorStateObserver from './editor_state_observer.vue'; import FormattingBubbleMenu from './bubble_menus/formatting.vue'; import CodeBlockBubbleMenu from './bubble_menus/code_block.vue'; import LinkBubbleMenu from './bubble_menus/link.vue'; +import MediaBubbleMenu from './bubble_menus/media.vue'; import TopToolbar from './top_toolbar.vue'; import LoadingIndicator from './loading_indicator.vue'; @@ -20,6 +21,7 @@ export default { FormattingBubbleMenu, CodeBlockBubbleMenu, LinkBubbleMenu, + MediaBubbleMenu, EditorStateObserver, }, props: { @@ -95,6 +97,7 @@ export default { +
diff --git a/app/assets/javascripts/content_editor/components/wrappers/media.vue b/app/assets/javascripts/content_editor/components/wrappers/media.vue deleted file mode 100644 index 37119bdd066..00000000000 --- a/app/assets/javascripts/content_editor/components/wrappers/media.vue +++ /dev/null @@ -1,51 +0,0 @@ - - diff --git a/app/assets/javascripts/content_editor/extensions/image.js b/app/assets/javascripts/content_editor/extensions/image.js index 311db8151cb..25f976f524f 100644 --- a/app/assets/javascripts/content_editor/extensions/image.js +++ b/app/assets/javascripts/content_editor/extensions/image.js @@ -1,6 +1,4 @@ import { Image } from '@tiptap/extension-image'; -import { VueNodeViewRenderer } from '@tiptap/vue-2'; -import MediaWrapper from '../components/wrappers/media.vue'; import { PARSE_HTML_PRIORITY_HIGHEST } from '../constants'; const resolveImageEl = (element) => @@ -77,7 +75,4 @@ export default Image.extend({ }, ]; }, - addNodeView() { - return VueNodeViewRenderer(MediaWrapper); - }, }); diff --git a/app/assets/javascripts/content_editor/extensions/playable.js b/app/assets/javascripts/content_editor/extensions/playable.js index 2c5269377c5..ed343d8acf8 100644 --- a/app/assets/javascripts/content_editor/extensions/playable.js +++ b/app/assets/javascripts/content_editor/extensions/playable.js @@ -1,8 +1,6 @@ /* eslint-disable @gitlab/require-i18n-strings */ import { Node } from '@tiptap/core'; -import { VueNodeViewRenderer } from '@tiptap/vue-2'; -import MediaWrapper from '../components/wrappers/media.vue'; const queryPlayableElement = (element, mediaType) => element.querySelector(mediaType); @@ -68,8 +66,4 @@ export default Node.create({ ['a', { href: node.attrs.src }, node.attrs.title || node.attrs.alt || ''], ]; }, - - addNodeView() { - return VueNodeViewRenderer(MediaWrapper); - }, }); diff --git a/app/assets/javascripts/content_editor/services/asset_resolver.js b/app/assets/javascripts/content_editor/services/asset_resolver.js new file mode 100644 index 00000000000..942457b9664 --- /dev/null +++ b/app/assets/javascripts/content_editor/services/asset_resolver.js @@ -0,0 +1,13 @@ +import { memoize } from 'lodash'; + +export default ({ renderMarkdown }) => ({ + resolveUrl: memoize(async (canonicalSrc) => { + const html = await renderMarkdown(`[link](${canonicalSrc})`); + if (!html) return canonicalSrc; + + const parser = new DOMParser(); + const { body } = parser.parseFromString(html, 'text/html'); + + return body.querySelector('a').getAttribute('href'); + }), +}); diff --git a/app/assets/javascripts/content_editor/services/content_editor.js b/app/assets/javascripts/content_editor/services/content_editor.js index 21843c482a8..b993851a92f 100644 --- a/app/assets/javascripts/content_editor/services/content_editor.js +++ b/app/assets/javascripts/content_editor/services/content_editor.js @@ -3,12 +3,13 @@ import { LOADING_CONTENT_EVENT, LOADING_SUCCESS_EVENT, LOADING_ERROR_EVENT } fro /* eslint-disable no-underscore-dangle */ export class ContentEditor { - constructor({ tiptapEditor, serializer, deserializer, eventHub, languageLoader }) { + constructor({ tiptapEditor, serializer, deserializer, assetResolver, eventHub, languageLoader }) { this._tiptapEditor = tiptapEditor; this._serializer = serializer; this._deserializer = deserializer; this._eventHub = eventHub; this._languageLoader = languageLoader; + this._assetResolver = assetResolver; } get tiptapEditor() { @@ -34,22 +35,27 @@ export class ContentEditor { this._eventHub.dispose(); } + deserialize(serializedContent) { + const { _tiptapEditor: editor, _deserializer: deserializer } = this; + + return deserializer.deserialize({ + schema: editor.schema, + content: serializedContent, + }); + } + + resolveAssetUrl(canonicalSrc) { + return this._assetResolver.resolveUrl(canonicalSrc); + } + async setSerializedContent(serializedContent) { - const { - _tiptapEditor: editor, - _deserializer: deserializer, - _eventHub: eventHub, - _languageLoader: languageLoader, - } = this; + const { _tiptapEditor: editor, _eventHub: eventHub, _languageLoader: languageLoader } = this; const { doc, tr } = editor.state; const selection = TextSelection.create(doc, 0, doc.content.size); try { eventHub.$emit(LOADING_CONTENT_EVENT); - const result = await deserializer.deserialize({ - schema: editor.schema, - content: serializedContent, - }); + const result = await this.deserialize(serializedContent); if (Object.keys(result).length !== 0) { const { document, languages } = result; diff --git a/app/assets/javascripts/content_editor/services/create_content_editor.js b/app/assets/javascripts/content_editor/services/create_content_editor.js index 28041504e3c..adb1398b2c4 100644 --- a/app/assets/javascripts/content_editor/services/create_content_editor.js +++ b/app/assets/javascripts/content_editor/services/create_content_editor.js @@ -60,6 +60,7 @@ import { ContentEditor } from './content_editor'; import createMarkdownSerializer from './markdown_serializer'; import createGlApiMarkdownDeserializer from './gl_api_markdown_deserializer'; import createRemarkMarkdownDeserializer from './remark_markdown_deserializer'; +import createAssetResolver from './asset_resolver'; import trackInputRulesAndShortcuts from './track_input_rules_and_shortcuts'; import languageLoader from './code_block_language_loader'; @@ -152,6 +153,14 @@ export const createContentEditor = ({ : createGlApiMarkdownDeserializer({ render: renderMarkdown, }); + const assetResolver = createAssetResolver({ renderMarkdown }); - return new ContentEditor({ tiptapEditor, serializer, eventHub, deserializer, languageLoader }); + return new ContentEditor({ + tiptapEditor, + serializer, + eventHub, + deserializer, + languageLoader, + assetResolver, + }); }; diff --git a/app/assets/javascripts/content_editor/services/upload_helpers.js b/app/assets/javascripts/content_editor/services/upload_helpers.js index ed2c4b39131..09f0738b51b 100644 --- a/app/assets/javascripts/content_editor/services/upload_helpers.js +++ b/app/assets/javascripts/content_editor/services/upload_helpers.js @@ -70,6 +70,8 @@ const uploadContent = async ({ type, editor, file, uploadsPath, renderMarkdown, const position = state.selection.from - 1; const { tr } = state; + editor.commands.setNodeSelection(position); + try { const { src, canonicalSrc } = await uploadFile({ file, uploadsPath, renderMarkdown }); @@ -81,6 +83,8 @@ const uploadContent = async ({ type, editor, file, uploadsPath, renderMarkdown, canonicalSrc, }), ); + + editor.commands.setNodeSelection(position); } catch (e) { editor.commands.deleteRange({ from: position, to: position + 1 }); eventHub.$emit('alert', { diff --git a/app/assets/javascripts/content_editor/services/utils.js b/app/assets/javascripts/content_editor/services/utils.js index b3856b0dd74..e352fa8a9db 100644 --- a/app/assets/javascripts/content_editor/services/utils.js +++ b/app/assets/javascripts/content_editor/services/utils.js @@ -15,7 +15,7 @@ export const hasSelection = (tiptapEditor) => { * @returns {string} */ export const extractFilename = (src) => { - return src.replace(/^.*\/|\..+?$/g, ''); + return src.replace(/^.*\/|\.[^.]+?$/g, ''); }; export const readFileAsDataURL = (file) => { diff --git a/app/assets/javascripts/pages/projects/services/edit/index.js b/app/assets/javascripts/pages/projects/services/edit/index.js index 2048d3dfc37..64df0d07d74 100644 --- a/app/assets/javascripts/pages/projects/services/edit/index.js +++ b/app/assets/javascripts/pages/projects/services/edit/index.js @@ -1,5 +1,4 @@ import initIntegrationSettingsForm from '~/integrations/edit'; -import PrometheusAlerts from '~/prometheus_alerts'; import CustomMetrics from '~/prometheus_metrics/custom_metrics'; initIntegrationSettingsForm(); @@ -10,5 +9,3 @@ if (prometheusSettingsWrapper) { const customMetrics = new CustomMetrics(prometheusSettingsSelector); customMetrics.init(); } - -PrometheusAlerts(); diff --git a/app/assets/javascripts/prometheus_alerts/components/reset_key.vue b/app/assets/javascripts/prometheus_alerts/components/reset_key.vue deleted file mode 100644 index befbca48736..00000000000 --- a/app/assets/javascripts/prometheus_alerts/components/reset_key.vue +++ /dev/null @@ -1,149 +0,0 @@ - - - diff --git a/app/assets/javascripts/prometheus_alerts/index.js b/app/assets/javascripts/prometheus_alerts/index.js deleted file mode 100644 index 7efe6ed186b..00000000000 --- a/app/assets/javascripts/prometheus_alerts/index.js +++ /dev/null @@ -1,28 +0,0 @@ -import Vue from 'vue'; -import ResetKey from './components/reset_key.vue'; - -export default () => { - const el = document.querySelector('#js-settings-prometheus-alerts'); - - if (!el) { - return; - } - - const { authorizationKey, changeKeyUrl, notifyUrl, learnMoreUrl, disabled } = el.dataset; - - // eslint-disable-next-line no-new - new Vue({ - el, - render(createElement) { - return createElement(ResetKey, { - props: { - initialAuthorizationKey: authorizationKey, - changeKeyUrl, - notifyUrl, - learnMoreUrl, - disabled, - }, - }); - }, - }); -}; diff --git a/app/assets/javascripts/runner/admin_runners/admin_runners_app.vue b/app/assets/javascripts/runner/admin_runners/admin_runners_app.vue index accc9926a57..c2bb635e056 100644 --- a/app/assets/javascripts/runner/admin_runners/admin_runners_app.vue +++ b/app/assets/javascripts/runner/admin_runners/admin_runners_app.vue @@ -38,7 +38,7 @@ import { } from '../runner_search_utils'; import { captureException } from '../sentry_utils'; -const runnersCountSmartQuery = { +const countSmartQuery = () => ({ query: runnersAdminCountQuery, fetchPolicy: fetchPolicies.NETWORK_ONLY, update(data) { @@ -47,6 +47,39 @@ const runnersCountSmartQuery = { error(error) { this.reportToSentry(error); }, +}); + +const tabCountSmartQuery = ({ type }) => { + return { + ...countSmartQuery(), + variables() { + return { + ...this.countVariables, + type, + }; + }, + }; +}; + +const statusCountSmartQuery = ({ status, name }) => { + return { + ...countSmartQuery(), + skip() { + // skip if filtering by status and not using _this_ status as filter + if (this.countVariables.status && this.countVariables.status !== status) { + // reset count for given status + this[name] = null; + return true; + } + return false; + }, + variables() { + return { + ...this.countVariables, + status, + }; + }, + }; }; export default { @@ -101,65 +134,30 @@ export default { this.reportToSentry(error); }, }, + + // Tabs counts allRunnersCount: { - ...runnersCountSmartQuery, - variables() { - return { - ...this.countVariables, - type: null, - }; - }, + ...tabCountSmartQuery({ type: null }), }, instanceRunnersCount: { - ...runnersCountSmartQuery, - variables() { - return { - ...this.countVariables, - type: INSTANCE_TYPE, - }; - }, + ...tabCountSmartQuery({ type: INSTANCE_TYPE }), }, groupRunnersCount: { - ...runnersCountSmartQuery, - variables() { - return { - ...this.countVariables, - type: GROUP_TYPE, - }; - }, + ...tabCountSmartQuery({ type: GROUP_TYPE }), }, projectRunnersCount: { - ...runnersCountSmartQuery, - variables() { - return { - ...this.countVariables, - type: PROJECT_TYPE, - }; - }, + ...tabCountSmartQuery({ type: PROJECT_TYPE }), }, + + // Runner stats onlineRunnersTotal: { - ...runnersCountSmartQuery, - variables() { - return { - status: STATUS_ONLINE, - }; - }, + ...statusCountSmartQuery({ status: STATUS_ONLINE, name: 'onlineRunnersTotal' }), }, offlineRunnersTotal: { - ...runnersCountSmartQuery, - variables() { - return { - status: STATUS_OFFLINE, - }; - }, + ...statusCountSmartQuery({ status: STATUS_OFFLINE, name: 'offlineRunnersTotal' }), }, staleRunnersTotal: { - ...runnersCountSmartQuery, - variables() { - return { - status: STATUS_STALE, - }; - }, + ...statusCountSmartQuery({ status: STATUS_STALE, name: 'staleRunnersTotal' }), }, }, computed: { @@ -263,12 +261,6 @@ export default {