@@ -4,6 +4,7 @@ import { mapState } from 'vuex';
4
4
import { __ , s__ } from ' ~/locale' ;
5
5
import getBlobSearchQuery from ' ~/search/graphql/blob_search_zoekt.query.graphql' ;
6
6
import { parseBoolean } from ' ~/lib/utils/common_utils' ;
7
+ import { logError } from ' ~/lib/logger' ;
7
8
import { DEFAULT_FETCH_CHUNKS } from ' ../constants' ;
8
9
import { RECEIVE_NAVIGATION_COUNT } from ' ../../store/mutation_types' ;
9
10
import EmptyResult from ' ./result_empty.vue' ;
@@ -30,7 +31,6 @@ export default {
30
31
return {
31
32
hasError: false ,
32
33
blobSearch: {},
33
- hasResults: true ,
34
34
};
35
35
},
36
36
apollo: {
@@ -40,30 +40,40 @@ export default {
40
40
},
41
41
errorPolicy: ' none' ,
42
42
variables () {
43
- return {
44
- search: this .query .search ,
45
- groupId: this .query .group_id && ` gid://gitlab/Group/${ this .query .group_id } ` ,
46
- projectId: this .query .project_id && ` gid://gitlab/Project/${ this .query .project_id } ` ,
43
+ const variables = {
44
+ search: this .query .search || ' ' ,
47
45
page: this .currentPage ,
48
46
chunkCount: DEFAULT_FETCH_CHUNKS ,
49
- regex: parseBoolean (this .query .regex ),
50
- includeArchived: parseBoolean (this .query .include_archived ),
51
- includeForked: parseBoolean (this .query .include_forked ),
47
+ regex: parseBoolean (this .query ? .regex ),
48
+ includeArchived: parseBoolean (this .query ? .include_archived ),
49
+ includeForked: parseBoolean (this .query ? .include_forked ),
52
50
};
51
+
52
+ if (this .query ? .group_id ) {
53
+ variables .groupId = ` gid://gitlab/Group/${ this .query .group_id } ` ;
54
+ }
55
+
56
+ if (this .query ? .project_id ) {
57
+ variables .projectId = ` gid://gitlab/Project/${ this .query .project_id } ` ;
58
+ }
59
+
60
+ return variables;
61
+ },
62
+ skip () {
63
+ return ! this .query .search ;
53
64
},
54
65
result ({ data }) {
55
66
this .hasError = false ;
56
67
this .blobSearch = data? .blobSearch ;
57
- this .hasResults = data? .blobSearch ? .files ? .length > 0 ;
58
68
this .$store .commit (RECEIVE_NAVIGATION_COUNT , {
59
69
key: ' blobs' ,
60
70
count: data? .blobSearch ? .matchCount .toString (),
61
71
});
62
72
},
63
73
debounce: 500 ,
64
- error () {
74
+ error (error ) {
75
+ logError (error);
65
76
this .hasError = true ;
66
- this .hasResults = false ;
67
77
},
68
78
},
69
79
},
@@ -75,6 +85,9 @@ export default {
75
85
isLoading () {
76
86
return this .$apollo .queries .blobSearch .loading ;
77
87
},
88
+ hasResults () {
89
+ return this .blobSearch ? .files ? .length > 0 ;
90
+ },
78
91
},
79
92
};
80
93
< / script>
@@ -86,7 +99,7 @@ export default {
86
99
< status- bar v- if = " !isLoading" : blob- search= " blobSearch" / >
87
100
< empty- result v- if = " !hasResults && !isLoading" / >
88
101
< zoekt- blob- results
89
- v- if = " hasResults"
102
+ v- if = " hasResults || isLoading "
90
103
: blob- search= " blobSearch"
91
104
: has- results= " hasResults"
92
105
: is- loading= " isLoading"
0 commit comments