Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: search results for sandbox #8648

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ const useSearchedSandboxes = (query: string) => {
};

const calculateSearchIndex = (dashboard: any, activeTeam: string) => {
const sandboxes = dashboard.sandboxes.SEARCH;
if (sandboxes == null) {
return null;
}
const sandboxes = dashboard.sandboxes.SEARCH || [];

const folders: Collection[] = (dashboard.allCollections || [])
.map(collection => ({
...collection,
Expand All @@ -60,7 +58,7 @@ const calculateSearchIndex = (dashboard: any, activeTeam: string) => {
.filter(f => f.title);

const teamRepos = dashboard.repositoriesByTeamId[activeTeam] ?? [];
const repositories = teamRepos.map((repo: Repository) => {
const repositories = (teamRepos || []).map((repo: Repository) => {
return {
title: repo.repository.name,
/**
Expand All @@ -72,7 +70,7 @@ const calculateSearchIndex = (dashboard: any, activeTeam: string) => {
};
});

return new Fuse([...sandboxes, ...folders, ...(repositories || [])], {
return new Fuse([...sandboxes, ...folders, ...repositories], {
threshold: 0.1,
distance: 1000,
keys: [
Expand Down Expand Up @@ -122,7 +120,10 @@ export const useGetItems = ({
const sandbox = item as SandboxFragmentDashboardFragment;

// Remove draft sandboxes from other authors
return sandbox.draft && sandbox.author.username === username;
return (
!sandbox.draft ||
(sandbox.draft && sandbox.author.username === username)
);
}
);

Expand Down
Loading