From 8f17a25c5b869d4f3e224d774fb352e59ba1a52a Mon Sep 17 00:00:00 2001 From: Clement Ho Date: Wed, 7 Mar 2018 14:39:29 -0600 Subject: Add frontend security documentation --- doc/development/new_fe_guide/development/security.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/development/new_fe_guide/development/security.md b/doc/development/new_fe_guide/development/security.md index debda7de0c6..5bb38f17988 100644 --- a/doc/development/new_fe_guide/development/security.md +++ b/doc/development/new_fe_guide/development/security.md @@ -1,3 +1,14 @@ # Security -> TODO: Add content +## Avoid inline scripts and styles + +Inline scripts and styles should be avoided in almost all cases. In an effort to protect users from [XSS vulnerabilities](https://en.wikipedia.org/wiki/Cross-site_scripting), we will be disabling inline scripts using Content Security Policy. + +## Including external resources + +External fonts, CSS, and JavaScript should never be used with the exception of Google Analytics and Piwik - and only when the instance has enabled it. Assets should always be hosted and served locally from the GitLab instance. Embedded resources via `iframes` should never be used except in certain circumstances such as with ReCaptcha, which cannot be used without an `iframe`. + +## Resources for security testing + +- [Mozilla's HTTP Observatory CLI](https://github.com/mozilla/http-observatory-cli) +- [Qualys SSL Labs Server Test](https://www.ssllabs.com/ssltest/analyze.html) -- cgit v1.2.1 From e84c943fa0609d05184cb95c845fa35cc1fcd432 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Mon, 12 Mar 2018 17:08:05 +0000 Subject: Fix loading icon being visible in the wrong button --- .../javascripts/notes/components/comment_form.vue | 13 +++-- app/assets/javascripts/notes/stores/actions.js | 15 ++++- app/assets/javascripts/notes/stores/getters.js | 1 + app/assets/javascripts/notes/stores/index.js | 3 + .../javascripts/notes/stores/mutation_types.js | 1 + app/assets/javascripts/notes/stores/mutations.js | 4 ++ .../unreleased/44149-issue-comment-buttons.yml | 5 ++ .../notes/components/comment_form_spec.js | 14 +++++ spec/javascripts/notes/stores/actions_spec.js | 16 ++++++ spec/javascripts/notes/stores/mutation_spec.js | 66 ++++++++++++++++++++++ 10 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 changelogs/unreleased/44149-issue-comment-buttons.yml diff --git a/app/assets/javascripts/notes/components/comment_form.vue b/app/assets/javascripts/notes/components/comment_form.vue index 1785be01a0d..a649e180131 100644 --- a/app/assets/javascripts/notes/components/comment_form.vue +++ b/app/assets/javascripts/notes/components/comment_form.vue @@ -52,6 +52,7 @@ 'getNoteableData', 'getNotesData', 'openState', + 'isToggleStateButtonLoading', ]), noteableDisplayName() { return this.noteableType.replace(/_/g, ' '); @@ -143,6 +144,7 @@ 'closeIssue', 'reopenIssue', 'toggleIssueLocalState', + 'toggleStateButtonLoading', ]), setIsSubmitButtonDisabled(note, isSubmitting) { if (!_.isEmpty(note) && !isSubmitting) { @@ -170,13 +172,14 @@ if (this.noteType === constants.DISCUSSION) { noteData.data.note.type = constants.DISCUSSION_NOTE; } + this.note = ''; // Empty textarea while being requested. Repopulate in catch this.resizeTextarea(); this.stopPolling(); this.saveNote(noteData) .then((res) => { - this.isSubmitting = false; + this.enableButton(); this.restartPolling(); if (res.errors) { @@ -198,7 +201,7 @@ } }) .catch(() => { - this.isSubmitting = false; + this.enableButton(); this.discard(false); const msg = `Your comment could not be submitted! @@ -220,6 +223,7 @@ Please check your network connection and try again.`; .then(() => this.enableButton()) .catch(() => { this.enableButton(); + this.toggleStateButtonLoading(false); Flash( sprintf( __('Something went wrong while closing the %{issuable}. Please try again later'), @@ -232,6 +236,7 @@ Please check your network connection and try again.`; .then(() => this.enableButton()) .catch(() => { this.enableButton(); + this.toggleStateButtonLoading(false); Flash( sprintf( __('Something went wrong while reopening the %{issuable}. Please try again later'), @@ -419,13 +424,13 @@ append-right-10 comment-type-dropdown js-comment-type-dropdown droplab-dropdown" diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js index 08ca01e542e..70fc368a471 100644 --- a/app/assets/javascripts/notes/stores/actions.js +++ b/app/assets/javascripts/notes/stores/actions.js @@ -71,21 +71,32 @@ export const toggleResolveNote = ({ commit }, { endpoint, isResolved, discussion commit(mutationType, res); }); -export const closeIssue = ({ commit, dispatch, state }) => service +export const closeIssue = ({ commit, dispatch, state }) => { + dispatch('toggleStateButtonLoading', true); + return service .toggleIssueState(state.notesData.closePath) .then(res => res.json()) .then((data) => { commit(types.CLOSE_ISSUE); dispatch('emitStateChangedEvent', data); + dispatch('toggleStateButtonLoading', false); }); +}; -export const reopenIssue = ({ commit, dispatch, state }) => service +export const reopenIssue = ({ commit, dispatch, state }) => { + dispatch('toggleStateButtonLoading', true); + return service .toggleIssueState(state.notesData.reopenPath) .then(res => res.json()) .then((data) => { commit(types.REOPEN_ISSUE); dispatch('emitStateChangedEvent', data); + dispatch('toggleStateButtonLoading', false); }); +}; + +export const toggleStateButtonLoading = ({ commit }, value) => + commit(types.TOGGLE_STATE_BUTTON_LOADING, value); export const emitStateChangedEvent = ({ commit, getters }, data) => { const event = new CustomEvent('issuable_vue_app:change', { detail: { diff --git a/app/assets/javascripts/notes/stores/getters.js b/app/assets/javascripts/notes/stores/getters.js index e6180101c58..9ff5b0ec63f 100644 --- a/app/assets/javascripts/notes/stores/getters.js +++ b/app/assets/javascripts/notes/stores/getters.js @@ -9,6 +9,7 @@ export const getNotesDataByProp = state => prop => state.notesData[prop]; export const getNoteableData = state => state.noteableData; export const getNoteableDataByProp = state => prop => state.noteableData[prop]; export const openState = state => state.noteableData.state; +export const isToggleStateButtonLoading = state => state.isToggleStateButtonLoading; export const getUserData = state => state.userData || {}; export const getUserDataByProp = state => prop => state.userData && state.userData[prop]; diff --git a/app/assets/javascripts/notes/stores/index.js b/app/assets/javascripts/notes/stores/index.js index 488a9ca38d3..9ed19bf171e 100644 --- a/app/assets/javascripts/notes/stores/index.js +++ b/app/assets/javascripts/notes/stores/index.js @@ -12,6 +12,9 @@ export default new Vuex.Store({ targetNoteHash: null, lastFetchedAt: null, + // View layer + isToggleStateButtonLoading: false, + // holds endpoints and permissions provided through haml notesData: {}, userData: {}, diff --git a/app/assets/javascripts/notes/stores/mutation_types.js b/app/assets/javascripts/notes/stores/mutation_types.js index da1b5a9e51a..b455e23ecde 100644 --- a/app/assets/javascripts/notes/stores/mutation_types.js +++ b/app/assets/javascripts/notes/stores/mutation_types.js @@ -17,3 +17,4 @@ export const UPDATE_DISCUSSION = 'UPDATE_DISCUSSION'; // Issue export const CLOSE_ISSUE = 'CLOSE_ISSUE'; export const REOPEN_ISSUE = 'REOPEN_ISSUE'; +export const TOGGLE_STATE_BUTTON_LOADING = 'TOGGLE_STATE_BUTTON_LOADING'; diff --git a/app/assets/javascripts/notes/stores/mutations.js b/app/assets/javascripts/notes/stores/mutations.js index 963b40be3fd..f07afbe4303 100644 --- a/app/assets/javascripts/notes/stores/mutations.js +++ b/app/assets/javascripts/notes/stores/mutations.js @@ -197,4 +197,8 @@ export default { [types.REOPEN_ISSUE](state) { Object.assign(state.noteableData, { state: constants.REOPENED }); }, + + [types.TOGGLE_STATE_BUTTON_LOADING](state, value) { + Object.assign(state, { isToggleStateButtonLoading: value }); + }, }; diff --git a/changelogs/unreleased/44149-issue-comment-buttons.yml b/changelogs/unreleased/44149-issue-comment-buttons.yml new file mode 100644 index 00000000000..c874c0d3d66 --- /dev/null +++ b/changelogs/unreleased/44149-issue-comment-buttons.yml @@ -0,0 +1,5 @@ +--- +title: Fix broken loading state for close issue button +merge_request: +author: +type: fixed diff --git a/spec/javascripts/notes/components/comment_form_spec.js b/spec/javascripts/notes/components/comment_form_spec.js index 90016436cb7..224debbeff6 100644 --- a/spec/javascripts/notes/components/comment_form_spec.js +++ b/spec/javascripts/notes/components/comment_form_spec.js @@ -200,6 +200,20 @@ describe('issue_comment_form component', () => { done(); }); }); + + describe('when clicking close/reopen button', () => { + it('should disable button and show a loading spinner', (done) => { + const toggleStateButton = vm.$el.querySelector('.js-action-button'); + + toggleStateButton.click(); + Vue.nextTick(() => { + expect(toggleStateButton.disabled).toEqual(true); + expect(toggleStateButton.querySelector('.js-loading-button-icon')).not.toBeNull(); + + done(); + }); + }); + }); }); describe('issue is confidential', () => { diff --git a/spec/javascripts/notes/stores/actions_spec.js b/spec/javascripts/notes/stores/actions_spec.js index ab80ed7bbfb..0f092810574 100644 --- a/spec/javascripts/notes/stores/actions_spec.js +++ b/spec/javascripts/notes/stores/actions_spec.js @@ -87,6 +87,7 @@ describe('Actions Notes Store', () => { store.dispatch('closeIssue', { notesData: { closeIssuePath: '' } }) .then(() => { expect(store.state.noteableData.state).toEqual('closed'); + expect(store.state.isToggleStateButtonLoading).toEqual(false); done(); }) .catch(done.fail); @@ -98,6 +99,7 @@ describe('Actions Notes Store', () => { store.dispatch('reopenIssue', { notesData: { reopenIssuePath: '' } }) .then(() => { expect(store.state.noteableData.state).toEqual('reopened'); + expect(store.state.isToggleStateButtonLoading).toEqual(false); done(); }) .catch(done.fail); @@ -116,6 +118,20 @@ describe('Actions Notes Store', () => { }); }); + describe('toggleStateButtonLoading', () => { + it('should set loading as true', (done) => { + testAction(actions.toggleStateButtonLoading, true, {}, [ + { type: 'TOGGLE_STATE_BUTTON_LOADING', payload: true }, + ], done); + }); + + it('should set loading as false', (done) => { + testAction(actions.toggleStateButtonLoading, false, {}, [ + { type: 'TOGGLE_STATE_BUTTON_LOADING', payload: false }, + ], done); + }); + }); + describe('toggleIssueLocalState', () => { it('sets issue state as closed', (done) => { testAction(actions.toggleIssueLocalState, 'closed', {}, [ diff --git a/spec/javascripts/notes/stores/mutation_spec.js b/spec/javascripts/notes/stores/mutation_spec.js index e4baefc5bfc..2627f721d9d 100644 --- a/spec/javascripts/notes/stores/mutation_spec.js +++ b/spec/javascripts/notes/stores/mutation_spec.js @@ -217,4 +217,70 @@ describe('Notes Store mutations', () => { expect(state.notes[0].notes[0].note).toEqual('Foo'); }); }); + + describe('CLOSE_ISSUE', () => { + it('should set issue as closed', () => { + const state = { + notes: [], + targetNoteHash: null, + lastFetchedAt: null, + isToggleStateButtonLoading: false, + notesData: {}, + userData: {}, + noteableData: {}, + }; + + mutations.CLOSE_ISSUE(state); + expect(state.noteableData.state).toEqual('closed'); + }); + }); + + describe('REOPEN_ISSUE', () => { + it('should set issue as closed', () => { + const state = { + notes: [], + targetNoteHash: null, + lastFetchedAt: null, + isToggleStateButtonLoading: false, + notesData: {}, + userData: {}, + noteableData: {}, + }; + + mutations.REOPEN_ISSUE(state); + expect(state.noteableData.state).toEqual('reopened'); + }); + }); + + describe('TOGGLE_STATE_BUTTON_LOADING', () => { + it('should set isToggleStateButtonLoading as true', () => { + const state = { + notes: [], + targetNoteHash: null, + lastFetchedAt: null, + isToggleStateButtonLoading: false, + notesData: {}, + userData: {}, + noteableData: {}, + }; + + mutations.TOGGLE_STATE_BUTTON_LOADING(state, true); + expect(state.isToggleStateButtonLoading).toEqual(true); + }); + + it('should set isToggleStateButtonLoading as false', () => { + const state = { + notes: [], + targetNoteHash: null, + lastFetchedAt: null, + isToggleStateButtonLoading: true, + notesData: {}, + userData: {}, + noteableData: {}, + }; + + mutations.TOGGLE_STATE_BUTTON_LOADING(state, false); + expect(state.isToggleStateButtonLoading).toEqual(false); + }); + }); }); -- cgit v1.2.1 From 6379a849c0a9ab004f68307dac5375443f3e49fa Mon Sep 17 00:00:00 2001 From: Andreas Brandl Date: Mon, 12 Mar 2018 18:24:36 +0100 Subject: Fix timestamp to include %M instead of %I for post-deploy migrations. Closes #44121. --- .../post_deployment_migration/post_deployment_migration_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb b/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb index 7cb4bccb23c..91175b49c79 100644 --- a/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb +++ b/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb @@ -3,7 +3,7 @@ require 'rails/generators' module Rails class PostDeploymentMigrationGenerator < Rails::Generators::NamedBase def create_migration_file - timestamp = Time.now.strftime('%Y%m%d%H%I%S') + timestamp = Time.now.strftime('%Y%m%d%H%M%S') template "migration.rb", "db/post_migrate/#{timestamp}_#{file_name}.rb" end -- cgit v1.2.1 From 4fa2d6daa7b4921bdba06d89490e608bffb99ca0 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Mon, 12 Mar 2018 18:55:50 +0000 Subject: Update dependency for svgs --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 6549da99f97..472bdbebda8 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "webpack-prod": "NODE_ENV=production webpack --config config/webpack.config.js" }, "dependencies": { - "@gitlab-org/gitlab-svgs": "^1.13.0", + "@gitlab-org/gitlab-svgs": "^1.14.0", "autosize": "^4.0.0", "axios": "^0.17.1", "babel-core": "^6.26.0", diff --git a/yarn.lock b/yarn.lock index a2eee3a547d..adbb37bea72 100644 --- a/yarn.lock +++ b/yarn.lock @@ -54,9 +54,9 @@ lodash "^4.2.0" to-fast-properties "^2.0.0" -"@gitlab-org/gitlab-svgs@^1.13.0": - version "1.13.0" - resolved "https://registry.yarnpkg.com/@gitlab-org/gitlab-svgs/-/gitlab-svgs-1.13.0.tgz#9e856ef9fa7bbe49b2dce9789187a89e11311215" +"@gitlab-org/gitlab-svgs@^1.14.0": + version "1.14.0" + resolved "https://registry.yarnpkg.com/@gitlab-org/gitlab-svgs/-/gitlab-svgs-1.14.0.tgz#b4a5cca3106f33224c5486cf674ba3b70cee727e" "@types/jquery@^2.0.40": version "2.0.48" -- cgit v1.2.1 From 3b8db239ccb18eb68bcfde263e1cf24d57c924d5 Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Mon, 12 Mar 2018 19:52:55 +0100 Subject: Fix inconsistent punctuation on MR form --- .../shared/issuable/form/_contribution.html.haml | 2 +- .../merge_requests/img/allow_maintainer_push.png | Bin 99079 -> 49216 bytes locale/gitlab.pot | 108 +++++++++++++++++---- 3 files changed, 90 insertions(+), 20 deletions(-) diff --git a/app/views/shared/issuable/form/_contribution.html.haml b/app/views/shared/issuable/form/_contribution.html.haml index 0f2d313a5cc..de508278d7c 100644 --- a/app/views/shared/issuable/form/_contribution.html.haml +++ b/app/views/shared/issuable/form/_contribution.html.haml @@ -14,7 +14,7 @@ .checkbox = form.label :allow_maintainer_to_push do = form.check_box :allow_maintainer_to_push, disabled: !issuable.can_allow_maintainer_to_push?(current_user) - = _('Allow edits from maintainers') + = _('Allow edits from maintainers.') = link_to 'About this feature', help_page_path('user/project/merge_requests/maintainer_access') .help-block = allow_maintainer_push_unavailable_reason(issuable) diff --git a/doc/user/project/merge_requests/img/allow_maintainer_push.png b/doc/user/project/merge_requests/img/allow_maintainer_push.png index 1631527071b..91cc399f4ff 100644 Binary files a/doc/user/project/merge_requests/img/allow_maintainer_push.png and b/doc/user/project/merge_requests/img/allow_maintainer_push.png differ diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 3f05e878cc8..a04f869f2bb 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: gitlab 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-03-06 17:36+0100\n" -"PO-Revision-Date: 2018-03-06 17:36+0100\n" +"POT-Creation-Date: 2018-03-12 19:50+0100\n" +"PO-Revision-Date: 2018-03-12 19:50+0100\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" @@ -28,6 +28,11 @@ msgid_plural "%d commits behind" msgstr[0] "" msgstr[1] "" +msgid "%d exporter" +msgid_plural "%d exporters" +msgstr[0] "" +msgstr[1] "" + msgid "%d issue" msgid_plural "%d issues" msgstr[0] "" @@ -43,6 +48,11 @@ msgid_plural "%d merge requests" msgstr[0] "" msgstr[1] "" +msgid "%d metric" +msgid_plural "%d metrics" +msgstr[0] "" +msgstr[1] "" + msgid "%s additional commit has been omitted to prevent performance issues." msgid_plural "%s additional commits have been omitted to prevent performance issues." msgstr[0] "" @@ -102,6 +112,9 @@ msgstr "" msgid "2FA enabled" msgstr "" +msgid "Removes source branch" +msgstr "" + msgid "A collection of graphs regarding Continuous Integration" msgstr "" @@ -111,6 +124,9 @@ msgstr "" msgid "A project is where you house your files (repository), plan your work (issues), and publish your documentation (wiki), %{among_other_things_link}." msgstr "" +msgid "A user with write access to the source branch selected this option" +msgstr "" + msgid "About auto deploy" msgstr "" @@ -213,7 +229,7 @@ msgstr "" msgid "All features are enabled for blank projects, from templates, or when importing, but you can disable them afterward in the project settings." msgstr "" -msgid "Allow edits from maintainers" +msgid "Allow edits from maintainers." msgstr "" msgid "Allows you to add and manage Kubernetes clusters." @@ -857,6 +873,9 @@ msgstr "" msgid "ClusterIntegration|Learn more about environments" msgstr "" +msgid "ClusterIntegration|Learn more about security configuration" +msgstr "" + msgid "ClusterIntegration|Machine type" msgstr "" @@ -914,6 +933,9 @@ msgstr "" msgid "ClusterIntegration|Save changes" msgstr "" +msgid "ClusterIntegration|Security" +msgstr "" + msgid "ClusterIntegration|See and edit the details for your Kubernetes cluster" msgstr "" @@ -941,6 +963,9 @@ msgstr "" msgid "ClusterIntegration|Something went wrong while installing %{title}" msgstr "" +msgid "ClusterIntegration|The default cluster configuration grants access to a wide set of functionalities needed to successfully build and deploy a containerised application." +msgstr "" + msgid "ClusterIntegration|This account must have permissions to create a Kubernetes cluster in the %{link_to_container_project} specified below" msgstr "" @@ -1182,6 +1207,9 @@ msgstr "" msgid "Create empty bare repository" msgstr "" +msgid "Create group label" +msgstr "" + msgid "Create lists from labels. Issues with that label appear in that list." msgstr "" @@ -1197,6 +1225,9 @@ msgstr "" msgid "Create new..." msgstr "" +msgid "Create project label" +msgstr "" + msgid "CreateNewFork|Fork" msgstr "" @@ -1776,9 +1807,18 @@ msgstr "" msgid "Labels" msgstr "" +msgid "Labels can be applied to %{features}. Group labels are available for any project within the group." +msgstr "" + msgid "Labels can be applied to issues and merge requests to categorize them." msgstr "" +msgid "Labels|Promote Label" +msgstr "" + +msgid "Labels|Promote label %{labelTitle} to Group Label?" +msgstr "" + msgid "Last %d day" msgid_plural "Last %d days" msgstr[0] "" @@ -1850,9 +1890,15 @@ msgstr "" msgid "Login" msgstr "" +msgid "Manage group labels" +msgstr "" + msgid "Manage labels" msgstr "" +msgid "Manage project labels" +msgstr "" + msgid "Mar" msgstr "" @@ -1907,6 +1953,12 @@ msgstr "" msgid "Milestones|Milestone %{milestoneTitle} was not found" msgstr "" +msgid "Milestones|Promote %{milestoneTitle} to group milestone?" +msgstr "" + +msgid "Milestones|Promote Milestone" +msgstr "" + msgid "MissingSSHKeyWarningLink|add an SSH key" msgstr "" @@ -2002,6 +2054,9 @@ msgstr "" msgid "No file chosen" msgstr "" +msgid "No labels created yet." +msgstr "" + msgid "No repository" msgstr "" @@ -2251,9 +2306,15 @@ msgstr "" msgid "Pipelines|Loading Pipelines" msgstr "" +msgid "Pipelines|Project cache successfully reset." +msgstr "" + msgid "Pipelines|Run Pipeline" msgstr "" +msgid "Pipelines|Something went wrong while cleaning runners cache." +msgstr "" + msgid "Pipelines|There are currently no %{scope} pipelines." msgstr "" @@ -2380,9 +2441,6 @@ msgstr "" msgid "Project avatar in repository: %{link}" msgstr "" -msgid "Project cache successfully reset." -msgstr "" - msgid "Project details" msgstr "" @@ -2446,6 +2504,12 @@ msgstr "" msgid "ProjectsDropdown|This feature requires browser localStorage support" msgstr "" +msgid "PrometheusService|%{exporters} with %{metrics} were found" +msgstr "" + +msgid "PrometheusService|

