Skip to content
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

Add Modify Plugin #53

Open
jcaianirh opened this issue Mar 13, 2019 · 8 comments
Open

Add Modify Plugin #53

jcaianirh opened this issue Mar 13, 2019 · 8 comments
Labels
enhancement Something to be improved
Milestone

Comments

@jcaianirh
Copy link
Collaborator

Add the ability to modify a plugin once its created. Use @jbernal0019 's backend js api for modifiable fields.

@zrthxn
Copy link
Member

zrthxn commented Apr 8, 2021

@mairin I could start working on this if I can get some documentation on the backend API. Also please let me know if there are specific requirements for this

@jennydaman
Copy link
Collaborator

@zrthxn some documentation is here: https://fnndsc.github.io/ChRIS_store/

But more helpful is the API itself. It's designed to be self-documenting in a way. (does it work? you be the judge)

For example:

https https://chrisstore.co/api/v1/20/
HTTP/1.1 200 OK
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
Connection: Keep-Alive
Content-Length: 973
Content-Type: application/vnd.collection+json
Date: Thu, 08 Apr 2021 06:54:39 GMT
Keep-Alive: timeout=5, max=100
Server: Apache
Vary: Accept,Cookie
X-Frame-Options: SAMEORIGIN

{
    "collection": {
        "href": "https://chrisstore.co/api/v1/20/",
        "items": [
            {
                "data": [
                    {
                        "name": "id",
                        "value": 20
                    },
                    {
                        "name": "creation_date",
                        "value": "2021-02-08T11:49:15.818028-05:00"
                    },
                    {
                        "name": "modification_date",
                        "value": "2021-02-09T07:44:00.312420-05:00"
                    },
                    {
                        "name": "name",
                        "value": "pl-med2img"
                    },
                    {
                        "name": "title",
                        "value": "A ChRIS plugin app"
                    },
                    {
                        "name": "stars",
                        "value": 0
                    },
                    {
                        "name": "public_repo",
                        "value": "https://github.com/FNNDSC/pl-med2img"
                    },
                    {
                        "name": "license",
                        "value": "MIT"
                    },
                    {
                        "name": "type",
                        "value": "ds"
                    },
                    {
                        "name": "icon",
                        "value": ""
                    },
                    {
                        "name": "category",
                        "value": ""
                    },
                    {
                        "name": "authors",
                        "value": "Arushi Vyas <dev@babyMRI.org>"
                    },
                    {
                        "name": "documentation",
                        "value": "https://github.com/FNNDSC/pl-med2img"
                    }
                ],
                "href": "https://chrisstore.co/api/v1/20/",
                "links": [
                    {
                        "href": "https://chrisstore.co/api/v1/20/plugins/",
                        "rel": "plugins"
                    },
                    {
                        "href": "https://chrisstore.co/api/v1/users/1/",
                        "rel": "owner"
                    }
                ]
            }
        ],
        "links": [],
        "template": {
            "data": [
                {
                    "name": "public_repo",
                    "value": ""
                },
                {
                    "name": "new_owner",
                    "value": ""
                }
            ]
        },
        "version": "1.0"
    }
}

Take note of these parts:

Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS
[...]
        "template": {
            "data": [
                {
                    "name": "public_repo",
                    "value": ""
                },
                {
                    "name": "new_owner",
                    "value": ""
                }
            ]
        },

Piecing it together, such a request would be legal:

https -a <username>:<password> PATCH https://chrisstore.co/api/v1/20/ content-type:application/vnd.collection+json template:='{"data":[{"name": "public_repo", "value": "https://github.com/FNNDSC/pl-med2img"}]}'

The effect is, the plugin's public code repository is changed.

@zrthxn
Copy link
Member

zrthxn commented Apr 9, 2021

After creating a test account and creating a sample plugin for testing, whose representation file I copied from the cookiecutter Wiki here, I get the following runtime error when I try to open the Dashboard.

TypeError: DashApplicationType is not a constructor

Screenshot (35)

I haven't modified anything related to the Dashboard yet.
I think this happens because DashApplicationType is a function

const DashApplicationType = (type) => {
  if (type === 'ds') {
    return (<React.Fragment><span className="fa fa-database" /> Data System</React.Fragment>);
  }
  return (<React.Fragment><span className="fa fa-file" /> File System</React.Fragment>);
};

and it's being called with the new keyword.

const applicationType = new DashApplicationType(plugin.type);

Should I modify this or is there something I'm missing here?

@jennydaman
Copy link
Collaborator

@zrthxn I am getting the same error. Maybe it is a backwards incompatible change with latest version of node. Would you submit a PR for your fix?

@zrthxn
Copy link
Member

zrthxn commented Apr 9, 2021 via email

@zrthxn
Copy link
Member

zrthxn commented Apr 10, 2021

From the documentation, if I understand correctly, the modifiable fields are

  • public_repo
  • dock_image
  • name
  • descriptor_file

Now there is already a edit modal that is able to edit the public_repo field. I am considering two approaches to this, one which uses the existing modal setup and another that will make more drastic changes.

  1. Using the modal, just add more fields to the modal and change the API call to include those fields. This will be simple but limited in the number of things you can put in the modal.
  2. Changing the CreatePlugin component to PluginEditor, and introduce an intent prop. Based on this the component can either populate the fields with given values if (intent == 'edit') or it can show empty fields if (intent == 'create')

Which dyou think is better and is this the right direction?

@jennydaman
Copy link
Collaborator

I don't see where in the documentation page it says that descriptor_file, name, or dock_image is modifiable. Neither do I think these should be modifiable.

Using the edit modal would be easier to implement, I believe. The 'intent' idea would be great, but at the moment we have too much first to figure out.

Perhaps I should have studied this issue a bit before having you take it up, since the edit modal allows for editing of the only editable field (aside from "owner," which is a bit special). I will ask @jbernal0019, our backend developer, how to proceed.

The "intent" idea might be worthwhile to pursue. If you were to implement the feature, uneditable fields such as name should be greyed out. i.e. most things should be greyed out. But the plugin's long description should maybe be editable. Unfortunately the backend does not support the long description yet.

@zrthxn
Copy link
Member

zrthxn commented Apr 11, 2021

I don't see where in the documentation page it says that descriptor_file, name, or dock_image is modifiable. Neither do I think these should be modifiable.

I saw them being sent in the "template" field and I tried to piece it together from how you had described it. I think that was wrong then.

The "intent" idea might be worthwhile to pursue. If you were to implement the feature, uneditable fields such as name should be greyed out. i.e. most things should be greyed out. But the plugin's long description should maybe be editable. Unfortunately the backend does not support the long description yet.

Yea that's what I had thought of as well.

Perhaps I should have studied this issue a bit before having you take it up, since the edit modal allows for editing of the only editable field (aside from "owner," which is a bit special). I will ask @jbernal0019, our backend developer, how to proceed.

Alright I'll wait for a response from him.

@zrthxn zrthxn removed their assignment May 24, 2021
@jennydaman jennydaman added the enhancement Something to be improved label May 26, 2021
@jennydaman jennydaman added this to the 2.0 reach milestone May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something to be improved
Projects
None yet
Development

No branches or pull requests

4 participants