Skip to content

Add scripts #2399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
mtrezza opened this issue Mar 2, 2023 · 9 comments · Fixed by #2409
Closed
3 tasks done

Add scripts #2399

mtrezza opened this issue Mar 2, 2023 · 9 comments · Fixed by #2409
Labels
bounty:$100 Bounty applies for fixing this issue (Parse Bounty Program) state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version type:feature New feature or improvement of existing feature

Comments

@mtrezza
Copy link
Member

mtrezza commented Mar 2, 2023

New Feature / Enhancement Checklist

Current Limitation

Parse Dashboard allows for low-level data manipulation, but repeated manipulation of multiple fields cannot be done efficiently.

Feature / Enhancement Description

Allow to pre-define scripts that can be executed in Parse Dashboard.

  • Allow to right-click on a row in the data browser to send the full object as argument to a JS function.
  • Offer the script in context menu also for pointers to _User in other classes
  • JS function is declared in a .js file which has the Parse JS SDK available.
  • Show a pop-up message at bottom with request status for success and fail.

Example Use Case

Deleting a user, their installation and all their sessions.

Currently, these involve multiple steps in Parse Dashboard.

  1. Search for user in _User and delete.
  2. Search for installations of user in _Installation and delete.
  3. Search for sessions of user in _Session and delete.

A JS Script using the Parse JS SDK could execute all that with:

  1. Right-click on the row in _User class and in context menu choose "Scripts > Delete Account".

The JS function looks something something like this:

async func deleteAccount(req -> {
  const user = req.object;
  // Search for user in `_User` and delete.
  // Search for installations of user in `_Installation` and delete.
  // Search for sessions of user in `_Session` and delete.

  return `Deleted user with ${installations.length} installations and ${sessions.length} sessions.`;
  // or throw(error); to show an error status message in dashboard
});

The dashboard config file looks something like this:

const dashboard = ParseDashboard({
  scripts: [
      {
         title: 'Delete account', // The title in the context menu
         classes: ['_User'] // The classes for which the script will be available in the context menu
         target: './scripts/scripts.js:deleteAccount' // The JS file that contains the function
      }
  ],
});

Alternatives / Workarounds

Allow to execute Cloud Code functions with input parameters, which requires scripts to be hosted by Parse Server instead of Parse Dashboard.

@parse-github-assistant
Copy link

parse-github-assistant bot commented Mar 2, 2023

Thanks for opening this issue!

  • 🎉 We are excited about your ideas for improvement!

@mtrezza mtrezza added type:feature New feature or improvement of existing feature bounty:$100 Bounty applies for fixing this issue (Parse Bounty Program) labels Mar 2, 2023
@dblythy
Copy link
Member

dblythy commented Mar 2, 2023

I like this one!!

@mtrezza
Copy link
Member Author

mtrezza commented Mar 3, 2023

Who do you think should host the scripts, Parse Server or Parse Dashboard?

@dblythy
Copy link
Member

dblythy commented Mar 3, 2023

I’m not entirely sure, I think for convenience we could use the code editor on the dashboard to create the scripts and then save them to a secure database class, but I’m not sure this is the best workflow as the code editor is almost obsolete, and evaluating stringified code saved in a remote database could be problematic.

What do you think?

@mtrezza
Copy link
Member Author

mtrezza commented Mar 4, 2023

Regarding code editing, I think a dashboard feature would quite certainly loose against common IDEs developers are already using today. The idea of a code editor in Parse Dashboard seems to be a 2010s concept from when commercial Parse wanted to fill the gap left by underdeveloped IDEs.

Regarding code hosting, I can think of a few ways:

  • a) Code hosted by Parse Dashboard in deployed repository
  • b) Code hosted by Parse Dashboard in browser cookie
  • c) Code hosted by Parse Server in deployed repository
  • d) Code hosted by Parse Server in database
  • e) Code hosted by Parse Server as Cloud Code

Choosing one:

  • We don't want to couple Parse Dashboard to Parse Server; Parse Dashboard should be just another client for Parse Server, so (d) falls flat as it seems to require a special internal class and (c) as it seems to require a custom endpoint to reach these script files.
  • The scripts are likely more depending on Parse Server than Parse Dashboard, for example Parse Server code and DB schema need to be in-sync with scripts. It sounds cumbersome to track changes in 2 repositories for that, so it seems (a) falls flat.
  • If Parse Dashboard was a desktop app saving scripts locally with the app would be a realistic option. For a browser app that would be a browser cookie / container, but that just seems too ephemeral.

So we're left with (e):

const dashboard = ParseDashboard({
  scripts: [
      {
         title: 'Delete account', // The title in the context menu
         classes: ['_User'] // The classes for which the script will be available in the context menu
         cloudCodeFunction: 'deleteAccount' // the name of the Cloud Code Function to call
      }
  ],
});

@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.2.0-alpha.19

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Jun 23, 2023
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.3.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Sep 15, 2023
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.3.0-alpha.1

@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.3.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty:$100 Bounty applies for fixing this issue (Parse Bounty Program) state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version type:feature New feature or improvement of existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants