Skip to content
Snippets Groups Projects
Commit b8bb2148 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 64fbcb2e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
import FilteredSearchTokenKeys from './filtered_search_token_keys';
import { __ } from '~/locale';
 
export const tokenKeys = [];
tokenKeys.push(
export const tokenKeys = [
{
key: 'author',
type: 'string',
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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() {
Loading
Loading
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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
 
Loading
Loading
Loading
Loading
@@ -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))
Loading
Loading
---
title: refactor javascript to remove Immediately Invoked Function Expression from
project file search
merge_request: 19192
author: Brian Luckenbill
type: other
Loading
Loading
@@ -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
},
},
});
 
Loading
Loading
@@ -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
Loading
Loading
Loading
Loading
@@ -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"
Loading
Loading
@@ -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 ""
 
Loading
Loading
@@ -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 ""
 
Loading
Loading
@@ -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 ""
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment