Skip to content

Commit

Permalink
PB-34272 WP1.7 - Search resource in webapp using v5
Browse files Browse the repository at this point in the history
  • Loading branch information
Benj1er committed Aug 8, 2024
1 parent 67b2841 commit 0ba2636
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 228 deletions.
5 changes: 3 additions & 2 deletions src/react-extension/contexts/ResourceWorkspaceContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,9 @@ export class ResourceWorkspaceContextProvider extends React.Component {
return foldersMatchCache[key];
};
const matchTagProperty = (word, resource) => resource.tags?.some(tag => matchWord(word, tag.slug));
const matchStringProperty = (word, resource) => ['name', 'username', 'uri', 'description'].some(key => matchWord(word, resource[key]));
const matchResource = (word, resource) => matchStringProperty(word, resource) || (canUseTags && matchTagProperty(word, resource)) || (resource?.folder_parent_id && matchFolderCache(word, resource.folder_parent_id));
const matchUrisProperty = (word, resource) => resource.metadata?.uris?.some(uri => matchWord(word, uri));
const matchStringProperty = (word, resource) => ['name', 'username', 'description'].some(key => matchWord(word, resource.metadata?.[key]));
const matchResource = (word, resource) => matchStringProperty(word, resource) || matchUrisProperty(word, resource) || (canUseTags && matchTagProperty(word, resource)) || (resource?.folder_parent_id && matchFolderCache(word, resource.folder_parent_id));
const matchText = resource => words.every(word => matchResource(word, resource));

const filteredResources = this.resources.filter(matchText);
Expand Down
Loading

0 comments on commit 0ba2636

Please sign in to comment.