Skip to content

Commit e787040

Browse files
authored
Tweak eagle eye search bar UX (#13)
1 parent 127cf5d commit e787040

12 files changed

Lines changed: 230 additions & 49 deletions

frontend/src/i18n/en.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ const en = {
259259
'issues-close': 'closed an issue',
260260
'issues-closed': 'closed an issue',
261261
'issue-comment': 'commented on an issue',
262-
'pull_request-comment': 'commented on a pull request',
262+
'pull_request-comment':
263+
'commented on a pull request',
263264
'discussion-started': 'started a discussion',
264265
'discussion-comment': 'commented on a discussion',
265266
contributed_to_community:

frontend/src/premium/eagle-eye/components/eagle-eye-counter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="text-gray-600 text-sm">
2+
<div class="text-gray-600 text-sm" v-if="count > 0">
33
{{ count }}
44
{{ typeOfPostsFound }} posts
55
{{

frontend/src/premium/eagle-eye/components/eagle-eye-filter.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,25 @@ export default {
130130
return activeFilters
131131
}
132132
},
133+
watch: {
134+
filter: {
135+
handler(newValue, oldValue) {
136+
if (newValue.nDays !== oldValue.nDays) {
137+
this.nDays = newValue.nDays
138+
}
139+
this.platforms = newValue.platforms
140+
? newValue.platforms
141+
: ['hacker_news', 'devto']
142+
},
143+
deep: true
144+
},
145+
'filter.platforms': {
146+
handler(newValue) {
147+
this.platforms = [...newValue]
148+
},
149+
deep: true
150+
}
151+
},
133152
methods: {
134153
...mapActions({
135154
doReset: 'eagleEye/doReset',

frontend/src/premium/eagle-eye/components/eagle-eye-list.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="py-6">
2+
<div class="pt-2 pb-6">
33
<div class="eagle-eye-list">
44
<div v-if="count > 0">
55
<transition-group name="fade" mode="out-in">

frontend/src/premium/eagle-eye/components/eagle-eye-page.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<app-eagle-eye-search />
66
<div
77
v-if="shouldRenderEmptyState"
8-
class="flex flex-col items-center justify-center w-full py-14"
8+
class="flex flex-col items-center justify-center w-full py-10"
99
>
1010
<img
1111
src="/images/eagle-eye-empty-state.svg"
@@ -25,7 +25,7 @@
2525
v-loading="loading"
2626
></div>
2727
<div v-else>
28-
<div class="flex justify-between items-center pt-8">
28+
<div class="flex justify-between items-center pt-4">
2929
<app-eagle-eye-counter />
3030
<app-eagle-eye-sorter
3131
v-if="activeTab === 'inbox'"
Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
<template>
22
<div class="eagle-eye-search">
3-
<app-autocomplete-many-input
4-
class="inline-input w-full mx-3"
5-
:fetchFn="handleSearchAutocomplete"
6-
v-model="selectedKeywords"
7-
placeholder="Enter keywords, or topics..."
8-
:triggerOnFocus="false"
9-
:inMemoryFilter="false"
10-
@remove-tag="handleRemoveKeyword"
11-
>
12-
</app-autocomplete-many-input>
3+
<div class="flex-grow mx-3">
4+
<app-keywords-input
5+
v-model="selectedKeywords"
6+
placeholder="Enter keywords, or topics..."
7+
/>
8+
</div>
139
<app-eagle-eye-filter />
1410
<el-button
1511
class="btn btn--primary mx-3"
@@ -21,53 +17,48 @@
2117
</template>
2218

2319
<script>
24-
import AppAutocompleteManyInput from '@/shared/form/autocomplete-many-input'
2520
import AppEagleEyeFilter from './eagle-eye-filter'
2621
import { mapGetters, mapActions } from 'vuex'
2722
2823
export default {
2924
name: 'app-eagle-eye-search',
3025
components: {
31-
AppEagleEyeFilter,
32-
AppAutocompleteManyInput
26+
AppEagleEyeFilter
3327
},
3428
computed: {
3529
...mapGetters({
36-
filter: 'eagleEye/filter'
30+
filter: 'eagleEye/filter',
31+
activeTab: 'eagleEye/activeTab'
3732
})
3833
},
3934
data() {
4035
return {
4136
selectedKeywords: []
4237
}
4338
},
39+
watch: {
40+
activeTab: {
41+
handler(newValue, oldValue) {
42+
if (newValue !== oldValue) {
43+
this.selectedKeywords = []
44+
}
45+
}
46+
}
47+
},
4448
methods: {
4549
...mapActions({
4650
doPopulate: 'eagleEye/doPopulate',
4751
doFetch: 'eagleEye/doFetch'
4852
}),
49-
async handleSearchAutocomplete(query) {
50-
return [
51-
{
52-
id: query,
53-
label: query
54-
}
55-
]
56-
},
5753
async doSearch() {
5854
const filtersToApply = {
5955
...this.filter,
60-
keywords: this.selectedKeywords
61-
.map((k) => k.id)
62-
.join(',')
56+
keywords: this.selectedKeywords.join(',')
6357
}
6458
await this.doFetch({
6559
rawFilter: filtersToApply,
6660
filter: filtersToApply
6761
})
68-
},
69-
handleRemoveKeyword() {
70-
this.doSearch()
7162
}
7263
},
7364
async created() {
@@ -76,12 +67,7 @@ export default {
7667
)
7768
this.selectedKeywords =
7869
savedKeywords && savedKeywords !== ''
79-
? savedKeywords.split(',').map((k) => {
80-
return {
81-
id: k,
82-
label: k
83-
}
84-
})
70+
? savedKeywords.split(',')
8571
: []
8672
8773
if (savedKeywords) {
@@ -93,6 +79,6 @@ export default {
9379

9480
<style lang="scss">
9581
.eagle-eye-search {
96-
@apply -mx-2 flex items-center mt-6;
82+
@apply -mx-3 flex items-start mt-6;
9783
}
9884
</style>

frontend/src/premium/eagle-eye/components/eagle-eye-sorter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="eagle-eye-sorter" :style="computedWidth">
2+
<div class="eagle-eye-sorter -mr-3" :style="computedWidth">
33
<el-select
44
:value="value"
55
popper-class="eagle-eye-popper-class"

frontend/src/premium/eagle-eye/eagle-eye-store.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,14 +315,12 @@ export default {
315315
})
316316
},
317317

318-
doChangeActiveTab(
319-
{ commit, dispatch, getters },
320-
activeTab
321-
) {
318+
doChangeActiveTab({ commit, dispatch }, activeTab) {
322319
commit('ACTIVE_TAB_CHANGED', activeTab)
323320
commit('RESETED')
324321
const filtersToApply = {
325-
...getters.filter,
322+
keywords: undefined,
323+
nDays: 1,
326324
status:
327325
activeTab === 'inbox' ? undefined : activeTab
328326
}

frontend/src/shared/form/autocomplete-many-input.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
multiple
1212
:placeholder="placeholder || ''"
1313
remote
14-
reserve-keyword
14+
:reserve-keyword="false"
1515
:allow-create="allowCreate"
1616
value-key="id"
1717
:class="inputClass"

frontend/src/shared/form/autocomplete-one-input.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
filterable
1212
remote
1313
:allow-create="allowCreate"
14-
reserve-keyword
14+
:reserve-keyword="false"
1515
value-key="id"
1616
:class="inputClass"
1717
>

0 commit comments

Comments
 (0)