Skip to content

Commit

Permalink
Merge branch 'alpha' into 2495
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza authored Sep 26, 2024
2 parents f7fe82b + fcfc757 commit 3d87049
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 23 deletions.
7 changes: 7 additions & 0 deletions changelogs/CHANGELOG_alpha.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [6.0.0-alpha.13](https://github.com/ParsePlatform/parse-dashboard/compare/6.0.0-alpha.12...6.0.0-alpha.13) (2024-09-25)


### Bug Fixes

* Internal classes `_User`, `_Role`, `_Installation` referenced with pointer don't appear in data browser filter dialog ([#2599](https://github.com/ParsePlatform/parse-dashboard/issues/2599)) ([8239cc8](https://github.com/ParsePlatform/parse-dashboard/commit/8239cc8a05865c5f0b4f5b33dfb224e87d25a319))

# [6.0.0-alpha.12](https://github.com/ParsePlatform/parse-dashboard/compare/6.0.0-alpha.11...6.0.0-alpha.12) (2024-08-07)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parse-dashboard",
"version": "6.0.0-alpha.12",
"version": "6.0.0-alpha.13",
"repository": {
"type": "git",
"url": "https://github.com/ParsePlatform/parse-dashboard"
Expand Down
31 changes: 21 additions & 10 deletions src/lib/Filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export function availableFilters(schema, currentFilters, blacklist) {
return available;
}

export function findRelatedClasses(referClass , allClasses, blacklist, currentFilters) {
export function findRelatedClasses(referClass, allClasses, blacklist, currentFilters) {
const relatedClasses = {};
if (allClasses[referClass]) {
const availableForRefer = availableFilters(allClasses[referClass], currentFilters, blacklist);
Expand All @@ -243,31 +243,42 @@ export function findRelatedClasses(referClass , allClasses, blacklist, currentFi
}

for (const className in allClasses) {
if (className === referClass){
if (className === referClass) {
continue;
}

if (!checkRelation(referClass, allClasses[className])) {
if (!checkRelation(referClass, allClasses, className)) {
continue;
}

const schema = allClasses[className];
const available = availableFilters(schema, currentFilters, blacklist);
if (Object.keys(available).length > 0) {
relatedClasses[className] = available;
}
}

return relatedClasses;
}

function checkRelation(classname,schema){
for (const col in schema) {
if (schema[col].type === 'Pointer' && schema[col].targetClass === classname) {
return true;
const checkRelationHelper = (schema, col, className) =>
schema[col].type === 'Pointer' && schema[col].targetClass === className;

function checkRelation(currentClassname, schemas, classToReferName) {
const currentClassSchema = schemas[currentClassname];
const classSchemaBeingCheckedToRefer = schemas[classToReferName];
let flag = false;

for (const col in currentClassSchema) {
if (checkRelationHelper(currentClassSchema, col, classToReferName)) {
flag = true;
}
}
return false;

for (const col in classSchemaBeingCheckedToRefer) {
if (checkRelationHelper(classSchemaBeingCheckedToRefer, col, currentClassname)) {
flag = true;
}
}
return flag;
}

export const BLACKLISTED_FILTERS = ['containsAny', 'doesNotContainAny'];
Expand Down
23 changes: 13 additions & 10 deletions src/lib/queryFromFilters.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,20 @@ export default async function queryFromFilters(className, filters) {
}
const reversePointerField = getPointerField(allClassesSchema, filterClassName, className);
const pointerField = getPointerField(allClassesSchema, className, filterClassName);
if (pointerField) {
tempquery.matchesQuery(pointerField, queries[filterClassName]);
} else if (reversePointerField) {
await tempquery.matchesKeyInQuery(
'objectId',
`${reversePointerField}.objectId`,
queries[filterClassName]
)
querieslist.push(tempquery);
} else {
if (!pointerField && !reversePointerField) {
console.warn(`No relationship found between ${className} and ${filterClassName}`);
} else {
if (pointerField) {
tempquery.matchesQuery(pointerField, queries[filterClassName]);
}
if (!pointerField && reversePointerField) {
await tempquery.matchesKeyInQuery(
'objectId',
`${reversePointerField}.objectId`,
queries[filterClassName]
);
}
querieslist.push(tempquery);
}
})
);
Expand Down

0 comments on commit 3d87049

Please sign in to comment.