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

SWC-6740, SWC-6741, SWC-6743 - Add "No results found" image #5595

Merged
merged 3 commits into from
Dec 2, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public void loadMore() {
>() {
@Override
public void onSuccess(UserGroupHeaderResponsePage result) {
boolean hasNoResults = offset == 0 && result.getChildren().isEmpty();
view.setShowNoResults(hasNoResults);

for (UserGroupHeader header : result.getChildren()) {
if (header.getIsIndividual()) {
UserBadge badge = ginInjector.getUserBadgeWidget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public void loadMore() {
>() {
@Override
public void onSuccess(PaginatedResults<Team> result) {
boolean hasNoResults = offset == 0 && result.getResults().isEmpty();
view.setShowNoResults(hasNoResults);

for (Team team : result.getResults()) {
BigTeamBadge teamBadge = ginInjector.getBigTeamBadgeWidget();
teamBadge.configure(team, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ public interface Presenter {
public void setSynAlertWidget(Widget asWidget);

public void setSynAlertWidgetVisible(boolean b);

public void setShowNoResults(boolean show);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
Expand Down Expand Up @@ -39,6 +40,9 @@ public interface PeopleSearchViewImplUiBinder
@UiField
TextBox searchField;

@UiField
HTMLPanel noSearchResultsContainer;

private Header headerWidget;
private Presenter presenter;

Expand Down Expand Up @@ -103,4 +107,9 @@ public void setSynAlertWidget(Widget synAlert) {
public void setSynAlertWidgetVisible(boolean isVisible) {
synAlertPanel.setVisible(isVisible);
}

@Override
public void setShowNoResults(boolean show) {
noSearchResultsContainer.setVisible(show);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ public Widget getResults(
searchResultsPanel =
new HTMLPanel(
new SafeHtmlBuilder()
.appendHtmlConstant(
"<img src=\"https://s3.us-east-1.amazonaws.com/static.synapse.org/images/NoSearchResults.svg\" width=\"300px\" />"
)
.appendHtmlConstant(
"<h4>" + DisplayConstants.LABEL_NO_SEARCH_RESULTS_PART1
)
Expand All @@ -211,6 +214,7 @@ public Widget getResults(
)
.toSafeHtml()
);
searchResultsPanel.addStyleName("text-align-center");
facetPanel.clear();
} else {
searchResultsPanel = new SimplePanel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ public interface Presenter {
public void setSynAlertWidget(Widget asWidget);

void setLoadMoreContainer(Widget w);

public void setShowNoResults(boolean show);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
Expand Down Expand Up @@ -39,6 +40,9 @@ public interface TeamSearchViewImplUiBinder
@UiField
SimplePanel synAlertPanel;

@UiField
HTMLPanel noSearchResultsContainer;

private Header headerWidget;
private Presenter presenter;
private SynapseJSNIUtils synapseJsniUtils;
Expand Down Expand Up @@ -105,4 +109,9 @@ public void onKeyDown(KeyDownEvent event) {
public void setSynAlertWidget(Widget synAlert) {
synAlertPanel.setWidget(synAlert);
}

@Override
public void setShowNoResults(boolean show) {
noSearchResultsContainer.setVisible(show);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@
visible="false"
/>
</bh:Div>
<g:HTMLPanel
ui:field="noSearchResultsContainer"
visible="false"
addStyleNames="margin-top-40 text-align-center"
>
<img
src="https://s3.us-east-1.amazonaws.com/static.synapse.org/images/NoSearchResults.svg"
width="300px"
/>
<bh:Paragraph addStyleNames="margin-top-15" text="No people found." />
</g:HTMLPanel>
<bh:Div>
<g:SimplePanel
ui:field="peopleListPanel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@
</bh:Div>
</bh:Div>
<g:SimplePanel ui:field="synAlertPanel" />
<g:HTMLPanel
ui:field="noSearchResultsContainer"
visible="false"
addStyleNames="margin-top-40 text-align-center"
>
<img
src="https://s3.us-east-1.amazonaws.com/static.synapse.org/images/NoSearchResults.svg"
width="300px"
/>
<bh:Paragraph addStyleNames="margin-top-15" text="No teams found." />
</g:HTMLPanel>
<g:FlowPanel ui:field="mainContainer" addStyleNames="margin-top-10" />
<g:SimplePanel ui:field="paginationPanel" />
</bh:Div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Widget;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -109,6 +110,57 @@ public void testSearch() throws RestServiceException {
verify(mockView).setSearchTerm(searchTerm);
verify(mockPortalGinInjector, times(3)).getUserBadgeWidget();
verify(mockLoadMoreWidgetContainer, times(3)).add(any());
verify(mockView).setShowNoResults(false);

// Call loadMore with no results in the 2nd page
AsyncMockStubber
.callSuccessWith(
new UserGroupHeaderResponsePage().setChildren(Collections.emptyList())
)
.when(mockSynapseJavascriptClient)
.getUserGroupHeadersByPrefix(
anyString(),
any(TypeFilter.class),
anyLong(),
anyLong(),
any(AsyncCallback.class)
);

presenter.loadMore();

verify(mockView, never()).setShowNoResults(true);
}

@Test
public void testEmptySearch() throws RestServiceException {
AsyncMockStubber
.callSuccessWith(
new UserGroupHeaderResponsePage().setChildren(Collections.emptyList())
)
.when(mockSynapseJavascriptClient)
.getUserGroupHeadersByPrefix(
anyString(),
any(TypeFilter.class),
anyLong(),
anyLong(),
any(AsyncCallback.class)
);

String searchTerm = "test";
when(mockPlace.getSearchTerm()).thenReturn(searchTerm);
presenter.setPlace(mockPlace);
verify(mockSynapseJavascriptClient)
.getUserGroupHeadersByPrefix(
eq(searchTerm),
eq(TypeFilter.USERS_ONLY),
anyLong(),
anyLong(),
any(AsyncCallback.class)
);
verify(mockView).setSearchTerm(searchTerm);
verify(mockPortalGinInjector, never()).getUserBadgeWidget();
verify(mockLoadMoreWidgetContainer, never()).add(any());
verify(mockView).setShowNoResults(true);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -139,6 +141,7 @@ public void testSearch() throws RestServiceException {
// add both test teams
verify(mockPortalGinInjector, times(2)).getBigTeamBadgeWidget();
verify(mockLoadMoreWidgetContainer, times(2)).add(any());
verify(mockView).setShowNoResults(false);
}

@Test
Expand All @@ -155,6 +158,7 @@ public void testSearchFailure() throws RestServiceException {
);
presenter.setPlace(mockPlace);
verify(mockSynAlert).handleException(caught);
verify(mockView, never()).setShowNoResults(anyBoolean());
}

@Test
Expand Down Expand Up @@ -192,6 +196,8 @@ public void testEmptyTeams() {
anyInt(),
any(AsyncCallback.class)
);

verify(mockView).setShowNoResults(true);
}

@Test
Expand Down
Loading