Skip to content

Commit 097b545

Browse files
committed
fix: hide functions in containers view (#2597)
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->
1 parent 258dd58 commit 097b545

4 files changed

Lines changed: 31 additions & 18 deletions

File tree

frontend/apps/hub/src/domains/project/components/actors/actors-provider.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
createActorAtom,
1414
type Logs,
1515
actorsQueryAtom,
16+
actorsInternalFilterAtom,
17+
type Actor,
1618
} from "@rivet-gg/components/actors";
1719
import {
1820
InfiniteQueryObserver,
@@ -40,6 +42,7 @@ interface ActorsProviderProps {
4042
children?: ReactNode;
4143
fixedTags?: Record<string, string>;
4244
filter?: (actor: Rivet.actors.Actor) => boolean;
45+
isActorInternal?: (actor: Actor) => boolean;
4346

4447
/// filters
4548
tags: FilterValue;
@@ -57,6 +60,7 @@ export function ActorsProvider({
5760
children,
5861
fixedTags,
5962
filter,
63+
isActorInternal: internalFilter,
6064
// filters
6165
tags,
6266
region,
@@ -84,6 +88,13 @@ export function ActorsProvider({
8488
});
8589
}, [tags, region, createdAt, destroyedAt, status, devMode]);
8690

91+
// biome-ignore lint/correctness/useExhaustiveDependencies: store is not a dependency
92+
useEffect(() => {
93+
if (internalFilter) {
94+
store.set(actorsInternalFilterAtom, internalFilter);
95+
}
96+
}, [internalFilter]);
97+
8798
// biome-ignore lint/correctness/useExhaustiveDependencies: store is not a dependency
8899
useEffect(() => {
89100
return store.sub(actorFiltersAtom, () => {

frontend/apps/hub/src/routes/_authenticated/_layout/projects/$projectNameId/environments/$environmentNameId._v2/containers.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
type Actor as StateActor,
23
ActorFeature,
34
ActorNotFound,
45
ActorsActorDetails,
@@ -64,7 +65,6 @@ const FIXED_TAGS = {};
6465
// toRecord(actor.tags).framework !== "actor-core";
6566

6667
const ACTORS_FILTER = (actor: Rivet.actors.Actor) =>
67-
toRecord(actor.tags).type !== "function" &&
6868
toRecord(actor.tags).framework !== "actor-core";
6969

7070
const ACTORS_VIEW_CONTEXT = {
@@ -107,6 +107,9 @@ const ACTORS_VIEW_CONTEXT = {
107107
canCreate: false,
108108
};
109109

110+
const IS_ACTOR_INTERNAL = (actor: StateActor) =>
111+
toRecord(actor.tags).type === "function";
112+
110113
function Content() {
111114
const { nameId: projectNameId } = useProject();
112115
const { nameId: environmentNameId } = useEnvironment();
@@ -137,6 +140,7 @@ function Content() {
137140
actorId={actorId}
138141
fixedTags={FIXED_TAGS}
139142
filter={ACTORS_FILTER}
143+
isActorInternal={IS_ACTOR_INTERNAL}
140144
{...filters}
141145
>
142146
<ActorsListPreview>

frontend/apps/hub/src/routes/_authenticated/_layout/projects/$projectNameId/environments/$environmentNameId._v2/functions.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
TableBody,
2727
TableCell,
2828
DiscreteCopyButton,
29-
toRecord,
3029
DropdownMenu,
3130
DropdownMenuTrigger,
3231
DropdownMenuContent,
@@ -102,8 +101,8 @@ function ProjectFunctionsRoute() {
102101
<Table>
103102
<TableHeader>
104103
<TableRow>
104+
<TableHead>Name</TableHead>
105105
<TableHead>Route</TableHead>
106-
<TableHead>Instances</TableHead>
107106
<TableHead />
108107
</TableRow>
109108
</TableHeader>
@@ -121,24 +120,17 @@ function ProjectFunctionsRoute() {
121120
<TableRow key={route.id}>
122121
<TableCell>
123122
<DiscreteCopyButton
124-
value={`${route.hostname}${route.path}${route.routeSubpaths ? "/*" : ""}`}
123+
value={route.id}
125124
>
126-
{`${route.hostname}${route.path}${route.routeSubpaths ? "/*" : ""}`}
125+
{route.id}
127126
</DiscreteCopyButton>
128127
</TableCell>
129128
<TableCell>
130-
{actors?.filter((actor) =>
131-
Object.entries(
132-
route.target.actors
133-
?.selectorTags || {},
134-
).some(([key, value]) => {
135-
return (
136-
toRecord(actor.tags)[
137-
key
138-
] === value
139-
);
140-
}),
141-
).length || 0}
129+
<DiscreteCopyButton
130+
value={`${route.hostname}${route.path}${route.routeSubpaths ? "/*" : ""}`}
131+
>
132+
{`${route.hostname}${route.path}${route.routeSubpaths ? "/*" : ""}`}
133+
</DiscreteCopyButton>
142134
</TableCell>
143135
<TableCell>
144136
<DropdownMenu>

frontend/packages/components/src/actors/actor-context.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ export const actorRegionsAtom = atom<Region[]>([
112112

113113
export const actorBuildsAtom = atom<Build[]>([]);
114114

115+
export const actorsInternalFilterAtom = atom<(actor: Actor) => boolean>();
116+
115117
// derived atoms
116118

117119
export const currentActorRegionAtom = atom((get) => {
@@ -127,6 +129,8 @@ export const filteredActorsAtom = atom((get) => {
127129
const filters = get(actorFiltersAtom);
128130
const actors = get(actorsAtom);
129131

132+
const isActorInternal = get(actorsInternalFilterAtom);
133+
130134
return actors.filter((actor) => {
131135
const satisfiesFilters = Object.entries(filters).every(
132136
([key, filter]) => {
@@ -232,7 +236,9 @@ export const filteredActorsAtom = atom((get) => {
232236
},
233237
);
234238

235-
const isInternal = toRecord(actor.tags).owner === "rivet";
239+
const isInternal =
240+
toRecord(actor.tags).owner === "rivet" ||
241+
(isActorInternal?.(actor) ?? false);
236242

237243
return (
238244
satisfiesFilters && ((isInternal && filters.devMode) || !isInternal)

0 commit comments

Comments
 (0)