Giter VIP home page Giter VIP logo

Comments (4)

parse-github-assistant avatar parse-github-assistant commented on August 31, 2024

Thanks for opening this issue!

  • 🎉 We are excited about your ideas for improvement!

from parse-dashboard.

patelmilanun avatar patelmilanun commented on August 31, 2024

We can't call the cloud function with array of elements it has to be a object meaning our array of selected items must be converted into object. And because of this user should be aware of the cloud function receiving different types of input base on from where it is called i.e. from cell or multi select row. Because accordingly the input will change. If we use this approach.

Here is a snippet that demonstrate that. Now the question is do we want to run the function 1-by-1 on each element or just use single object which in actual is array of all the selected elements. In 1-by-1 approach user don't need to worry about the input type anymore but this will be pure overhead in my opinion.

@mtrezza guide me senpai

async executeSript(script) {
  const { selection } = this.props;
  try {
    const objects = [];
    Object.keys(selection).forEach((key) =>
      objects.push(
        Parse.Object.extend(this.props.currentClass).createWithoutData(key)
      )
    );
    const response = await Parse.Cloud.run(
      script.cloudCodeFunction,
      { object: { ...objects.map((object) => object.toPointer()) } },
      { useMasterKey: true }
    );
    this.props.showNote(
      response ||
        `Ran script "${script.title}" on "${this.props.currentClass}" object "${object.id}".`
    );
    this.props.onRefresh();
  } catch (e) {
    this.props.showNote(e.message, true);
    console.log(`Could not run ${script.title}: ${e}`);
  }
}

This will output in

info: Ran cloud function deleteAccount for user undefined with:
  Input: {"object":{"0":{"__type":"Pointer","className":"_User","objectId":"fM1mhqXeJ9"},"1":{"__type":"Pointer","className":"_User","objectId":"EiBiG6KFdy"}}}
  Result: "Hello world!" {"functionName":"deleteAccount","params":{"object":{"0":{"__type":"Pointer","className":"_User","objectId":"fM1mhqXeJ9"},"1":{"__type":"Pointer","className":"_User","objectId":"EiBiG6KFdy"}}}}

As you can see in the output, I have to convert array to object else it won't work. This approach is a bit anti-user. Do you have any suggestion here?

from parse-dashboard.

mtrezza avatar mtrezza commented on August 31, 2024

I think there are two possible scenarios and uses cases for both:

  • a) Execute multiple server requests, each with a single object.
  • b) Execute a single server requests with all selected rows in the payload.

It's something the developer should be able to decide what they want. Both approaches allow for different features.

For example:

  • (a) allows to implement a progress bar in the dashboard, (b) doesn't.
  • (b) allows to select 2 rows and "connect" the two records in some way, (a) doesn't.

The developer could choose between (a) and (b) in the script settings.

I would however see (b) as a completely new feature and maybe rather start with (a). Which seems simpler. Not sure about the payload the dashboard currently sends, but if we start supporting sending multiple objects with (b), then maybe we should (breaking) change the payload in a way that it works for both, like:

{
  objects: [...]
}

from parse-dashboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.