Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chatpal: limit results to current room #17718

Merged
merged 5 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/chatpal-search/client/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
.chatpal-search-typefilter li {

display: flex;
flex: 0 0 50%;
flex: 0 0 33%;

height: 35px;
padding-top: 10px;
Expand Down
5 changes: 3 additions & 2 deletions app/chatpal-search/client/template/result.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<div class="chatpal-search-container">
<ul class="chatpal-search-typefilter">
<li value="All" class="{{navSelected 'All'}}">{{_ "Chatpal_All_Results"}}</li>
<li value="Room" class="{{navSelected 'Room'}}">{{_ "Chatpal_Current_Room_Only"}}</li>
<li value="Messages" class="{{navSelected 'Messages'}}">{{_ "Chatpal_Messages_Only"}}</li>
</ul>
<div class="chatpal-search-result">
Expand Down Expand Up @@ -59,7 +60,7 @@ <h2>{{_ "Chatpal_No_Results"}}</h2>
</div>
{{/if}}
{{/if}}
{{#if $eq resultType "Messages"}}
{{#if resultMessagesOnly}}
<div class="chatpal-search-result-header">
<h2 class="chatpal-search-number">
{{#if resultNumFound}}
Expand Down Expand Up @@ -110,7 +111,7 @@ <h2>
</h2>
<div class="chatpal-avatar">
<div class="chatpal-avatar-image"
style="background-image:url({{getAvatarUrl cleanUsername }});"></div>
style="background-image:url({{getAvatarUrl username }});"></div>
</div>
<span class="chatpal-name">{{username}}</span>
<span class="chatpal-time">{{time}}</span>
Expand Down
9 changes: 7 additions & 2 deletions app/chatpal-search/client/template/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import { DateFormat } from '../../../lib';
import { roomTypes, getURL } from '../../../utils';
import { Subscriptions } from '../../../models';
import { getUserAvatarURL as getAvatarUrl } from '../../../utils/lib/getUserAvatarURL';

const getAvatarUrl = (username) => getURL(`/avatar/${ username }?_dc=undefined`);
const getDMUrl = (username) => getURL(`/direct/${ username }`);

Template.ChatpalSearchResultTemplate.onCreated(function() {
Expand Down Expand Up @@ -78,6 +78,10 @@ Template.ChatpalSearchResultTemplate.helpers({
}
}
},
resultMessagesOnly() {
return Template.instance().resultType.get() === 'Messages'
|| Template.instance().resultType.get() === 'Room';
},
resultPaging() {
const result = Template.instance().data.result.get();
const pageSize = Template.instance().data.settings.PageSize;
Expand Down Expand Up @@ -134,7 +138,8 @@ Template.ChatpalSearchSingleRoom.helpers({

Template.ChatpalSearchSingleUser.helpers({
cleanUsername() {
return this.user_username.replace(/<\/?em>/ig, '');
const username = this.user_username || this.username; // varies whether users or messages of users are displayed
return username.replace(/<\/?em>/ig, '');
},
getAvatarUrl,
getDMUrl,
Expand Down
7 changes: 4 additions & 3 deletions app/chatpal-search/server/provider/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ class ChatpalProvider extends SearchProvider {
});
this._settings.add('DefaultResultType', 'select', 'All', {
values: [
{ key: 'All', i18nLabel: 'All' },
{ key: 'Messages', i18nLabel: 'Messages' },
{ key: 'All', i18nLabel: 'Chatpal_All_Results' },
{ key: 'Room', i18nLabel: 'Chatpal_Current_Room_Only' },
{ key: 'Messages', i18nLabel: 'Chatpal_Messages_Only' },
],
i18nLabel: 'Chatpal_Default_Result_Type',
i18nDescription: 'Chatpal_Default_Result_Type_Description',
Expand Down Expand Up @@ -313,7 +314,7 @@ class ChatpalProvider extends SearchProvider {
this.index.query(
text,
this._settings.get('Main_Language'),
this._getAcl(context),
payload.resultType === 'Room' ? [context.rid] : this._getAcl(context),
type,
payload.start || 0,
payload.rows || this._settings.get('PageSize'),
Expand Down
2 changes: 1 addition & 1 deletion app/search/client/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

.rocket-search-result {
display: flex;
overflow: hidden;
overflow-x: hidden;
flex-direction: column;
flex: 1 1 0;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-i18n/i18n/de.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@
"Chatops_Title": "ChatOps-Panel",
"Chatops_Username": "ChatOps-Benutzername",
"Chatpal_AdminPage": "Chatpal Adminseite",
"Chatpal_All_Results": "Alle",
"Chatpal_All_Results": "Alles",
"Chatpal_API_Key": "API Key",
"Chatpal_API_Key_Description": "Sie haben noch keinen <strong>API Key</strong>? <a class=\"chatpal-admin-link\" href=\"./admin/chatpal\">Hier gehts zum Key!</a>",
"Chatpal_Backend": "Backend Typ",
Expand All @@ -590,6 +590,7 @@
"Chatpal_Batch_Size_Description": "Anzahl der Indexdokumente pro Batch (beim Bootstrapping)",
"Chatpal_create_key": "Api Key erzeugen",
"Chatpal_created_key_successfully": "API-Key erfolgreich erstellt",
"Chatpal_Current_Room_Only": "Selber Raum",
"Chatpal_Default_Result_Type": "Vordefinierter Resultattyp",
"Chatpal_Default_Result_Type_Description": "Wählen Sie, welche Art von Resultaten standardmäßig angezeigt werden soll. Alles was das bedeutet, ist dass eine Übersicht für alle Typen zur Verfügung steht.",
"Chatpal_Email_Address": "E-Mail Adresse",
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@
"Chatops_Title": "Chatops Panel",
"Chatops_Username": "Chatops Username",
"Chatpal_AdminPage": "Chatpal Admin Page",
"Chatpal_All_Results": "All",
"Chatpal_All_Results": "Everything",
"Chatpal_API_Key": "API Key",
"Chatpal_API_Key_Description": "You don't yet have an <strong>API Key</strong>? <a class=\"chatpal-admin-link\" href=\"./admin/chatpal\">Get one!</a>",
"Chatpal_Backend": "Backend Type",
Expand All @@ -632,6 +632,7 @@
"Chatpal_Batch_Size_Description": "The batch size of index documents (on bootstrapping)",
"Chatpal_create_key": "Create Key",
"Chatpal_created_key_successfully": "API-Key created successfully",
"Chatpal_Current_Room_Only": "Same room",
"Chatpal_Default_Result_Type": "Default Result Type",
"Chatpal_Default_Result_Type_Description": "Defines which result type is shown by result. All means that an overview for all types is provided.",
"Chatpal_Email_Address": "Email Address",
Expand Down