Skip to content

Commit

Permalink
Merge pull request #10363 from sudhanshutech/fix/patterns
Browse files Browse the repository at this point in the history
[bug] Fix patterns filtering
  • Loading branch information
leecalcote committed Feb 26, 2024
2 parents 801ce98 + 76ff513 commit b989872
Showing 1 changed file with 30 additions and 23 deletions.
53 changes: 30 additions & 23 deletions ui/components/MesheryPatterns.js
Expand Up @@ -56,7 +56,7 @@ import CloneIcon from '../public/static/img/CloneIcon';
import { useRouter } from 'next/router';
import Modal from './Modal';
import downloadContent from '../utils/fileDownloader';
import fetchCatalogPattern from './graphql/queries/CatalogPatternQuery';
// import fetchCatalogPattern from './graphql/queries/CatalogPatternQuery';
import ConfigurationSubscription from './graphql/subscriptions/ConfigurationSubscription';
import ReusableTooltip from './reusable-tooltip';
import Pattern from '../public/static/img/drawer-icons/pattern_svg.js';
Expand Down Expand Up @@ -634,30 +634,37 @@ function MesheryPatterns({
},
);
catalogVisibilityRef.current = catalogVisibility;
const fetchCatalogPatterns = fetchCatalogPattern({
selector: {
search: '',
order: '',
page: 0,
pagesize: 0,
},
}).subscribe({
next: (result) => {
catalogContentRef.current = result?.catalogPatterns;
initPatternsSubscription();
},
error: (err) => console.log('There was an error fetching Catalog Filter: ', err),
});

return () => {
fetchCatalogPatterns.unsubscribe();
disposeConfSubscriptionRef.current?.dispose();
};
/*
Below is a graphql query that fetches the catalog patterns that is published so
when catalogVisibility is true, we fetch the catalog patterns and set it to the patterns state
which show the catalog patterns only in the UI at the top of the list always whether we filter for public or private patterns.
Meshery's REST API already fetches catalog items with `published` visibility, hence this function is commented out.
*/
// const fetchCatalogPatterns = fetchCatalogPattern({
// selector: {
// search: '',
// order: '',
// page: 0,
// pagesize: 0,
// },
// }).subscribe({
// next: (result) => {
// catalogContentRef.current = result?.catalogPatterns;
// initPatternsSubscription();
// },
// error: (err) => console.log('There was an error fetching Catalog Filter: ', err),
// });

// return () => {
// fetchCatalogPatterns.unsubscribe();
// disposeConfSubscriptionRef.current?.dispose();
// };
}, []);

useEffect(() => {
handleSetPatterns(patterns);
}, [catalogVisibility]);
// useEffect(() => {
// handleSetPatterns(patterns);
// }, [catalogVisibility]);

const handleSetPatterns = (patterns) => {
console.log('Patterns', patterns);
Expand Down Expand Up @@ -964,7 +971,7 @@ function MesheryPatterns({
setCount(result.total_count || 0);
handleSetPatterns(filteredPatterns);
setVisibilityFilter(visibilityFilter);
// setPatterns(result.patterns || []);
setPatterns(result.patterns || []);
}
},
handleError(ACTION_TYPES.FETCH_PATTERNS),
Expand Down

0 comments on commit b989872

Please sign in to comment.