Skip to content

Commit a8a6d21

Browse files
author
Charlie Egan
authored
docs: Allow searching of ecosystem page (#7574)
* docs: Allow searching of ecosystem page At the moment, showing the long list is not ideal without categorizing the items. However, search helps a little as well as the existing categorization earlier in the page. This PR also adds a small note to show how the page is ordered. Signed-off-by: Charlie Egan <charlie@styra.com> * docs: No results text for ecosystem search Links to slack to in case the user is confused. Signed-off-by: Charlie Egan <charlie@styra.com> --------- Signed-off-by: Charlie Egan <charlie@styra.com>
1 parent e43ef0a commit a8a6d21

1 file changed

Lines changed: 59 additions & 19 deletions

File tree

docs/new/src/pages/ecosystem/index.js

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Heading from "@theme/Heading";
22
import Layout from "@theme/Layout";
3-
import React from "react";
3+
import React, { useState } from "react";
44

55
import Card from "../../components/Card";
66
import getLogoAsset from "../../lib/ecosystem/getLogoAsset.js";
@@ -12,8 +12,20 @@ import features from "@generated/ecosystem-data/default/features.json";
1212
import languages from "@generated/ecosystem-data/default/languages.json";
1313

1414
const EcosystemIndex = (props) => {
15-
const sortedPages = sortPagesByRank(entries);
1615
const title = "OPA Ecosystem";
16+
const sortedPages = sortPagesByRank(entries);
17+
18+
const [searchQuery, setSearchQuery] = useState("");
19+
20+
const filteredPages = sortedPages.filter((id) => {
21+
const page = entries[id];
22+
const query = searchQuery.toLowerCase();
23+
return (
24+
page.title.toLowerCase().includes(query)
25+
|| page.subtitle?.toLowerCase().includes(query)
26+
|| page.content.toLowerCase().includes(query)
27+
);
28+
});
1729

1830
const orderedCategoryKeys = ["rego", "production", "tool", "createwithopa"];
1931
const preferredLanguageOrder = [
@@ -139,6 +151,24 @@ const EcosystemIndex = (props) => {
139151
All Entries & Integrations
140152
</Heading>
141153

154+
<div style={{ margin: "1.5rem 0" }}>
155+
<input
156+
type="text"
157+
placeholder="Search entries..."
158+
value={searchQuery}
159+
onChange={(e) => setSearchQuery(e.target.value)}
160+
style={{
161+
padding: "0.5rem",
162+
width: "100%",
163+
maxWidth: "40rem",
164+
fontSize: "1rem",
165+
}}
166+
/>
167+
<p style={{ fontSize: "0.8rem", marginTop: "0.5rem" }}>
168+
All integrations are ordered by the number of linked resources.
169+
</p>
170+
</div>
171+
142172
<div
143173
style={{
144174
marginTop: "2rem",
@@ -148,23 +178,33 @@ const EcosystemIndex = (props) => {
148178
gap: 20,
149179
}}
150180
>
151-
{sortedPages.map((id) => {
152-
const page = entries[id];
153-
154-
const cardData = {
155-
title: page.title,
156-
note: page.subtitle,
157-
icon: getLogoAsset(page.id),
158-
link: `/ecosystem/entry/${id}`,
159-
link_text: "View Details",
160-
};
161-
162-
return (
163-
<div key={id} style={{ flex: "1 1 30%", minWidth: "250px", maxWidth: "400px" }}>
164-
<Card item={cardData} />
165-
</div>
166-
);
167-
})}
181+
{filteredPages.length === 0
182+
? (
183+
<p style={{ textAlign: "center", width: "100%" }}>
184+
No integrations found. Try searching for something else or drop us a message on{" "}
185+
<a href="https://slack.openpolicyagent.org/" target="_blank" rel="noopener noreferrer">
186+
Slack
187+
</a>.
188+
</p>
189+
)
190+
: (
191+
filteredPages.map((id) => {
192+
const page = entries[id];
193+
const cardData = {
194+
title: page.title,
195+
note: page.subtitle,
196+
icon: getLogoAsset(page.id),
197+
link: `/ecosystem/entry/${id}`,
198+
link_text: "View Details",
199+
};
200+
201+
return (
202+
<div key={id} style={{ flex: "1 1 30%", minWidth: "250px", maxWidth: "400px" }}>
203+
<Card item={cardData} />
204+
</div>
205+
);
206+
})
207+
)}
168208
</div>
169209
</div>
170210
</Layout>

0 commit comments

Comments
 (0)