No common metrics were found

" +msgstr "" + msgid "PrometheusService|Active" msgstr "" @@ -2458,6 +2522,9 @@ msgstr "" msgid "PrometheusService|By default, Prometheus listens on ‘http://localhost:9090’. It’s not recommended to change the default address and port as this might affect or conflict with other services running on the GitLab server." msgstr "" +msgid "PrometheusService|Common metrics" +msgstr "" + msgid "PrometheusService|Finding and configuring metrics..." msgstr "" @@ -2479,15 +2546,9 @@ msgstr "" msgid "PrometheusService|Missing environment variable" msgstr "" -msgid "PrometheusService|Monitored" -msgstr "" - msgid "PrometheusService|More information" msgstr "" -msgid "PrometheusService|No metrics are being monitored. To start monitoring, deploy to an environment." -msgstr "" - msgid "PrometheusService|Prometheus API Base URL, like http://prometheus.example.com/" msgstr "" @@ -2503,7 +2564,16 @@ msgstr "" msgid "PrometheusService|To enable the installation of Prometheus on your clusters, deactivate the manual configuration below" msgstr "" -msgid "PrometheusService|View environments" +msgid "PrometheusService|Waiting for your first deployment to an environment to find common metrics" +msgstr "" + +msgid "Promote" +msgstr "" + +msgid "Promote to Group Label" +msgstr "" + +msgid "Promote to Group Milestone" msgstr "" msgid "Protip:" @@ -2515,9 +2585,6 @@ msgstr "" msgid "Public - The project can be accessed without any authentication." msgstr "" -msgid "Push access to this project is necessary in order to enable this option" -msgstr "" - msgid "Push events" msgstr "" @@ -3338,9 +3405,6 @@ msgstr "" msgid "Trigger this manual action" msgstr "" -msgid "Unable to reset project cache." -msgstr "" - msgid "Unlock" msgstr "" @@ -3383,12 +3447,18 @@ msgstr "" msgid "View file @ " msgstr "" +msgid "View group labels" +msgstr "" + msgid "View labels" msgstr "" msgid "View open merge request" msgstr "" +msgid "View project labels" +msgstr "" + msgid "View replaced file @ " msgstr "" -- cgit v1.2.1 From 4d726d1f9fc701449037fb81218860c452a77e20 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 12 Mar 2018 14:19:51 -0500 Subject: remove deprecated page_specific_javascript_bundle_tag --- app/helpers/javascript_helper.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/helpers/javascript_helper.rb b/app/helpers/javascript_helper.rb index d5e77c7e271..cd4075b340d 100644 --- a/app/helpers/javascript_helper.rb +++ b/app/helpers/javascript_helper.rb @@ -2,9 +2,4 @@ module JavascriptHelper def page_specific_javascript_tag(js) javascript_include_tag asset_path(js) end - - # deprecated; use webpack_bundle_tag directly instead - def page_specific_javascript_bundle_tag(bundle) - webpack_bundle_tag(bundle) - end end -- cgit v1.2.1 From ab8ad58ea1b49387081a862f7b58efc538d9a708 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 12 Mar 2018 15:19:19 -0500 Subject: rewrite docs for page-specific-javascript --- doc/development/fe_guide/performance.md | 122 +++++++++++++++++++++++--------- 1 file changed, 88 insertions(+), 34 deletions(-) diff --git a/doc/development/fe_guide/performance.md b/doc/development/fe_guide/performance.md index 98e43931a02..82e110ba8e3 100644 --- a/doc/development/fe_guide/performance.md +++ b/doc/development/fe_guide/performance.md @@ -49,39 +49,95 @@ properties once, and handle the actual animation with transforms. ### Page-specific JavaScript -Certain pages may require the use of a third party library, such as [d3][d3] for -the User Activity Calendar and [Chart.js][chartjs] for the Graphs pages. These -libraries increase the page size significantly, and impact load times due to -bandwidth bottlenecks and the browser needing to parse more JavaScript. - -In cases where libraries are only used on a few specific pages, we use -"page-specific JavaScript" to prevent the main `main.js` file from -becoming unnecessarily large. - -Steps to split page-specific JavaScript from the main `main.js`: - -1. Create a directory for the specific page(s), e.g. `graphs/`. -1. In that directory, create a `namespace_bundle.js` file, e.g. `graphs_bundle.js`. -1. Add the new "bundle" file to the list of entry files in `config/webpack.config.js`. - - For example: `graphs: './graphs/graphs_bundle.js',`. -1. Move code reliant on these libraries into the `graphs` directory. -1. In `graphs_bundle.js` add CommonJS `require('./path_to_some_component.js');` statements to load any other files in this directory. Make sure to use relative urls. -1. In the relevant views, add the scripts to the page with the following: - -```haml -- content_for :page_specific_javascripts do - = webpack_bundle_tag 'lib_chart' - = webpack_bundle_tag 'graphs' -``` - -The above loads `chart.js` and `graphs_bundle.js` for this page only. `chart.js` -is separated from the bundle file so it can be cached separately from the bundle -and reused for other pages that also rely on the library. For an example, see -[this Haml file][page-specific-js-example]. +Webpack has been configured to automatically generate entry point bundles based +on the file structure within `app/assets/javascripts/pages/*`. The directories +within the `pages` directory are meant to correspond to Rails controllers and +actions. These auto-generated bundles will be automatically included on the +corresponding pages. + +For example, if you were to visit [gitlab.com/gitlab-org/gitlab-ce/issues](https://gitlab.com/gitlab-org/gitlab-ce/issues), +you would be accessing the `app/controllers/projects/issues_controller.rb` +controller with the `index` action. If a corresponding file exists at +`pages/projects/issues/index/index.js`, it will be compiled into a webpack +bundle and included on the page. + +> **Note:** Previously we had encouraged the use of +> `content_for :page_specific_javascripts` within haml files, along with +> manually generated webpack bundles. However under this new system you should +> not ever need to manually add an entry point to the `webpack.config.js` file. + +In addition to these page-specific bundles, the code within `main.js` and +`commons/index.js` are imported on _all_ pages. + +#### Important Tips and Considerations: + +- If you are unsure what controller and action corresponds to a given page, you + can find this out by checking `document.body.dataset.page` while on any page + within gitlab.com. + +- Since `main.js` and `commons/index.js` are imported on all pages, it is + important to not add anything to these bundles unless it is truly needed + _everywhere_. This includes ubiquitous libraries like `vue`, `axios`, and + `jQuery`, as well as code for the main navigation and sidebar. + +- Page-specific javascript entry points should be as lite as possible. These + files are exempt from tests, and should be used primarily for instantiation + and dependency injection of classes and methods that live in modules outside + of the entry point script. Just import, read the DOM, instantiate, and + nothing else. + +- **DO NOT ASSUME** that the DOM has been fully loaded and available when an + entry point script is run. If you require that some code be run after the + DOM has loaded, you must attach an event handler to the `DOMContentLoaded` + event with: + + ```javascript + import initMyWidget from './my_widget'; + + document.addEventListener('DOMContentLoaded', () => { + initMyWidget(); + }); + ``` + +- If a class or a module is specific to a particular route, try to locate it + close to the entry point it will be used. For instance, if `my_widget.js` is + only imported within `pages/widget/show/index.js`, you should place the + module at `pages/widget/show/my_widget.js` and import it with a relative path + (e.g. `import initMyWidget from './my_widget';`). + +- If a class or module is used by multiple routes, place it within a shared + directory at the closest common parent directory for the entry points that + import it. For example, if `my_widget.js` is imported within both + `pages/widget/show/index.js` and `pages/widget/run/index.js`, then place the + module at `pages/widget/shared/my_widget.js` and import it with a relative + path if possible `../shared/my_widget`. + +- For GitLab Enterprise Edition, page-specific entry points will override their + Community Edition counterparts with the same name, so if + `ee/app/assets/javascripts/pages/foo/bar/index.js` exists, it will take + precedence over `app/assets/javascripts/pages/foo/bar/index.js`. If you want + to minimize duplicate code, you can import one entry point from the other. + This is not done automatically to allow for flexibility in overriding + functionality. ### Code Splitting -> *TODO* flesh out this section once webpack is ready for code-splitting +For any code that does not need to be run immediately upon page load, (e.g. +modals, dropdowns, and other behaviors that can be lazy-loaded), you can split +your module into asynchronous chunks with dynamic import statements. These +imports return a Promise which will be resolved once the script has loaded: + +```javascript +import(/* webpackChunkName: 'emoji' */ '~/emoji') + .then(/* do something */) + .catch(/* report error */) +``` + +Please try to use `webpackChunkName` when generating these dynamic imports as +it will provide a deterministic filename for the chunk which can then be cached +the browser. + +More information is available in [webpack's code splitting documentation](https://webpack.js.org/guides/code-splitting/#dynamic-imports). ### Minimizing page size @@ -95,7 +151,8 @@ General tips: - Prefer font formats with better compression, e.g. WOFF2 is better than WOFF, which is better than TTF. - Compress and minify assets wherever possible (For CSS/JS, Sprockets and webpack do this for us). - If some functionality can reasonably be achieved without adding extra libraries, avoid them. -- Use page-specific JavaScript as described above to dynamically load libraries that are only needed on certain pages. +- Use page-specific JavaScript as described above to load libraries that are only needed on certain pages. +- Use code-splitting dynamic imports wherever possible to lazy-load code that is not needed initially. - [High Performance Animations][high-perf-animations] ------- @@ -112,8 +169,5 @@ General tips: [pagespeed-insights]: https://developers.google.com/speed/pagespeed/insights/ [google-devtools-profiling]: https://developers.google.com/web/tools/chrome-devtools/profile/?hl=en [browser-diet]: https://browserdiet.com/ -[d3]: https://d3js.org/ -[chartjs]: http://www.chartjs.org/ -[page-specific-js-example]: https://gitlab.com/gitlab-org/gitlab-ce/blob/13bb9ed77f405c5f6ee4fdbc964ecf635c9a223f/app/views/projects/graphs/_head.html.haml#L6-8 [high-perf-animations]: https://www.html5rocks.com/en/tutorials/speed/high-performance-animations/ [flip]: https://aerotwist.com/blog/flip-your-animations/ -- cgit v1.2.1 From ae47afb9fdb9bea0ce18273bd1a9dc400833af72 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 12 Mar 2018 15:24:55 -0500 Subject: add section for universal code --- doc/development/fe_guide/performance.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/development/fe_guide/performance.md b/doc/development/fe_guide/performance.md index 82e110ba8e3..70cd79ecb3a 100644 --- a/doc/development/fe_guide/performance.md +++ b/doc/development/fe_guide/performance.md @@ -47,6 +47,15 @@ properties once, and handle the actual animation with transforms. ## Reducing Asset Footprint +### Universal code + +Code that is contained within `main.js` and `commons/index.js` are loaded and +run on _all_ pages. **DO NOT ADD** anything to these files unless it is truly +needed _everywhere_. This includes ubiquitous libraries like `vue`, `axios`, +and `jQuery`, as well as code for the main navigation and sidebar. Where +possible we should aim to remove modules from these bundles to reduce our code +footprint. + ### Page-specific JavaScript Webpack has been configured to automatically generate entry point bundles based @@ -75,11 +84,6 @@ In addition to these page-specific bundles, the code within `main.js` and can find this out by checking `document.body.dataset.page` while on any page within gitlab.com. -- Since `main.js` and `commons/index.js` are imported on all pages, it is - important to not add anything to these bundles unless it is truly needed - _everywhere_. This includes ubiquitous libraries like `vue`, `axios`, and - `jQuery`, as well as code for the main navigation and sidebar. - - Page-specific javascript entry points should be as lite as possible. These files are exempt from tests, and should be used primarily for instantiation and dependency injection of classes and methods that live in modules outside -- cgit v1.2.1 From 66ee5b0117dcd53ae6e9295c56d200be884d5ae9 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 12 Mar 2018 15:31:28 -0500 Subject: emphasize headings for each page-specific-javascript tip --- doc/development/fe_guide/performance.md | 43 ++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/doc/development/fe_guide/performance.md b/doc/development/fe_guide/performance.md index 70cd79ecb3a..65d95edca77 100644 --- a/doc/development/fe_guide/performance.md +++ b/doc/development/fe_guide/performance.md @@ -80,19 +80,22 @@ In addition to these page-specific bundles, the code within `main.js` and #### Important Tips and Considerations: -- If you are unsure what controller and action corresponds to a given page, you +- **Identifying Controller Paths:** + If you are unsure what controller and action corresponds to a given page, you can find this out by checking `document.body.dataset.page` while on any page within gitlab.com. -- Page-specific javascript entry points should be as lite as possible. These +- **Keep Entry Points Lite:** + Page-specific javascript entry points should be as lite as possible. These files are exempt from tests, and should be used primarily for instantiation and dependency injection of classes and methods that live in modules outside of the entry point script. Just import, read the DOM, instantiate, and nothing else. -- **DO NOT ASSUME** that the DOM has been fully loaded and available when an +- **Entry Points May Be Asynchronous:** + _DO NOT ASSUME_ that the DOM has been fully loaded and available when an entry point script is run. If you require that some code be run after the - DOM has loaded, you must attach an event handler to the `DOMContentLoaded` + DOM has loaded, you should attach an event handler to the `DOMContentLoaded` event with: ```javascript @@ -103,20 +106,22 @@ In addition to these page-specific bundles, the code within `main.js` and }); ``` -- If a class or a module is specific to a particular route, try to locate it - close to the entry point it will be used. For instance, if `my_widget.js` is - only imported within `pages/widget/show/index.js`, you should place the - module at `pages/widget/show/my_widget.js` and import it with a relative path - (e.g. `import initMyWidget from './my_widget';`). - -- If a class or module is used by multiple routes, place it within a shared - directory at the closest common parent directory for the entry points that - import it. For example, if `my_widget.js` is imported within both - `pages/widget/show/index.js` and `pages/widget/run/index.js`, then place the - module at `pages/widget/shared/my_widget.js` and import it with a relative - path if possible `../shared/my_widget`. - -- For GitLab Enterprise Edition, page-specific entry points will override their +- **Supporting Module Placement:** + - If a class or a module is _specific to a particular route_, try to locate + it close to the entry point it will be used. For instance, if + `my_widget.js` is only imported within `pages/widget/show/index.js`, you + should place the module at `pages/widget/show/my_widget.js` and import it + with a relative path (e.g. `import initMyWidget from './my_widget';`). + + - If a class or module is _used by multiple routes_, place it within a + shared directory at the closest common parent directory for the entry + points that import it. For example, if `my_widget.js` is imported within + both `pages/widget/show/index.js` and `pages/widget/run/index.js`, then + place the module at `pages/widget/shared/my_widget.js` and import it with + a relative path if possible (e.g. `../shared/my_widget`). + +- **Enterprise Edition Caveats:** + For GitLab Enterprise Edition, page-specific entry points will override their Community Edition counterparts with the same name, so if `ee/app/assets/javascripts/pages/foo/bar/index.js` exists, it will take precedence over `app/assets/javascripts/pages/foo/bar/index.js`. If you want @@ -139,7 +144,7 @@ import(/* webpackChunkName: 'emoji' */ '~/emoji') Please try to use `webpackChunkName` when generating these dynamic imports as it will provide a deterministic filename for the chunk which can then be cached -the browser. +the browser across GitLab versions. More information is available in [webpack's code splitting documentation](https://webpack.js.org/guides/code-splitting/#dynamic-imports). -- cgit v1.2.1 From 6cfd38e5122e8b52219816a4e03231311df23def Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 12 Mar 2018 15:33:32 -0500 Subject: differentiate image lazy-loading from code splitting --- doc/development/fe_guide/performance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/development/fe_guide/performance.md b/doc/development/fe_guide/performance.md index 65d95edca77..045a1d73d9b 100644 --- a/doc/development/fe_guide/performance.md +++ b/doc/development/fe_guide/performance.md @@ -23,7 +23,7 @@ controlled by the server. 1. The backend code will most likely be using etags. You do not and should not check for status `304 Not Modified`. The browser will transform it for you. -### Lazy Loading +### Lazy Loading Images To improve the time to first render we are using lazy loading for images. This works by setting the actual image source on the `data-src` attribute. After the HTML is rendered and JavaScript is loaded, -- cgit v1.2.1 From 06a07e12889bb0cfd3ffd15245cfc5edcbf6bd6f Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 12 Mar 2018 15:39:39 -0500 Subject: update EE features frontend section to point to performance.md for info on page-specific EE code --- doc/development/ee_features.md | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/doc/development/ee_features.md b/doc/development/ee_features.md index 1eb90c30ebd..fea92e740cb 100644 --- a/doc/development/ee_features.md +++ b/doc/development/ee_features.md @@ -360,27 +360,15 @@ Instead place EE specs in the `ee/spec` folder. ## JavaScript code in `assets/javascripts/` -To separate EE-specific JS-files we can also move the files into an `ee` folder. +To separate EE-specific JS-files we should also move the files into an `ee` folder. For example there can be an `app/assets/javascripts/protected_branches/protected_branches_bundle.js` and an EE counterpart `ee/app/assets/javascripts/protected_branches/protected_branches_bundle.js`. -That way we can create a separate webpack bundle in `webpack.config.js`: - -```javascript - protected_branches: '~/protected_branches', - ee_protected_branches: 'ee/protected_branches/protected_branches_bundle.js', -``` - -With the separate bundle in place, we can decide which bundle to load inside the -view, using the `page_specific_javascript_bundle_tag` helper. - -```haml -- content_for :page_specific_javascripts do - = page_specific_javascript_bundle_tag('protected_branches') -``` +See the frontend guide [performance section](./fe_guide/performance.md) for +information on managing page-specific javascript within EE. ## SCSS code in `assets/stylesheets` -- cgit v1.2.1 From 43ceaf494fa21eb38e87b68c3451b9b1e55d065a Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 12 Mar 2018 15:46:13 -0500 Subject: update node and yarn dependencies within install/upgrade docs --- changelogs/unreleased/43720-update-fe-webpack-docs.yml | 6 ++++++ doc/development/fe_guide/index.md | 4 ++-- doc/install/installation.md | 15 ++++++++------- doc/update/10.5-to-10.6.md | 8 ++++---- 4 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 changelogs/unreleased/43720-update-fe-webpack-docs.yml diff --git a/changelogs/unreleased/43720-update-fe-webpack-docs.yml b/changelogs/unreleased/43720-update-fe-webpack-docs.yml new file mode 100644 index 00000000000..9e461eaaec8 --- /dev/null +++ b/changelogs/unreleased/43720-update-fe-webpack-docs.yml @@ -0,0 +1,6 @@ +--- +title: Update documentation to reflect current minimum required versions of node and + yarn +merge_request: 17706 +author: +type: other diff --git a/doc/development/fe_guide/index.md b/doc/development/fe_guide/index.md index 12dfc10812b..2280cf79f86 100644 --- a/doc/development/fe_guide/index.md +++ b/doc/development/fe_guide/index.md @@ -14,8 +14,8 @@ support through [webpack][webpack]. We also utilize [webpack][webpack] to handle the bundling, minification, and compression of our assets. -Working with our frontend assets requires Node (v4.3 or greater) and Yarn -(v0.17 or greater). You can find information on how to install these on our +Working with our frontend assets requires Node (v6.0 or greater) and Yarn +(v1.2 or greater). You can find information on how to install these on our [installation guide][install]. [jQuery][jquery] is used throughout the application's JavaScript, with diff --git a/doc/install/installation.md b/doc/install/installation.md index 6eb767b00b3..1abbfd78738 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -162,13 +162,14 @@ page](https://golang.org/dl). ## 4. Node -Since GitLab 8.17, GitLab requires the use of node >= v4.3.0 to compile -javascript assets, and yarn >= v0.17.0 to manage javascript dependencies. -In many distros the versions provided by the official package repositories -are out of date, so we'll need to install through the following commands: - - # install node v7.x - curl --location https://deb.nodesource.com/setup_7.x | sudo bash - +Since GitLab 8.17, GitLab requires the use of Node to compile javascript +assets, and Yarn to manage javascript dependencies. The current minimum +requirements for these are node >= v6.0.0 and yarn >= v1.2.0. In many distros +the versions provided by the official package repositories are out of date, so +we'll need to install through the following commands: + + # install node v8.x + curl --location https://deb.nodesource.com/setup_8.x | sudo bash - sudo apt-get install -y nodejs curl --silent --show-error https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - diff --git a/doc/update/10.5-to-10.6.md b/doc/update/10.5-to-10.6.md index af8343b5958..f5c5c305726 100644 --- a/doc/update/10.5-to-10.6.md +++ b/doc/update/10.5-to-10.6.md @@ -56,8 +56,8 @@ sudo gem install bundler --no-ri --no-rdoc ### 4. Update Node -GitLab now runs [webpack](http://webpack.js.org) to compile frontend assets. -We require a minimum version of node v6.0.0. +GitLab utilizes [webpack](http://webpack.js.org) to compile frontend assets. +This requires a minimum version of node v6.0.0. You can check which version you are running with `node -v`. If you are running a version older than `v6.0.0` you will need to update to a newer version. You @@ -66,8 +66,8 @@ from source at the nodejs.org website. -Since 8.17, GitLab requires the use of yarn `>= v0.17.0` to manage -JavaScript dependencies. +GitLab also requires the use of yarn `>= v1.2.0` to manage JavaScript +dependencies. ```bash curl --silent --show-error https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - -- cgit v1.2.1 From afe2c15e6bf1005e5bd1d213d3548a1a17a11137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D=C3=A1vila?= Date: Mon, 12 Mar 2018 16:01:43 -0500 Subject: Fix provider server URL used when listing repos to import Also use Gitlab::Auth::OAuth::Provider.config_for to access OmniAuth config --- app/helpers/import_helper.rb | 13 +++++---- ...4-fix-generated-url-for-external-repository.yml | 5 ++++ lib/gitlab/auth/saml/config.rb | 2 +- lib/gitlab/github_import/client.rb | 5 +--- lib/gitlab/gitlab_import/client.rb | 2 +- lib/gitlab/legacy_github_import/client.rb | 2 +- lib/google_api/auth.rb | 2 +- spec/helpers/import_helper_spec.rb | 33 ++++++++++++++++++---- 8 files changed, 46 insertions(+), 18 deletions(-) create mode 100644 changelogs/unreleased/34604-fix-generated-url-for-external-repository.yml diff --git a/app/helpers/import_helper.rb b/app/helpers/import_helper.rb index 9149d79ecb8..4664b1728c4 100644 --- a/app/helpers/import_helper.rb +++ b/app/helpers/import_helper.rb @@ -1,4 +1,6 @@ module ImportHelper + include ::Gitlab::Utils::StrongMemoize + def has_ci_cd_only_params? false end @@ -75,17 +77,18 @@ module ImportHelper private def github_project_url(full_path) - "#{github_root_url}/#{full_path}" + URI.join(github_root_url, full_path).to_s end def github_root_url - return @github_url if defined?(@github_url) + strong_memoize(:github_url) do + provider = Gitlab::Auth::OAuth::Provider.config_for('github') - provider = Gitlab.config.omniauth.providers.find { |p| p.name == 'github' } - @github_url = provider.fetch('url', 'https://github.com') if provider + provider&.dig('url').presence || 'https://github.com' + end end def gitea_project_url(full_path) - "#{@gitea_host_url.sub(%r{/+\z}, '')}/#{full_path}" + URI.join(@gitea_host_url, full_path).to_s end end diff --git a/changelogs/unreleased/34604-fix-generated-url-for-external-repository.yml b/changelogs/unreleased/34604-fix-generated-url-for-external-repository.yml new file mode 100644 index 00000000000..c4b5f59b724 --- /dev/null +++ b/changelogs/unreleased/34604-fix-generated-url-for-external-repository.yml @@ -0,0 +1,5 @@ +--- +title: Fix generated URL when listing repoitories for import +merge_request: 17692 +author: +type: fixed diff --git a/lib/gitlab/auth/saml/config.rb b/lib/gitlab/auth/saml/config.rb index e654e7fe438..2760b1a3247 100644 --- a/lib/gitlab/auth/saml/config.rb +++ b/lib/gitlab/auth/saml/config.rb @@ -4,7 +4,7 @@ module Gitlab class Config class << self def options - Gitlab.config.omniauth.providers.find { |provider| provider.name == 'saml' } + Gitlab::Auth::OAuth::Provider.config_for('saml') end def groups diff --git a/lib/gitlab/github_import/client.rb b/lib/gitlab/github_import/client.rb index 4f160e4a447..a61beafae0d 100644 --- a/lib/gitlab/github_import/client.rb +++ b/lib/gitlab/github_import/client.rb @@ -197,10 +197,7 @@ module Gitlab end def github_omniauth_provider - @github_omniauth_provider ||= - Gitlab.config.omniauth.providers - .find { |provider| provider.name == 'github' } - .to_h + @github_omniauth_provider ||= Gitlab::Auth::OAuth::Provider.config_for('github').to_h end def rate_limit_counter diff --git a/lib/gitlab/gitlab_import/client.rb b/lib/gitlab/gitlab_import/client.rb index 075b3982608..5482504e72e 100644 --- a/lib/gitlab/gitlab_import/client.rb +++ b/lib/gitlab/gitlab_import/client.rb @@ -72,7 +72,7 @@ module Gitlab end def config - Gitlab.config.omniauth.providers.find {|provider| provider.name == "gitlab"} + Gitlab::Auth::OAuth::Provider.config_for('gitlab') end def gitlab_options diff --git a/lib/gitlab/legacy_github_import/client.rb b/lib/gitlab/legacy_github_import/client.rb index 53c910d44bd..d8ed0ebca9d 100644 --- a/lib/gitlab/legacy_github_import/client.rb +++ b/lib/gitlab/legacy_github_import/client.rb @@ -83,7 +83,7 @@ module Gitlab end def config - Gitlab.config.omniauth.providers.find { |provider| provider.name == "github" } + Gitlab::Auth::OAuth::Provider.config_for('github') end def github_options diff --git a/lib/google_api/auth.rb b/lib/google_api/auth.rb index 99a82c849e0..1aeaa387a49 100644 --- a/lib/google_api/auth.rb +++ b/lib/google_api/auth.rb @@ -32,7 +32,7 @@ module GoogleApi private def config - Gitlab.config.omniauth.providers.find { |provider| provider.name == "google_oauth2" } + Gitlab::Auth::OAuth::Provider.config_for('google_oauth2') end def client diff --git a/spec/helpers/import_helper_spec.rb b/spec/helpers/import_helper_spec.rb index 9afff47f4e9..57d843c1be2 100644 --- a/spec/helpers/import_helper_spec.rb +++ b/spec/helpers/import_helper_spec.rb @@ -27,25 +27,48 @@ describe ImportHelper do describe '#provider_project_link' do context 'when provider is "github"' do + let(:github_server_url) { nil } + + before do + setting = Settingslogic.new('name' => 'github') + setting['url'] = github_server_url if github_server_url + + allow(Gitlab.config.omniauth).to receive(:providers).and_return([setting]) + end + context 'when provider does not specify a custom URL' do it 'uses default GitHub URL' do - allow(Gitlab.config.omniauth).to receive(:providers) - .and_return([Settingslogic.new('name' => 'github')]) - expect(helper.provider_project_link('github', 'octocat/Hello-World')) .to include('href="https://github.com/octocat/Hello-World"') end end context 'when provider specify a custom URL' do + let(:github_server_url) { 'https://github.company.com' } + it 'uses custom URL' do - allow(Gitlab.config.omniauth).to receive(:providers) - .and_return([Settingslogic.new('name' => 'github', 'url' => 'https://github.company.com')]) + expect(helper.provider_project_link('github', 'octocat/Hello-World')) + .to include('href="https://github.company.com/octocat/Hello-World"') + end + end + + context "when custom URL contains a '/' char at the end" do + let(:github_server_url) { 'https://github.company.com/' } + it "doesn't render double slash" do expect(helper.provider_project_link('github', 'octocat/Hello-World')) .to include('href="https://github.company.com/octocat/Hello-World"') end end + + context 'when provider is missing' do + it 'uses the default URL' do + allow(Gitlab.config.omniauth).to receive(:providers).and_return([]) + + expect(helper.provider_project_link('github', 'octocat/Hello-World')) + .to include('href="https://github.com/octocat/Hello-World"') + end + end end context 'when provider is "gitea"' do -- cgit v1.2.1 From d92baff68f8c14e81bc3b3351a2318cdd0135b84 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 12 Mar 2018 17:42:38 -0500 Subject: address wording feedback --- doc/development/fe_guide/performance.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/development/fe_guide/performance.md b/doc/development/fe_guide/performance.md index 045a1d73d9b..93b999568ad 100644 --- a/doc/development/fe_guide/performance.md +++ b/doc/development/fe_guide/performance.md @@ -51,18 +51,18 @@ properties once, and handle the actual animation with transforms. Code that is contained within `main.js` and `commons/index.js` are loaded and run on _all_ pages. **DO NOT ADD** anything to these files unless it is truly -needed _everywhere_. This includes ubiquitous libraries like `vue`, `axios`, -and `jQuery`, as well as code for the main navigation and sidebar. Where -possible we should aim to remove modules from these bundles to reduce our code -footprint. +needed _everywhere_. These bundles include ubiquitous libraries like `vue`, +`axios`, and `jQuery`, as well as code for the main navigation and sidebar. +Where possible we should aim to remove modules from these bundles to reduce our +code footprint. ### Page-specific JavaScript Webpack has been configured to automatically generate entry point bundles based on the file structure within `app/assets/javascripts/pages/*`. The directories -within the `pages` directory are meant to correspond to Rails controllers and -actions. These auto-generated bundles will be automatically included on the -corresponding pages. +within the `pages` directory correspond to Rails controllers and actions. These +auto-generated bundles will be automatically included on the corresponding +pages. For example, if you were to visit [gitlab.com/gitlab-org/gitlab-ce/issues](https://gitlab.com/gitlab-org/gitlab-ce/issues), you would be accessing the `app/controllers/projects/issues_controller.rb` @@ -82,8 +82,8 @@ In addition to these page-specific bundles, the code within `main.js` and - **Identifying Controller Paths:** If you are unsure what controller and action corresponds to a given page, you - can find this out by checking `document.body.dataset.page` while on any page - within gitlab.com. + can find this out by inspecting `document.body.dataset.page` within your + browser's developer console while on any page within gitlab. - **Keep Entry Points Lite:** Page-specific javascript entry points should be as lite as possible. These -- cgit v1.2.1 From 9f9257fa5ab5fe1dafc4be4aa5bd9a5dbc9323cd Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 12 Mar 2018 17:51:01 -0500 Subject: specify that webpack entry points are exempt from unit tests, not integration tests --- doc/development/fe_guide/performance.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/development/fe_guide/performance.md b/doc/development/fe_guide/performance.md index 93b999568ad..5c3936fe1cc 100644 --- a/doc/development/fe_guide/performance.md +++ b/doc/development/fe_guide/performance.md @@ -87,10 +87,10 @@ In addition to these page-specific bundles, the code within `main.js` and - **Keep Entry Points Lite:** Page-specific javascript entry points should be as lite as possible. These - files are exempt from tests, and should be used primarily for instantiation - and dependency injection of classes and methods that live in modules outside - of the entry point script. Just import, read the DOM, instantiate, and - nothing else. + files are exempt from unit tests, and should be used primarily for + instantiation and dependency injection of classes and methods that live in + modules outside of the entry point script. Just import, read the DOM, + instantiate, and nothing else. - **Entry Points May Be Asynchronous:** _DO NOT ASSUME_ that the DOM has been fully loaded and available when an -- cgit v1.2.1 From f3d3a4719d0b42e740e2c95e7d4a0198272872ad Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 12 Mar 2018 18:00:44 -0500 Subject: move tip into blockquote --- doc/development/fe_guide/performance.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/doc/development/fe_guide/performance.md b/doc/development/fe_guide/performance.md index 5c3936fe1cc..1320efaf767 100644 --- a/doc/development/fe_guide/performance.md +++ b/doc/development/fe_guide/performance.md @@ -75,15 +75,12 @@ bundle and included on the page. > manually generated webpack bundles. However under this new system you should > not ever need to manually add an entry point to the `webpack.config.js` file. -In addition to these page-specific bundles, the code within `main.js` and -`commons/index.js` are imported on _all_ pages. +> **Tip:** +> If you are unsure what controller and action corresponds to a given page, you +> can find this out by inspecting `document.body.dataset.page` within your +> browser's developer console while on any page within gitlab. -#### Important Tips and Considerations: - -- **Identifying Controller Paths:** - If you are unsure what controller and action corresponds to a given page, you - can find this out by inspecting `document.body.dataset.page` within your - browser's developer console while on any page within gitlab. +#### Important Considerations: - **Keep Entry Points Lite:** Page-specific javascript entry points should be as lite as possible. These -- cgit v1.2.1 From 93c6842fbf74b0a680b3e730848b1d2b8bfceefa Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Tue, 13 Mar 2018 09:25:39 +0000 Subject: Use mapState instead of a getter --- app/assets/javascripts/notes/components/comment_form.vue | 4 +++- app/assets/javascripts/notes/stores/getters.js | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/notes/components/comment_form.vue b/app/assets/javascripts/notes/components/comment_form.vue index a649e180131..42bc383f4d2 100644 --- a/app/assets/javascripts/notes/components/comment_form.vue +++ b/app/assets/javascripts/notes/components/comment_form.vue @@ -1,6 +1,6 @@