Skip to content

Commit

Permalink
fix: owned services filter not working
Browse files Browse the repository at this point in the history
  • Loading branch information
prosfus committed Jan 3, 2025
1 parent 5564148 commit dc6c649
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/pages/ui/minio/components/AddBucketButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function AddBucketButton() {
<PopoverContent className="w-80">
<div className="grid gap-4">
<div className="space-y-2">
<h4 className="font-medium leading-none">Create MinIO Bucket</h4>
<h4 className="font-medium leading-none">Create bucket</h4>
</div>
<div className="grid gap-2">
<Label htmlFor="bucketName">Bucket Name</Label>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AuthData } from "@/contexts/AuthContext";
import {
Service,
ServiceFilter,
Expand All @@ -7,12 +8,25 @@ import {
interface Props {
services: Service[];
filter: ServiceFilter;
user: string;
authData: AuthData;
}

function handleFilterServices({ services, filter, user }: Props) {
function handleFilterServices({ services, filter, authData }: Props) {
return services.filter((service) => {
if (filter.onlyOwned && service.owner !== user) return false;
if (filter.onlyOwned) {
const token = authData.token;

if (!token) {
return (
service.allowed_users.includes(authData.user) ||
service.owner === authData.user
);
}

if (token && !service.allowed_users.includes(token)) {
return false;
}
}

const param = service[ServiceFilterByKey[filter.type]] as string;

Expand Down
2 changes: 1 addition & 1 deletion src/pages/ui/services/components/ServicesList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function ServicesList() {
const filteredServices = handleFilterServices({
filter,
services,
user: authData.user,
authData,
});
return filteredServices;
}, [services, filter, authData?.user]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ function ServicesFilterBy() {
}}
style={{ fontSize: 16 }}
/>
<label htmlFor="ownedItems" style={{ fontSize: 14 }}>
Only owned services
<label
htmlFor="ownedItems"
style={{ fontSize: 14, marginTop: "1px" }}
>
My services
</label>
</div>
</SelectContent>
Expand Down

0 comments on commit dc6c649

Please sign in to comment.