Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-23 12:07:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-23 12:07:42 +0300
commitb8bb2148c282f5ebaf5cd3c83d905285902a1446 (patch)
tree9c104ecb570b5df83ef2e01fa26d0a56355c1d05
parent64fbcb2e57083569f2fda885784c20b6bc2c38f4 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--.gitlab/CODEOWNERS2
-rw-r--r--app/assets/javascripts/filtered_search/issuable_filtered_search_token_keys.js30
-rw-r--r--app/assets/javascripts/project_find_file.js35
-rw-r--r--app/controllers/projects/issues_controller.rb1
-rw-r--r--app/controllers/projects/merge_requests_controller.rb1
-rw-r--r--app/models/concerns/reactive_caching.rb8
-rw-r--r--changelogs/unreleased/patch-36.yml6
-rw-r--r--doc/development/fe_guide/graphql.md92
-rw-r--r--locale/gitlab.pot11
9 files changed, 134 insertions, 52 deletions
diff --git a/.gitlab/CODEOWNERS b/.gitlab/CODEOWNERS
index 0e16e1407ac..f19a7fec7c6 100644
--- a/.gitlab/CODEOWNERS
+++ b/.gitlab/CODEOWNERS
@@ -3,7 +3,7 @@
*.rake @gitlab-org/maintainers/rails-backend
# Technical writing team are the default reviewers for everything in `doc/`
-doc/ @gl-docsteam
+/doc/* @gl-docsteam
# Frontend maintainers should see everything in `app/assets/`
app/assets/ @gitlab-org/maintainers/frontend
diff --git a/app/assets/javascripts/filtered_search/issuable_filtered_search_token_keys.js b/app/assets/javascripts/filtered_search/issuable_filtered_search_token_keys.js
index 414bcf186a3..eb518eb1f52 100644
--- a/app/assets/javascripts/filtered_search/issuable_filtered_search_token_keys.js
+++ b/app/assets/javascripts/filtered_search/issuable_filtered_search_token_keys.js
@@ -1,9 +1,7 @@
import FilteredSearchTokenKeys from './filtered_search_token_keys';
import { __ } from '~/locale';
-export const tokenKeys = [];
-
-tokenKeys.push(
+export const tokenKeys = [
{
key: 'author',
type: 'string',
@@ -28,27 +26,23 @@ tokenKeys.push(
icon: 'clock',
tag: '%milestone',
},
-);
-
-if (gon && gon.features && gon.features.releaseSearchFilter) {
- tokenKeys.push({
+ {
key: 'release',
type: 'string',
param: 'tag',
symbol: '',
icon: 'rocket',
tag: __('tag name'),
- });
-}
-
-tokenKeys.push({
- key: 'label',
- type: 'array',
- param: 'name[]',
- symbol: '~',
- icon: 'labels',
- tag: '~label',
-});
+ },
+ {
+ key: 'label',
+ type: 'array',
+ param: 'name[]',
+ symbol: '~',
+ icon: 'labels',
+ tag: '~label',
+ },
+];
if (gon.current_user_id) {
// Appending tokenkeys only logged-in
diff --git a/app/assets/javascripts/project_find_file.js b/app/assets/javascripts/project_find_file.js
index d6cdd37a2c3..a31034361a8 100644
--- a/app/assets/javascripts/project_find_file.js
+++ b/app/assets/javascripts/project_find_file.js
@@ -55,26 +55,21 @@ export default class ProjectFindFile {
initEvent() {
this.inputElement.off('keyup');
- this.inputElement.on(
- 'keyup',
- (function(_this) {
- return function(event) {
- const target = $(event.target);
- const value = target.val();
- const ref = target.data('oldValue');
- const oldValue = ref != null ? ref : '';
- if (value !== oldValue) {
- target.data('oldValue', value);
- _this.findFile();
- return _this.element
- .find('tr.tree-item')
- .eq(0)
- .addClass('selected')
- .focus();
- }
- };
- })(this),
- );
+ this.inputElement.on('keyup', event => {
+ const target = $(event.target);
+ const value = target.val();
+ const ref = target.data('oldValue');
+ const oldValue = ref != null ? ref : '';
+ if (value !== oldValue) {
+ target.data('oldValue', value);
+ this.findFile();
+ return this.element
+ .find('tr.tree-item')
+ .eq(0)
+ .addClass('selected')
+ .focus();
+ }
+ });
}
findFile() {
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index 229374c3929..f6514c4ba99 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -44,7 +44,6 @@ class Projects::IssuesController < Projects::ApplicationController
before_action do
push_frontend_feature_flag(:vue_issuable_sidebar, project.group)
- push_frontend_feature_flag(:release_search_filter, project, default_enabled: true)
end
respond_to :html
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index 69e3e7c7acb..94b5f29eff7 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -25,7 +25,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
before_action do
push_frontend_feature_flag(:vue_issuable_sidebar, @project.group)
- push_frontend_feature_flag(:release_search_filter, @project, default_enabled: true)
push_frontend_feature_flag(:async_mr_widget, @project)
end
diff --git a/app/models/concerns/reactive_caching.rb b/app/models/concerns/reactive_caching.rb
index 693f9ab8dc5..45fbbef9225 100644
--- a/app/models/concerns/reactive_caching.rb
+++ b/app/models/concerns/reactive_caching.rb
@@ -122,6 +122,14 @@ module ReactiveCaching
end
end
+ # This method is used for debugging purposes and should not be used otherwise.
+ def without_reactive_cache(*args, &blk)
+ return with_reactive_cache(*args, &blk) unless Rails.env.development?
+
+ data = self.class.reactive_cache_worker_finder.call(id, *args).calculate_reactive_cache(*args)
+ yield data
+ end
+
def clear_reactive_cache!(*args)
Rails.cache.delete(full_reactive_cache_key(*args))
Rails.cache.delete(alive_reactive_cache_key(*args))
diff --git a/changelogs/unreleased/patch-36.yml b/changelogs/unreleased/patch-36.yml
new file mode 100644
index 00000000000..7bf2d2ed1a8
--- /dev/null
+++ b/changelogs/unreleased/patch-36.yml
@@ -0,0 +1,6 @@
+---
+title: refactor javascript to remove Immediately Invoked Function Expression from
+ project file search
+merge_request: 19192
+author: Brian Luckenbill
+type: other
diff --git a/doc/development/fe_guide/graphql.md b/doc/development/fe_guide/graphql.md
index 40b9fdef76e..36cde1b0f75 100644
--- a/doc/development/fe_guide/graphql.md
+++ b/doc/development/fe_guide/graphql.md
@@ -109,17 +109,16 @@ import createDefaultClient from '~/lib/graphql';
Vue.use(VueApollo);
const defaultClient = createDefaultClient({
- Query: {
- ...
- },
- Mutations: {
- ...
- },
+ resolvers: {}
});
defaultClient.cache.writeData({
data: {
- isLoading: true,
+ user: {
+ name: 'John',
+ surname: 'Doe',
+ age: 30
+ },
},
});
@@ -128,6 +127,85 @@ const apolloProvider = new VueApollo({
});
```
+We can query local data with `@client` Apollo directive:
+
+```javascript
+// user.query.graphql
+
+query User {
+ user @client {
+ name
+ surname
+ age
+ }
+}
+```
+
+Along with creating local data, we can also extend existing GraphQL types with `@client` fields. This is extremely useful when we need to mock an API responses for fields not yet added to our GraphQL API.
+
+#### Mocking API response with local Apollo cache
+
+Using local Apollo Cache is handy when we have a need to mock some GraphQL API responses, queries or mutations locally (e.g. when they're still not added to our actual API).
+
+For example, we have a [fragment](#fragments) on `DesignVersion` used in our queries:
+
+```
+fragment VersionListItem on DesignVersion {
+ id
+ sha
+}
+```
+
+We need to fetch also version author and the 'created at' property to display them in the versions dropdown but these changes are still not implemented in our API. We can change the existing fragment to get a mocked response for these new fields:
+
+```
+fragment VersionListItem on DesignVersion {
+ id
+ sha
+ author @client {
+ avatarUrl
+ name
+ }
+ createdAt @client
+}
+```
+
+Now Apollo will try to find a _resolver_ for every field marked with `@client` directive. Let's create a resolver for `DesignVersion` type (why `DesignVersion`? because our fragment was created on this type).
+
+```javascript
+// resolvers.js
+
+const resolvers = {
+ DesignVersion: {
+ author: () => ({
+ avatarUrl:
+ 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon',
+ name: 'Administrator',
+ __typename: 'User',
+ }),
+ createdAt: () => '2019-11-13T16:08:11Z',
+ },
+};
+
+export default resolvers;
+```
+
+We need to pass resolvers object to our existing Apollo Client:
+
+```javascript
+// graphql.js
+
+import createDefaultClient from '~/lib/graphql';
+import resolvers from './graphql/resolvers';
+
+const defaultClient = createDefaultClient(
+ {},
+ resolvers,
+);
+```
+
+Now every single time on attempt to fetch a version, our client will fetch `id` and `sha` from the remote API endpoint and will assign our hardcoded values to `author` and `createdAt` version properties. With this data, frontend developers are able to work on UI part without being blocked by backend. When actual response is added to the API, a custom local resolver can be removed fast and the only change to query/fragment is `@client` directive removal.
+
Read more about local state management with Apollo in the [Vue Apollo documentation](https://vue-apollo.netlify.com/guide/local-state.html#local-state).
### Testing
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index c83fc685a62..03508e65eaf 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -12258,7 +12258,7 @@ msgstr ""
msgid "Number of commits per MR"
msgstr ""
-msgid "Number of employees?"
+msgid "Number of employees"
msgstr ""
msgid "Number of files touched"
@@ -17181,6 +17181,9 @@ msgstr ""
msgid "Start thread & reopen %{noteable_name}"
msgstr ""
+msgid "Start your Free Gold Trial"
+msgstr ""
+
msgid "Start your free trial"
msgstr ""
@@ -20290,9 +20293,6 @@ msgstr ""
msgid "We heard back from your U2F device. You have been authenticated."
msgstr ""
-msgid "We need some additional information to activate your free trial"
-msgstr ""
-
msgid "We sent you an email with reset password instructions"
msgstr ""
@@ -20979,6 +20979,9 @@ msgstr ""
msgid "Your GPG keys (%{count})"
msgstr ""
+msgid "Your Gitlab Gold trial will last 30 days after which point you can keep your free Gitlab account forever. We just need some additional information to activate your trial."
+msgstr ""
+
msgid "Your Groups"
msgstr ""