Skip to content

Commit 099c6a7

Browse files
authored
Merge pull request #1356 from thunderstore-io/02-24-add_and_enable_dependants_and_team_pages
Add and enable dependants and team pages
2 parents 6069b0a + dd87de6 commit 099c6a7

File tree

7 files changed

+276
-50
lines changed

7 files changed

+276
-50
lines changed

apps/cyberstorm-remix/app/p/components/TeamMembers/TeamMembers.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@ export default function TeamMembers(props: {
2121
Team
2222
</Heading>
2323
<NewLink
24-
// TODO: Remove when team page is available
25-
primitiveType="link"
26-
href={`${props.domain}/c/${props.listing.community_identifier}/p/${props.listing.namespace}/`}
27-
// primitiveType="cyberstormLink"
28-
// linkId="Team"
29-
// community={props.listing.community_identifier}
30-
// team={props.listing.team.name}
24+
primitiveType="cyberstormLink"
25+
linkId="Team"
26+
community={props.listing.community_identifier}
27+
team={props.listing.team.name}
3128
csVariant="cyber"
3229
rootClasses="team-members__link"
3330
>
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
.dependants {
2-
display: flex;
3-
flex-direction: column;
1+
@layer nimbus-layout {
2+
.dependants {
3+
display: flex;
4+
flex-direction: column;
45

5-
.dependants__header {
6-
padding: var(--space-40) 0;
7-
color: var(--color-text--default);
8-
font-weight: var(--font-weight-bold);
9-
font-size: 1.75rem;
10-
line-height: var(--line-height-xs);
6+
.dependants__header {
7+
padding: var(--space-40) 0;
8+
color: var(--color-text--default);
9+
font-weight: var(--font-weight-bold);
10+
font-size: 1.75rem;
11+
line-height: var(--line-height-xs);
12+
}
1113
}
12-
}
1314

14-
@media (width <= 48rem) {
15-
.dependants {
16-
gap: var(--space-16);
15+
@media (width <= 48rem) {
16+
.dependants {
17+
gap: var(--space-16);
18+
}
1719
}
1820
}

apps/cyberstorm-remix/app/p/dependants/Dependants.tsx

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
2-
import { useLoaderData } from "@remix-run/react";
2+
import { useLoaderData, useOutletContext } from "@remix-run/react";
33
import {
44
CyberstormLink,
55
NewBreadCrumbs,
@@ -9,6 +9,8 @@ import "./Dependants.css";
99
import { PackageSearch } from "~/commonComponents/PackageSearch/PackageSearch";
1010
import { ApiError } from "@thunderstore/thunderstore-api";
1111
import { DapperTs } from "@thunderstore/dapper-ts";
12+
import { PackageOrderOptions } from "../../commonComponents/PackageSearch/components/PackageOrder";
13+
import { OutletContextShape } from "../../root";
1214

1315
export const meta: MetaFunction<typeof loader> = ({ data }) => {
1416
return [
@@ -27,17 +29,23 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
2729
};
2830
});
2931
const searchParams = new URL(request.url).searchParams;
30-
const order = searchParams.get("order");
32+
const ordering =
33+
searchParams.get("ordering") ?? PackageOrderOptions.Updated;
3134
const page = searchParams.get("page");
3235
const search = searchParams.get("search");
3336
const includedCategories = searchParams.get("includedCategories");
3437
const excludedCategories = searchParams.get("excludedCategories");
3538
const section = searchParams.get("section");
3639
const nsfw = searchParams.get("nsfw");
3740
const deprecated = searchParams.get("deprecated");
41+
const community = await dapper.getCommunity(params.communityId);
42+
const filters = await dapper.getCommunityFilters(params.communityId);
43+
const sortedSections = filters.sections.sort(
44+
(a, b) => b.priority - a.priority
45+
);
3846
return {
39-
community: await dapper.getCommunity(params.communityId),
40-
filters: await dapper.getCommunityFilters(params.communityId),
47+
community: community,
48+
filters: filters,
4149
listing: await dapper.getPackageListingDetails(
4250
params.communityId,
4351
params.namespaceId,
@@ -50,21 +58,27 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
5058
namespaceId: params.namespaceId,
5159
packageName: params.packageId,
5260
},
53-
order ?? "",
61+
ordering ?? "",
5462
page === null ? undefined : Number(page),
5563
search ?? "",
5664
includedCategories?.split(",") ?? undefined,
5765
excludedCategories?.split(",") ?? undefined,
58-
section ?? "",
66+
section
67+
? section === "all"
68+
? ""
69+
: section
70+
: sortedSections && sortedSections[0]
71+
? sortedSections[0].uuid
72+
: "",
5973
nsfw === "true" ? true : false,
6074
deprecated === "true" ? true : false
6175
),
76+
sortedSections: sortedSections,
6277
};
6378
} catch (error) {
6479
if (error instanceof ApiError) {
6580
throw new Response("Package not found", { status: 404 });
6681
} else {
67-
// REMIX TODO: Add sentry
6882
throw error;
6983
}
7084
}
@@ -77,17 +91,23 @@ export async function clientLoader({ request, params }: LoaderFunctionArgs) {
7791
try {
7892
const dapper = window.Dapper;
7993
const searchParams = new URL(request.url).searchParams;
80-
const order = searchParams.get("order");
94+
const ordering =
95+
searchParams.get("ordering") ?? PackageOrderOptions.Updated;
8196
const page = searchParams.get("page");
8297
const search = searchParams.get("search");
8398
const includedCategories = searchParams.get("includedCategories");
8499
const excludedCategories = searchParams.get("excludedCategories");
85100
const section = searchParams.get("section");
86101
const nsfw = searchParams.get("nsfw");
87102
const deprecated = searchParams.get("deprecated");
103+
const community = await dapper.getCommunity(params.communityId);
104+
const filters = await dapper.getCommunityFilters(params.communityId);
105+
const sortedSections = filters.sections.sort(
106+
(a, b) => b.priority - a.priority
107+
);
88108
return {
89-
community: await dapper.getCommunity(params.communityId),
90-
filters: await dapper.getCommunityFilters(params.communityId),
109+
community: community,
110+
filters: filters,
91111
listing: await dapper.getPackageListingDetails(
92112
params.communityId,
93113
params.namespaceId,
@@ -100,32 +120,39 @@ export async function clientLoader({ request, params }: LoaderFunctionArgs) {
100120
namespaceId: params.namespaceId,
101121
packageName: params.packageId,
102122
},
103-
order ?? "",
123+
ordering ?? "",
104124
page === null ? undefined : Number(page),
105125
search ?? "",
106126
includedCategories?.split(",") ?? undefined,
107127
excludedCategories?.split(",") ?? undefined,
108-
section ?? "",
128+
section
129+
? section === "all"
130+
? ""
131+
: section
132+
: sortedSections && sortedSections[0]
133+
? sortedSections[0].uuid
134+
: "",
109135
nsfw === "true" ? true : false,
110136
deprecated === "true" ? true : false
111137
),
138+
sortedSections: sortedSections,
112139
};
113140
} catch (error) {
114141
if (error instanceof ApiError) {
115-
throw new Response("Community not found", { status: 404 });
142+
throw new Response("Package not found", { status: 404 });
116143
} else {
117-
// REMIX TODO: Add sentry
118144
throw error;
119145
}
120146
}
121147
}
122-
throw new Response("Community not found", { status: 404 });
148+
throw new Response("Package not found", { status: 404 });
123149
}
124150

125151
export default function Dependants() {
126-
const { community, filters, listing, listings } = useLoaderData<
127-
typeof loader | typeof clientLoader
128-
>();
152+
const { community, filters, listing, listings, sortedSections } =
153+
useLoaderData<typeof loader | typeof clientLoader>();
154+
155+
const outletContext = useOutletContext() as OutletContextShape;
129156

130157
return (
131158
<div className="container container--y container--full layout__content">
@@ -178,7 +205,9 @@ export default function Dependants() {
178205
<PackageSearch
179206
listings={listings}
180207
packageCategories={filters.package_categories}
181-
sections={filters.sections}
208+
sections={sortedSections}
209+
config={outletContext.requestConfig}
210+
currentUser={outletContext.currentUser}
182211
/>
183212
</section>
184213
</div>

apps/cyberstorm-remix/app/p/packageListing.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,10 @@ export default function PackageListing() {
315315
meta={
316316
<>
317317
<NewLink
318-
// TODO: Remove when team page is available
319-
primitiveType="link"
320-
href={`${domain}/c/${listing.community_identifier}/p/${listing.namespace}/`}
321-
// primitiveType="cyberstormLink"
322-
// linkId="Team"
323-
// community={listing.community_identifier}
324-
// team={listing.namespace}
318+
primitiveType="cyberstormLink"
319+
linkId="Team"
320+
community={listing.community_identifier}
321+
team={listing.namespace}
325322
csVariant="cyber"
326323
rootClasses="page-header__meta-item"
327324
>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@layer nimbus-layout {
2+
.team {
3+
display: flex;
4+
flex-direction: column;
5+
6+
.team__header {
7+
padding: var(--space-40) 0;
8+
color: var(--color-text--default);
9+
font-weight: var(--font-weight-bold);
10+
font-size: 1.75rem;
11+
line-height: var(--line-height-xs);
12+
}
13+
}
14+
15+
@media (width <= 48rem) {
16+
.team {
17+
gap: var(--space-16);
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)