Skip to content

Commit

Permalink
Add beta store search heading (#1673)
Browse files Browse the repository at this point in the history
  • Loading branch information
steverydz authored Sep 28, 2023
1 parent 0b30aca commit 9a8378f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ canonicalwebteam.discourse==5.4.2
canonicalwebteam.image-template==1.3.1
canonicalwebteam.store-api==4.4.0
canonicalwebteam.docstring-extractor==1.2.0
canonicalwebteam.store-base==0.0.7
canonicalwebteam.store-base==0.1.1
Flask-WTF==1.0.1
humanize==4.4.0
mistune==2.0.4
Expand Down
22 changes: 21 additions & 1 deletion static/js/beta-store/components/Packages/Packages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function Packages() {
});

return {
total_items: data.total_items,
total_pages: data.total_pages,
packages: packagesWithId,
categories: data.categories,
Expand Down Expand Up @@ -176,6 +177,25 @@ function Packages() {
</Col>
<Col size={9}>
<Topics topicsQuery={topicsQuery} />
{data?.packages &&
data.packages.length > 0 &&
searchParams.get("q") && (
<div className="u-fixed-width">
<p>
{data?.packages.length} of {data?.total_items} results for{" "}
<strong>"{searchParams.get("q")}"</strong>.{" "}
<Button
appearance="link"
onClick={() => {
searchParams.delete("q");
setSearchParams(searchParams);
}}
>
Clear search
</Button>
</p>
</div>
)}
<Row>
{isFetching &&
[...Array(ITEMS_PER_PAGE)].map((item, index) => (
Expand Down Expand Up @@ -209,7 +229,7 @@ function Packages() {
{status === "success" && data.packages.length > 0 && (
<Pagination
itemsPerPage={ITEMS_PER_PAGE}
totalItems={ITEMS_PER_PAGE * data.total_pages}
totalItems={data.total_items}
paginate={(pageNumber) => {
setCurrentPage(pageNumber.toString());
setSearchParams({
Expand Down
14 changes: 9 additions & 5 deletions webapp_beta/beta_app.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
import talisker.requests
from canonicalwebteam.store_base.app import create_app
from canonicalwebteam.store_api.stores.charmstore import CharmStore, CharmPublisher
from canonicalwebteam.store_api.stores.charmstore import (
CharmStore,
CharmPublisher,
)
from canonicalwebteam.candid import CandidClient

from webapp_beta.charmhub_bp import charmhub_bp
from webapp.handlers import charmhub_utility_processor
from webapp.decorators import login_required

# beta charmhub configiuration
app = create_app(
"charmhub_beta",
login_required,
store_bp=charmhub_bp,
utility_processor=charmhub_utility_processor,
)

app.name = "charmhub_beta"
app.static_folder=charmhub_bp.static_folder
app.template_folder=charmhub_bp.template_folder
app.static_url_path=charmhub_bp.static_url_path
app.static_folder = charmhub_bp.static_folder
app.template_folder = charmhub_bp.template_folder
app.static_url_path = charmhub_bp.static_url_path
app.store_api = CharmStore(session=talisker.requests.get_session())



request_session = talisker.requests.get_session()
candid = CandidClient(request_session)
publisher_api = CharmPublisher(request_session)

0 comments on commit 9a8378f

Please sign in to comment.