@@ -166,7 +166,8 @@ class Browser extends DashboardView {
166
166
let relation = this . state . relation ;
167
167
if ( isRelationRoute && ! relation ) {
168
168
const parentObjectQuery = new Parse . Query ( className ) ;
169
- const parent = await parentObjectQuery . get ( entityId , { useMasterKey : true } ) ;
169
+ const { useMasterKey } = this . state ;
170
+ const parent = await parentObjectQuery . get ( entityId , { useMasterKey : useMasterKey } ) ;
170
171
relation = parent . relation ( relationName ) ;
171
172
}
172
173
await this . setState ( {
@@ -401,7 +402,8 @@ class Browser extends DashboardView {
401
402
402
403
async fetchParseDataCount ( source , filters ) {
403
404
const query = queryFromFilters ( source , filters ) ;
404
- const count = await query . count ( { useMasterKey : true } ) ;
405
+ const { useMasterKey } = this . state ;
406
+ const count = await query . count ( { useMasterKey : useMasterKey } ) ;
405
407
return count ;
406
408
}
407
409
@@ -478,7 +480,8 @@ class Browser extends DashboardView {
478
480
}
479
481
query . limit ( MAX_ROWS_FETCHED ) ;
480
482
481
- query . find ( { useMasterKey : true } ) . then ( ( nextPage ) => {
483
+ const { useMasterKey } = this . state ;
484
+ query . find ( { useMasterKey : useMasterKey } ) . then ( ( nextPage ) => {
482
485
if ( className === this . props . params . className ) {
483
486
this . setState ( ( state ) => ( {
484
487
data : state . data . concat ( nextPage )
@@ -569,7 +572,8 @@ class Browser extends DashboardView {
569
572
} else {
570
573
obj . set ( attr , value ) ;
571
574
}
572
- obj . save ( null , { useMasterKey : true } ) . then ( ( objectSaved ) => {
575
+ const { useMasterKey } = this . state ;
576
+ obj . save ( null , { useMasterKey : useMasterKey } ) . then ( ( objectSaved ) => {
573
577
const createdOrUpdated = isNewObject ? 'created' : 'updated' ;
574
578
let msg = objectSaved . className + ' with id \'' + objectSaved . id + '\' ' + createdOrUpdated ;
575
579
this . showNote ( msg , false ) ;
@@ -583,7 +587,7 @@ class Browser extends DashboardView {
583
587
const parentRelation = parent . relation ( relation . key ) ;
584
588
parentRelation . add ( obj ) ;
585
589
const targetClassName = relation . targetClassName ;
586
- parent . save ( null , { useMasterKey : true } ) . then ( ( ) => {
590
+ parent . save ( null , { useMasterKey : useMasterKey } ) . then ( ( ) => {
587
591
this . setState ( {
588
592
newObject : null ,
589
593
data : [
@@ -660,10 +664,11 @@ class Browser extends DashboardView {
660
664
const toDeleteObjectIds = [ ] ;
661
665
toDelete . forEach ( ( obj ) => { toDeleteObjectIds . push ( obj . id ) ; } ) ;
662
666
667
+ const { useMasterKey } = this . state ;
663
668
let relation = this . state . relation ;
664
669
if ( relation && toDelete . length ) {
665
670
relation . remove ( toDelete ) ;
666
- relation . parent . save ( null , { useMasterKey : true } ) . then ( ( ) => {
671
+ relation . parent . save ( null , { useMasterKey : useMasterKey } ) . then ( ( ) => {
667
672
if ( this . state . relation === relation ) {
668
673
for ( let i = 0 ; i < indexes . length ; i ++ ) {
669
674
this . state . data . splice ( indexes [ i ] - i , 1 ) ;
@@ -674,7 +679,7 @@ class Browser extends DashboardView {
674
679
}
675
680
} ) ;
676
681
} else if ( toDelete . length ) {
677
- Parse . Object . destroyAll ( toDelete , { useMasterKey : true } ) . then ( ( ) => {
682
+ Parse . Object . destroyAll ( toDelete , { useMasterKey : useMasterKey } ) . then ( ( ) => {
678
683
let deletedNote ;
679
684
680
685
if ( toDeleteObjectIds . length == 1 ) {
@@ -767,11 +772,12 @@ class Browser extends DashboardView {
767
772
if ( ! objectIds || ! objectIds . length ) {
768
773
throw 'No objectId passed' ;
769
774
}
775
+ const { useMasterKey } = this . state ;
770
776
const relation = this . state . relation ;
771
777
const query = new Parse . Query ( relation . targetClassName ) ;
772
778
const parent = relation . parent ;
773
779
query . containedIn ( 'objectId' , objectIds ) ;
774
- let objects = await query . find ( { useMasterKey : true } ) ;
780
+ let objects = await query . find ( { useMasterKey : useMasterKey } ) ;
775
781
const missedObjectsCount = objectIds . length - objects . length ;
776
782
if ( missedObjectsCount ) {
777
783
const missedObjects = [ ] ;
@@ -785,7 +791,7 @@ class Browser extends DashboardView {
785
791
throw `${ errorSummary } ${ JSON . stringify ( missedObjects ) } ` ;
786
792
}
787
793
parent . relation ( relation . key ) . add ( objects ) ;
788
- await parent . save ( null , { useMasterKey : true } ) ;
794
+ await parent . save ( null , { useMasterKey : useMasterKey } ) ;
789
795
// remove duplication
790
796
this . state . data . forEach ( origin => objects = objects . filter ( object => object . id !== origin . id ) ) ;
791
797
this . setState ( {
@@ -811,13 +817,14 @@ class Browser extends DashboardView {
811
817
}
812
818
813
819
async confirmAttachSelectedRows ( className , targetObjectId , relationName , objectIds , targetClassName ) {
820
+ const { useMasterKey } = this . state ;
814
821
const parentQuery = new Parse . Query ( className ) ;
815
- const parent = await parentQuery . get ( targetObjectId , { useMasterKey : true } ) ;
822
+ const parent = await parentQuery . get ( targetObjectId , { useMasterKey : useMasterKey } ) ;
816
823
const query = new Parse . Query ( targetClassName || this . props . params . className ) ;
817
824
query . containedIn ( 'objectId' , objectIds ) ;
818
- const objects = await query . find ( { useMasterKey : true } ) ;
825
+ const objects = await query . find ( { useMasterKey : useMasterKey } ) ;
819
826
parent . relation ( relationName ) . add ( objects ) ;
820
- await parent . save ( null , { useMasterKey : true } ) ;
827
+ await parent . save ( null , { useMasterKey : useMasterKey } ) ;
821
828
this . setState ( {
822
829
selection : { } ,
823
830
} ) ;
@@ -836,18 +843,19 @@ class Browser extends DashboardView {
836
843
}
837
844
838
845
async confirmCloneSelectedRows ( ) {
846
+ const { useMasterKey } = this . state ;
839
847
const objectIds = [ ] ;
840
848
for ( const objectId in this . state . selection ) {
841
849
objectIds . push ( objectId ) ;
842
850
}
843
851
const query = new Parse . Query ( this . props . params . className ) ;
844
852
query . containedIn ( 'objectId' , objectIds ) ;
845
- const objects = await query . find ( { useMasterKey : true } ) ;
853
+ const objects = await query . find ( { useMasterKey : useMasterKey } ) ;
846
854
const toClone = [ ] ;
847
855
for ( const object of objects ) {
848
856
toClone . push ( object . clone ( ) ) ;
849
857
}
850
- await Parse . Object . saveAll ( toClone , { useMasterKey : true } ) ;
858
+ await Parse . Object . saveAll ( toClone , { useMasterKey : useMasterKey } ) ;
851
859
this . setState ( {
852
860
selection : { } ,
853
861
data : [
@@ -1205,6 +1213,7 @@ class Browser extends DashboardView {
1205
1213
updateRow = { this . updateRow }
1206
1214
confirmAttachSelectedRows = { this . confirmAttachSelectedRows }
1207
1215
schema = { this . props . schema }
1216
+ useMasterKey = { this . state . useMasterKey }
1208
1217
/>
1209
1218
)
1210
1219
}
0 commit comments