diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /app/assets/javascripts/editor | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'app/assets/javascripts/editor')
6 files changed, 175 insertions, 97 deletions
diff --git a/app/assets/javascripts/editor/extensions/source_editor_ci_schema_ext.js b/app/assets/javascripts/editor/extensions/source_editor_ci_schema_ext.js index b41eae88c54..b33dcba2b7d 100644 --- a/app/assets/javascripts/editor/extensions/source_editor_ci_schema_ext.js +++ b/app/assets/javascripts/editor/extensions/source_editor_ci_schema_ext.js @@ -17,10 +17,14 @@ export class CiSchemaExtension { const absoluteSchemaUrl = new URL(ciSchemaPath, gon.gitlab_url).href; const modelFileName = instance.getModel().uri.path.split('/').pop(); - registerSchema({ - uri: absoluteSchemaUrl, - fileMatch: [modelFileName], - }); + registerSchema( + { + uri: absoluteSchemaUrl, + fileMatch: [modelFileName], + }, + // eslint-disable-next-line @gitlab/require-i18n-strings + { customTags: ['!reference sequence'] }, + ); }, }; } diff --git a/app/assets/javascripts/editor/extensions/source_editor_markdown_livepreview_ext.js b/app/assets/javascripts/editor/extensions/source_editor_markdown_livepreview_ext.js index 11cc85c659d..e4ad0bf8e76 100644 --- a/app/assets/javascripts/editor/extensions/source_editor_markdown_livepreview_ext.js +++ b/app/assets/javascripts/editor/extensions/source_editor_markdown_livepreview_ext.js @@ -36,6 +36,8 @@ const setupDomElement = ({ injectToEl = null } = {}) => { return previewEl; }; +let dimResize = false; + export class EditorMarkdownPreviewExtension { static get extensionName() { return 'EditorMarkdownPreview'; @@ -50,6 +52,7 @@ export class EditorMarkdownPreviewExtension { }, shown: false, modelChangeListener: undefined, + layoutChangeListener: undefined, path: setupOptions.previewMarkdownPath, actionShowPreviewCondition: instance.createContextKey('toggleLivePreview', true), }; @@ -59,6 +62,14 @@ export class EditorMarkdownPreviewExtension { if (instance.toolbar) { this.setupToolbar(instance); } + + this.preview.layoutChangeListener = instance.onDidLayoutChange(() => { + if (instance.markdownPreview?.shown && !dimResize) { + const { width } = instance.getLayoutInfo(); + const newWidth = width * EXTENSION_MARKDOWN_PREVIEW_PANEL_WIDTH; + EditorMarkdownPreviewExtension.resizePreviewLayout(instance, newWidth); + } + }); } onBeforeUnuse(instance) { @@ -70,6 +81,9 @@ export class EditorMarkdownPreviewExtension { } cleanup(instance) { + if (this.preview.layoutChangeListener) { + this.preview.layoutChangeListener.dispose(); + } if (this.preview.modelChangeListener) { this.preview.modelChangeListener.dispose(); } @@ -82,6 +96,15 @@ export class EditorMarkdownPreviewExtension { this.preview.shown = false; } + static resizePreviewLayout(instance, width) { + const { height } = instance.getLayoutInfo(); + dimResize = true; + instance.layout({ width, height }); + window.requestAnimationFrame(() => { + dimResize = false; + }); + } + setupToolbar(instance) { this.toolbarButtons = [ { @@ -99,11 +122,11 @@ export class EditorMarkdownPreviewExtension { } togglePreviewLayout(instance) { - const { width, height } = instance.getLayoutInfo(); + const { width } = instance.getLayoutInfo(); const newWidth = this.preview.shown ? width / EXTENSION_MARKDOWN_PREVIEW_PANEL_WIDTH : width * EXTENSION_MARKDOWN_PREVIEW_PANEL_WIDTH; - instance.layout({ width: newWidth, height }); + EditorMarkdownPreviewExtension.resizePreviewLayout(instance, newWidth); } togglePreviewPanel(instance) { diff --git a/app/assets/javascripts/editor/extensions/source_editor_webide_ext.js b/app/assets/javascripts/editor/extensions/source_editor_webide_ext.js index 4e8c11bac54..6270517b3f3 100644 --- a/app/assets/javascripts/editor/extensions/source_editor_webide_ext.js +++ b/app/assets/javascripts/editor/extensions/source_editor_webide_ext.js @@ -7,7 +7,6 @@ * @property {Object} options The Monaco editor options */ -import { debounce } from 'lodash'; import { KeyCode, KeyMod, Range } from 'monaco-editor'; import { EDITOR_TYPE_DIFF } from '~/editor/constants'; import Disposable from '~/ide/lib/common/disposable'; @@ -59,13 +58,10 @@ const renderSideBySide = (domElement) => { return domElement.offsetWidth >= 700; }; -const updateInstanceDimensions = (instance) => { - instance.layout(); - if (isDiffEditorType(instance)) { - instance.updateOptions({ - renderSideBySide: renderSideBySide(instance.getDomNode()), - }); - } +const updateDiffInstanceRendering = (instance) => { + instance.updateOptions({ + renderSideBySide: renderSideBySide(instance.getDomNode()), + }); }; export class EditorWebIdeExtension { @@ -85,15 +81,14 @@ export class EditorWebIdeExtension { this.options = setupOptions.options; this.disposable = new Disposable(); - this.debouncedUpdate = debounce(() => { - updateInstanceDimensions(instance); - }, UPDATE_DIMENSIONS_DELAY); - addActions(instance, setupOptions.store); - } - onUse(instance) { - window.addEventListener('resize', this.debouncedUpdate, false); + if (isDiffEditorType(instance)) { + updateDiffInstanceRendering(instance); + instance.getModifiedEditor().onDidLayoutChange(() => { + updateDiffInstanceRendering(instance); + }); + } instance.onDidDispose(() => { this.onUnuse(); @@ -101,8 +96,6 @@ export class EditorWebIdeExtension { } onUnuse() { - window.removeEventListener('resize', this.debouncedUpdate); - // catch any potential errors with disposing the error // this is mainly for tests caused by elements not existing try { @@ -149,7 +142,6 @@ export class EditorWebIdeExtension { modified: model.getModel(), }); }, - updateDimensions: (instance) => updateInstanceDimensions(instance), setPos: (instance, { lineNumber, column }) => { instance.revealPositionInCenter({ lineNumber, diff --git a/app/assets/javascripts/editor/schema/ci.json b/app/assets/javascripts/editor/schema/ci.json index 1352211b927..c8015f884b7 100644 --- a/app/assets/javascripts/editor/schema/ci.json +++ b/app/assets/javascripts/editor/schema/ci.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "$id": "https://gitlab.com/.gitlab-ci.yml", "title": "Gitlab CI configuration", - "description": "Gitlab has a built-in solution for doing CI called Gitlab CI. It is configured by supplying a file called `.gitlab-ci.yml`, which will list all the jobs that are going to run for the project. A full list of all options can be found at https://docs.gitlab.com/ee/ci/yaml/. You can read more about Gitlab CI at https://docs.gitlab.com/ee/ci/README.html.", + "markdownDescription": "Gitlab has a built-in solution for doing CI called Gitlab CI. It is configured by supplying a file called `.gitlab-ci.yml`, which will list all the jobs that are going to run for the project. A full list of all options can be found [here](https://docs.gitlab.com/ee/ci/yaml). [Learn More](https://docs.gitlab.com/ee/ci/index.html).", "type": "object", "properties": { "$schema": { @@ -15,6 +15,7 @@ "after_script": { "$ref": "#/definitions/after_script" }, "variables": { "$ref": "#/definitions/globalVariables" }, "cache": { "$ref": "#/definitions/cache" }, + "!reference": {"$ref" : "#/definitions/!reference"}, "default": { "type": "object", "properties": { @@ -27,13 +28,14 @@ "retry": { "$ref": "#/definitions/retry" }, "services": { "$ref": "#/definitions/services" }, "tags": { "$ref": "#/definitions/tags" }, - "timeout": { "$ref": "#/definitions/timeout" } + "timeout": { "$ref": "#/definitions/timeout" }, + "!reference": {"$ref" : "#/definitions/!reference"} }, "additionalProperties": false }, "stages": { "type": "array", - "description": "Groups jobs into stages. All jobs in one stage must complete before next stage is executed. Defaults to ['build', 'test', 'deploy'].", + "markdownDescription": "Groups jobs into stages. All jobs in one stage must complete before next stage is executed. Defaults to ['build', 'test', 'deploy']. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#stages).", "default": ["build", "test", "deploy"], "items": { "type": "string" @@ -42,7 +44,7 @@ "minItems": 1 }, "include": { - "description": "Can be `IncludeItem` or `IncludeItem[]`. Each `IncludeItem` will be a string, or an object with properties for the method if including external YAML file. The external content will be fetched, included and evaluated along the `.gitlab-ci.yml`.", + "markdownDescription": "Can be `IncludeItem` or `IncludeItem[]`. Each `IncludeItem` will be a string, or an object with properties for the method if including external YAML file. The external content will be fetched, included and evaluated along the `.gitlab-ci.yml`. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#include).", "oneOf": [ { "$ref": "#/definitions/include_item" }, { @@ -53,7 +55,7 @@ }, "pages": { "$ref": "#/definitions/job", - "description": "A special job used to upload static sites to Gitlab pages. Requires a `public/` directory with `artifacts.path` pointing to it." + "markdownDescription": "A special job used to upload static sites to Gitlab pages. Requires a `public/` directory with `artifacts.path` pointing to it. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#pages)." }, "workflow": { "type": "object", @@ -61,7 +63,10 @@ "rules": { "type": "array", "items": { - "type": "object", + "anyOf": [ + {"type": "object"}, + {"type": "array", "minLength": 1, "items": { "type": "string" }} + ], "properties": { "if": { "$ref": "#/definitions/if" }, "changes": { "$ref": "#/definitions/changes" }, @@ -93,12 +98,12 @@ "definitions": { "artifacts": { "type": "object", - "description": "Used to specify a list of files and directories that should be attached to the job if it succeeds. Artifacts are sent to Gitlab where they can be downloaded.", + "markdownDescription": "Used to specify a list of files and directories that should be attached to the job if it succeeds. Artifacts are sent to Gitlab where they can be downloaded. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#artifacts).", "additionalProperties": false, "properties": { "paths": { "type": "array", - "description": "A list of paths to files/folders that should be included in the artifact.", + "markdownDescription": "A list of paths to files/folders that should be included in the artifact. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#artifactspaths).", "items": { "type": "string" }, @@ -106,7 +111,7 @@ }, "exclude": { "type": "array", - "description": "A list of paths to files/folders that should be excluded in the artifact.", + "markdownDescription": "A list of paths to files/folders that should be excluded in the artifact. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#artifactsexclude).", "items": { "type": "string" }, @@ -114,19 +119,19 @@ }, "expose_as": { "type": "string", - "description": "Can be used to expose job artifacts in the merge request UI. GitLab will add a link <expose_as> to the relevant merge request that points to the artifact." + "markdownDescription": "Can be used to expose job artifacts in the merge request UI. GitLab will add a link <expose_as> to the relevant merge request that points to the artifact. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#artifactsexpose_as)." }, "name": { "type": "string", - "description": "Name for the archive created on job success. Can use variables in the name, e.g. '$CI_JOB_NAME'" + "markdownDescription": "Name for the archive created on job success. Can use variables in the name, e.g. '$CI_JOB_NAME' [Learn More](https://docs.gitlab.com/ee/ci/yaml/#artifactsname)." }, "untracked": { "type": "boolean", - "description": "Whether to add all untracked files (along with 'artifacts.paths') to the artifact.", + "markdownDescription": "Whether to add all untracked files (along with 'artifacts.paths') to the artifact. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#artifactsuntracked).", "default": false }, "when": { - "description": "Configure when artifacts are uploaded depended on job status.", + "markdownDescription": "Configure when artifacts are uploaded depended on job status. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#artifactswhen).", "default": "on_success", "oneOf": [ { @@ -145,12 +150,12 @@ }, "expire_in": { "type": "string", - "description": "How long artifacts should be kept. They are saved 30 days by default. Artifacts that have expired are removed periodically via cron job. Supports a wide variety of formats, e.g. '1 week', '3 mins 4 sec', '2 hrs 20 min', '2h20min', '6 mos 1 day', '47 yrs 6 mos and 4d', '3 weeks and 2 days'.", + "markdownDescription": "How long artifacts should be kept. They are saved 30 days by default. Artifacts that have expired are removed periodically via cron job. Supports a wide variety of formats, e.g. '1 week', '3 mins 4 sec', '2 hrs 20 min', '2h20min', '6 mos 1 day', '47 yrs 6 mos and 4d', '3 weeks and 2 days'. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#artifactsexpire_in).", "default": "30 days" }, "reports": { "type": "object", - "description": "Reports will be uploaded as artifacts, and often displayed in the Gitlab UI, such as in Merge Requests.", + "markdownDescription": "Reports will be uploaded as artifacts, and often displayed in the Gitlab UI, such as in Merge Requests. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#artifactsreports).", "additionalProperties": false, "properties": { "junit": { @@ -341,6 +346,13 @@ } ] }, + "!reference": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + } + }, "image": { "oneOf": [ { @@ -362,16 +374,43 @@ "type": "array", "description": "Command or script that should be executed as the container's entrypoint. It will be translated to Docker's --entrypoint option while creating the container. The syntax is similar to Dockerfile's ENTRYPOINT directive, where each shell token is a separate string in the array.", "minItems": 1 + }, + "pull_policy": { + "markdownDescription": "Specifies how to pull the image in Runner. It can be one of `always`, `never` or `if-not-present`. The default value is `always`. [Learn more](https://docs.gitlab.com/ee/ci/yaml/#imagepull_policy).", + "default": "always", + "oneOf": [ + { + "type": "string", + "enum": [ + "always", + "never", + "if-not-present" + ] + }, + { + "type": "array", + "items": { + "type": "string", + "enum": [ + "always", + "never", + "if-not-present" + ] + }, + "minItems": 1, + "uniqueItems": true + } + ] } }, "required": ["name"] } ], - "description": "Specifies the docker image to use for the job or globally for all jobs. Job configuration takes precedence over global setting. Requires a certain kind of Gitlab runner executor." + "markdownDescription": "Specifies the docker image to use for the job or globally for all jobs. Job configuration takes precedence over global setting. Requires a certain kind of Gitlab runner executor. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#image)." }, "services": { "type": "array", - "description": "Similar to `image` property, but will link the specified services to the `image` container.", + "markdownDescription": "Similar to `image` property, but will link the specified services to the `image` container. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#services).", "items": { "oneOf": [ { @@ -418,7 +457,7 @@ }, "secrets": { "type": "object", - "description": "Defines secrets to be injected as environment variables", + "markdownDescription": "Defines secrets to be injected as environment variables. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#secrets).", "additionalProperties": { "type": "object", "description": "Environment variable name", @@ -453,7 +492,7 @@ }, "before_script": { "type": "array", - "description": "Defines scripts that should run *before* the job. Can be set globally or per job.", + "markdownDescription": "Defines scripts that should run *before* the job. Can be set globally or per job. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#before_script).", "items": { "anyOf": [ { @@ -470,7 +509,7 @@ }, "after_script": { "type": "array", - "description": "Defines scripts that should run *after* the job. Can be set globally or per job.", + "markdownDescription": "Defines scripts that should run *after* the job. Can be set globally or per job. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#after_script).", "items": { "anyOf": [ { @@ -487,27 +526,41 @@ }, "rules": { "type": "array", - "description": "Rules allows for an array of individual rule objects to be evaluated in order, until one matches and dynamically provides attributes to the job.", + "markdownDescription": "Rules allows for an array of individual rule objects to be evaluated in order, until one matches and dynamically provides attributes to the job. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#rules).", "items": { - "type": "object", - "additionalProperties": false, - "properties": { - "if": { "$ref": "#/definitions/if" }, - "changes": { "$ref": "#/definitions/changes" }, - "exists": { "$ref": "#/definitions/exists" }, - "variables": { "$ref": "#/definitions/variables" }, - "when": { "$ref": "#/definitions/when" }, - "start_in": { "$ref": "#/definitions/start_in" }, - "allow_failure": { "$ref": "#/definitions/allow_failure" } - } + "anyOf": [ + { + "type": "object", + "additionalProperties": false, + "properties": { + "if": { "$ref": "#/definitions/if" }, + "changes": { "$ref": "#/definitions/changes" }, + "exists": { "$ref": "#/definitions/exists" }, + "variables": { "$ref": "#/definitions/variables" }, + "when": { "$ref": "#/definitions/when" }, + "start_in": { "$ref": "#/definitions/start_in" }, + "allow_failure": { "$ref": "#/definitions/allow_failure" } + } + }, + {"type": "string", "minLength": 1}, + {"type": "array", "minLength": 1, "items": { "type": "string" }} + ] } }, "globalVariables": { - "description": "Defines environment variables globally. Job level property overrides global variables. If a job sets `variables: {}`, all global variables are turned off. You can use the value and description keywords to define variables that are prefilled when running a pipeline manually.", - "type": "object", + "markdownDescription": "Defines environment variables globally. Job level property overrides global variables. If a job sets `variables: {}`, all global variables are turned off. You can use the value and description keywords to define variables that are prefilled when running a pipeline manually. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#variables).", + "anyOf": [ + {"type": "object"}, + { + "type": "array", + "items": { + "type": "string" + } + } + ], "additionalProperties": { "anyOf": [ - {"type": ["string", "integer"]}, + {"type": ["string", "integer", "array"]}, { "type": "object", "properties": { @@ -523,41 +576,51 @@ }, "if": { "type": "string", - "description": "Expression to evaluate whether additional attributes should be provided to the job" + "markdownDescription": "Expression to evaluate whether additional attributes should be provided to the job. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#rulesif)." }, "changes": { "type": "array", - "description": "Additional attributes will be provided to job if any of the provided paths matches a modified file", + "markdownDescription": "Additional attributes will be provided to job if any of the provided paths matches a modified file. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#ruleschanges).", "items": { "type": "string" } }, "exists": { "type": "array", - "description": "Additional attributes will be provided to job if any of the provided paths matches an existing file in the repository", + "markdownDescription": "Additional attributes will be provided to job if any of the provided paths matches an existing file in the repository. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#rulesexists).", "items": { "type": "string" } }, "variables": { - "type": "object", - "description": "Defines environment variables for specific jobs. Job level property overrides global variables. If a job sets `variables: {}`, all global variables are turned off.", - "additionalProperties": { - "type": ["string", "integer"] - } + "markdownDescription": "Defines environment variables for specific jobs. Job level property overrides global variables. If a job sets `variables: {}`, all global variables are turned off. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#rulesvariables).", + "anyOf": [ + { + "type": "object", + "additionalProperties": { + "type": ["string", "integer", "array"] + } + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] }, "timeout": { "type": "string", - "description": "Allows you to configure a timeout for a specific job (e.g. `1 minute`, `1h 30m 12s`). Read more: https://docs.gitlab.com/ee/ci/yaml/README.html#timeout", + "markdownDescription": "Allows you to configure a timeout for a specific job (e.g. `1 minute`, `1h 30m 12s`). [Learn More](https://docs.gitlab.com/ee/ci/yaml/index.html#timeout).", "minLength": 1 }, "start_in": { "type": "string", - "description": "Used in conjunction with 'when: delayed' to set how long to delay before starting a job. e.g. '5', 5 seconds, 30 minutes, 1 week, etc. Read more: https://docs.gitlab.com/ee/ci/jobs/job_control.html#run-a-job-after-a-delay", + "markdownDescription": "Used in conjunction with 'when: delayed' to set how long to delay before starting a job. e.g. '5', 5 seconds, 30 minutes, 1 week, etc. [Learn More](https://docs.gitlab.com/ee/ci/jobs/job_control.html#run-a-job-after-a-delay).", "minLength": 1 }, "allow_failure": { - "description": "Allow job to fail. A failed job does not cause the pipeline to fail.", + "markdownDescription": "Allow job to fail. A failed job does not cause the pipeline to fail. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#allow_failure).", "oneOf": [ { "description": "Setting this option to true will allow the job to fail while still letting the pipeline pass.", @@ -594,7 +657,7 @@ ] }, "when": { - "description": "Describes the conditions for when to run the job. Defaults to 'on_success'.", + "markdownDescription": "Describes the conditions for when to run the job. Defaults to 'on_success'.", "default": "on_success", "oneOf": [ { @@ -611,11 +674,11 @@ }, { "enum": ["manual"], - "description": "Execute the job manually from Gitlab UI or API. Read more: https://docs.gitlab.com/ee/ci/yaml/#when-manual" + "markdownDescription": "Execute the job manually from Gitlab UI or API. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#when)." }, { "enum": ["delayed"], - "description": "Execute a job after the time limit in 'start_in' expires. Read more: https://docs.gitlab.com/ee/ci/yaml/#when-delayed" + "markdownDescription": "Execute a job after the time limit in 'start_in' expires. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#when)." }, { "enum": ["never"], @@ -626,7 +689,7 @@ "cache": { "properties": { "when": { - "description": "Defines when to save the cache, based on the status of the job.", + "markdownDescription": "Defines when to save the cache, based on the status of the job. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#cachewhen).", "default": "on_success", "oneOf": [ { @@ -778,7 +841,7 @@ }, "variables": { "type": "array", - "description": "Filter job by checking comparing values of environment variables. Read more about variable expressions: https://docs.gitlab.com/ee/ci/variables/README.html#variables-expressions", + "markdownDescription": "Filter job by checking comparing values of CI/CD variables. [Learn More](https://docs.gitlab.com/ee/ci/jobs/job_control.html#cicd-variable-expressions).", "items": { "type": "string" } @@ -795,7 +858,7 @@ ] }, "retry": { - "description": "Retry a job if it fails. Can be a simple integer or object definition.", + "markdownDescription": "Retry a job if it fails. Can be a simple integer or object definition. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#retry).", "oneOf": [ { "$ref": "#/definitions/retry_max" }, { @@ -804,7 +867,7 @@ "properties": { "max": { "$ref": "#/definitions/retry_max" }, "when": { - "description": "Either a single or array of error types to trigger job retry.", + "markdownDescription": "Either a single or array of error types to trigger job retry. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#retrywhen).", "oneOf": [ { "$ref": "#/definitions/retry_errors" }, { @@ -884,19 +947,12 @@ }, "interruptible": { "type": "boolean", - "description": "Interruptible is used to indicate that a job should be canceled if made redundant by a newer pipeline run.", + "markdownDescription": "Interruptible is used to indicate that a job should be canceled if made redundant by a newer pipeline run. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#interruptible).", "default": false }, "job": { "allOf": [ - { "$ref": "#/definitions/job_template" }, - { - "anyOf": [ - { "required": ["script"] }, - { "required": ["extends"] }, - { "required": ["trigger"] } - ] - } + { "$ref": "#/definitions/job_template" } ] }, "job_template": { @@ -912,7 +968,7 @@ "cache": { "$ref": "#/definitions/cache" }, "secrets": { "$ref": "#/definitions/secrets" }, "script": { - "description": "Shell scripts executed by the Runner. The only required property of jobs. Be careful with special characters (e.g. `:`, `{`, `}`, `&`) and use single or double quotes to avoid issues.", + "markdownDescription": "Shell scripts executed by the Runner. The only required property of jobs. Be careful with special characters (e.g. `:`, `{`, `}`, `&`) and use single or double quotes to avoid issues. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#script)", "oneOf": [ { "type": "string", @@ -1241,11 +1297,11 @@ "description": "Limit job concurrency. Can be used to ensure that the Runner will not run certain jobs simultaneously." }, "trigger": { - "description": "Trigger allows you to define downstream pipeline trigger. When a job created from trigger definition is started by GitLab, a downstream pipeline gets created. Read more: https://docs.gitlab.com/ee/ci/yaml/README.html#trigger", + "markdownDescription": "Trigger allows you to define downstream pipeline trigger. When a job created from trigger definition is started by GitLab, a downstream pipeline gets created. [Learn More](https://docs.gitlab.com/ee/ci/yaml/index.html#trigger).", "oneOf": [ { "type": "object", - "description": "Trigger a multi-project pipeline. Read more: https://docs.gitlab.com/ee/ci/pipelines/multi_project_pipelines.html#specify-a-downstream-pipeline-branch", + "markdownDescription": "Trigger a multi-project pipeline. [Learn More](https://docs.gitlab.com/ee/ci/pipelines/multi_project_pipelines.html#specify-a-downstream-pipeline-branch).", "additionalProperties": false, "properties": { "project": { @@ -1287,7 +1343,7 @@ }, { "type": "object", - "description": "Trigger a child pipeline. Read more: https://docs.gitlab.com/ee/ci/pipelines/parent_child_pipelines.html", + "description": "Trigger a child pipeline. [Learn More](https://docs.gitlab.com/ee/ci/pipelines/parent_child_pipelines.html).", "additionalProperties": false, "properties": { "include": { @@ -1398,7 +1454,7 @@ } }, { - "description": "Path to the project, e.g. `group/project`, or `group/sub-group/project`. Read more: https://docs.gitlab.com/ee/ci/pipelines/multi_project_pipelines.html#define-multi-project-pipelines-in-your-gitlab-ciyml-file", + "markdownDescription": "Path to the project, e.g. `group/project`, or `group/sub-group/project`. [Learn More](https://docs.gitlab.com/ee/ci/pipelines/multi_project_pipelines.html#define-multi-project-pipelines-in-your-gitlab-ciyml-file).", "type": "string", "pattern": "\\S/\\S" } @@ -1406,10 +1462,10 @@ }, "inherit": { "type": "object", - "description": "Controls inheritance of globally-defined defaults and variables. Boolean values control inheritance of all default: or variables: keywords. To inherit only a subset of default: or variables: keywords, specify what you wish to inherit. Anything not listed is not inherited.", + "markdownDescription": "Controls inheritance of globally-defined defaults and variables. Boolean values control inheritance of all default: or variables: keywords. To inherit only a subset of default: or variables: keywords, specify what you wish to inherit. Anything not listed is not inherited. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#inherit).", "properties": { "default": { - "description": "Whether to inherit all globally-defined defaults or not. Or subset of inherited defaults", + "markdownDescription": "Whether to inherit all globally-defined defaults or not. Or subset of inherited defaults. [Learn more](https://docs.gitlab.com/ee/ci/yaml/#inheritdefault).", "oneOf": [ { "type": "boolean" @@ -1435,7 +1491,7 @@ ] }, "variables": { - "description": "Whether to inherit all globally-defined variables or not. Or subset of inherited variables", + "markdownDescription": "Whether to inherit all globally-defined variables or not. Or subset of inherited variables. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#inheritvariables).", "oneOf": [ { "type": "boolean" }, { @@ -1470,7 +1526,7 @@ }, "tags": { "type": "array", - "description": "Used to select runners from the list of available runners. A runner must have all tags listed here to run the job.", + "markdownDescription": "Used to select runners from the list of available runners. A runner must have all tags listed here to run the job. [Learn More](https://docs.gitlab.com/ee/ci/yaml/#tags).", "items": { "type": "string" } diff --git a/app/assets/javascripts/editor/source_editor.js b/app/assets/javascripts/editor/source_editor.js index fa749112ab5..d585dc009e6 100644 --- a/app/assets/javascripts/editor/source_editor.js +++ b/app/assets/javascripts/editor/source_editor.js @@ -75,6 +75,7 @@ export default class SourceEditor { blobGlobalId, instance, isDiff, + language, } = {}) { if (!instance) { return null; @@ -82,7 +83,7 @@ export default class SourceEditor { const uriFilePath = joinPaths(URI_PREFIX, blobGlobalId, blobPath); const uri = Uri.file(uriFilePath); const existingModel = monacoEditor.getModel(uri); - const model = existingModel || monacoEditor.createModel(blobContent, undefined, uri); + const model = existingModel || monacoEditor.createModel(blobContent, language, uri); if (!isDiff) { instance.setModel(model); return model; @@ -132,6 +133,7 @@ export default class SourceEditor { }); let model; + const language = instanceOptions.language || getBlobLanguage(blobPath); if (instanceOptions.model !== null) { model = SourceEditor.createEditorModel({ blobGlobalId, @@ -140,6 +142,7 @@ export default class SourceEditor { blobContent, instance, isDiff, + language, }); } diff --git a/app/assets/javascripts/editor/source_editor_extension.js b/app/assets/javascripts/editor/source_editor_extension.js index 6d47e1e2248..7b73da4465f 100644 --- a/app/assets/javascripts/editor/source_editor_extension.js +++ b/app/assets/javascripts/editor/source_editor_extension.js @@ -12,6 +12,6 @@ export default class EditorExtension { } get api() { - return this.obj.provides?.(); + return this.obj.provides?.() || {}; } } |