Skip to content

Json rpc plugin setting control #657

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

Merged
merged 15 commits into from
Dec 9, 2021
Merged

Json rpc plugin setting control #657

merged 15 commits into from
Dec 9, 2021

Conversation

taooceros
Copy link
Member

@taooceros taooceros commented Aug 16, 2021

close #814

TODO:

  • Markdown Field
  • File/Folder Selector

@taooceros
Copy link
Member Author

It's currently a simple proposal. Only key/value is supported. Bool value use Checkbox, and others use TextBox.
Numbers are treated as string.

@Zeroto521
Copy link
Member

githubs-form-schema is a good YAML example.

---
name: Account Recovery
description: Initiate an account recovery due to lost 2FA or inability to access email address
title: Account recovery request
labels: account-recovery 

body:
- type: markdown
  attributes:
    value: |
      **Request for account recovery.**

- type: input
  attributes:
    label: PyPI Username
    description: >-
      Enter your PyPI `username` wrapped with single backticks
  validations:
    required: true

- type: textarea
  attributes:
    label: Reason for request
    description: |
      State the reason for your request
      - Lost access to email address
      - Lost 2FA authentication app or security token
  validations:
    required: true


- type: checkboxes
  attributes:
    label: Code of Conduct
    description: |
      Read the [PSF Code of Conduct][CoC] first.

      [CoC]: https://github.com/pypa/.github/blob/main/CODE_OF_CONDUCT.md
    options:
    - label: I agree to follow the PSF Code of Conduct
      required: true

- type: checkboxes
  attributes:
    label: Acknowledgement
    description: |
      By their nature account recovery issues are labor intensive. The PyPI team has limited resources available for their completion.

      There may be a delay of a week or more between responses for these issues.
    options:
    - label: I understand that it may take a significant amount of time to process my account recovery request.
      required: true
...

image

@taooceros
Copy link
Member Author

taooceros commented Oct 30, 2021

Current Proposal

  • Configuration File: SettingsTemplate.yaml in the same folder as plugin.json\

Configuration Syntax (almost equal to github one but with small modification

- type: textarea/input
  attributes:
    label: Label to be displayed before the control
    description: Not yet implemented (probably tooltip)
    placeholder: Not yet implemented 
    name: identifier of the control
    defaultValue: Default Value of the control
- type: password
   attributes:
    label: Label to be displayed before the control
    description: Not yet implemented (probably tooltip)
    placeholder: Not yet implemented 
    name: identifier of the control
    defaultValue: Default Value of the control
    passwordChar: char to mask the actual input 
- type: dropdown
  attributes:
    label: Version
    description: What version of our software are you running?
    multiple: false
    options:
      - label: 1.0.2 (Default)
      - label: 1.0.3 (Edge)
  validations:
    required: true
- type: checkbox
  attributes:
    label: Code of Conduct
    description: The Code of Conduct helps create a safe space for everyone. We require
      that everyone agrees to it.
    defaultValue: true

@jjw24
Copy link
Member

jjw24 commented Nov 2, 2021

has this been tested, can you provide a screenshot of an example output please.

@jjw24 jjw24 added the enhancement New feature or request label Nov 2, 2021
@jjw24 jjw24 added this to the Future milestone Nov 2, 2021
@taooceros
Copy link
Member Author

has this been tested, can you provide a screenshot of an example output please.

It is usable. Though some communication detail is still under discussion.

@jjw24
Copy link
Member

jjw24 commented Nov 2, 2021

shall we mark it as draft then?

@taooceros
Copy link
Member Author

shall we mark it as draft then?

It depends. The functionality is complete, so plugin is able to create setting via the yaml. The left thing is how we want plugin to change the content in the setting, and how they should access the setting.

@jjw24
Copy link
Member

jjw24 commented Nov 2, 2021

how they should access the setting.

during start up, jsonrpc call to plugin to load the settings and then create the settings in flow's settings window based on the callback.

when user changes the setting in the settings window, do a jsonrpc call to let the plugin know?

how we want plugin to change the content in the setting

you mean plugin will change the settings contents in the settings window? can you give me an example

@taooceros
Copy link
Member Author

Well the current implementation is a template file (in the plugin root directory) will be used to create the settings file and the controls. Plugins may get the place of the setting file, but they currently don't have access to the content changed by user. I am thinking about to pass the whole setting json as part of the query to the plugin, and receive a diff new setting json from plugin when calling back (to modify the setting).
There's no need to let plugin know when setting changes because they don't have state. But it is also possible to save whenever user change the setting, so plugin can directly access that file. Though that way plugin won't be able to modify the setting loaded in flow.

Sometimes we would like to change the setting via query such as we can add path to quickaccesspath in explorer plugin. I think that's reasonable for jsonrpc plugin to do.

@Garulf Garulf modified the milestones: Future, 1.9.0 Dec 8, 2021
@Garulf
Copy link
Member

Garulf commented Dec 8, 2021

After some testing retrieving settings works, the templating works as well. SettingsChange would be more effective as an API method like:

{"method": "Flow.SettingsChange","parameters": foo}

Also we should make sure a malformed template file doesn't crash Flow.

@taooceros taooceros merged commit f86dd9d into dev Dec 9, 2021
@taooceros taooceros deleted the JsonRPCPluginSettingControl branch December 9, 2021 03:49
@Garulf Garulf modified the milestones: Future, 1.9.0 Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Let setting UI support for other program languages
4 participants