gioboa / jira-plugin

Jira plugin for VsCode
https://marketplace.visualstudio.com/items?itemName=gioboa.jira-plugin
MIT License
266 stars 41 forks source link

Custom Required Fields #38

Closed Kaffiend closed 5 years ago

Kaffiend commented 5 years ago

Is your feature request related to a problem? Please describe. Custom Required Fields are not populated in the create issue command.

Describe the solution you'd like Query the api for the fields to build a dynamic menu including required custom fields when creating an issue

Describe alternatives you've considered Manually configured custom fields to include in command menu.

Kaffiend commented 5 years ago

The above linked api call is from version 3 (beta) of the api and seems to be the animal we are looking for 😸 just looking at the example response it can be used to build the create issue menu from the response, including custom fields

GET /rest/api/3/field

[
  {
    "id": "description",
    "name": "Description",
    "custom": false,
    "orderable": true,
    "navigable": true,
    "searchable": true,
    "clauseNames": [
      "description"
    ],
    "schema": {
      "type": "string",
      "system": "description"
    }
  },
  {
    "id": "summary",
    "key": "summary",
    "name": "Summary",
    "custom": false,
    "orderable": true,
    "navigable": true,
    "searchable": true,
    "clauseNames": [
      "summary"
    ],
    "schema": {
      "type": "string",
      "system": "summary"
    }
  },
    {
        "id": "customfield_10100",
        "key": "customfield_10100",
        "name": "Customer",
        "custom": true,
        "orderable": true,
        "navigable": true,
        "searchable": true,
        "clauseNames": [
            "cf[10100]",
            "Customer"
        ],
        "schema": {
            "type": "option",
            "custom": "com.atlassian.jira.plugin.system.customfieldtypes:select",
            "customId": 10100
        }
    },
]

Edit: One thing i can think of, since we can only query for all the fields the user can see, regardless if they are in use on a screen. We can make a configure command to call the endpoint, and generate config options that plugin users can then toggle in the settings what fields to include when creating an issue.. So far that's all i've found.

gioboa commented 5 years ago

@Kaffiend you are right. 👍 We can change the workflow.

  1. First of first we choose the issue type.
  2. With issue type we can retrive all the fields.
  3. Then for each field we need "display_name" and possible values. @Kaffiend do you know how many types there are for "schema"? { "type": "option/string" ... } We need also a Jira API for extract all the values for each field
  4. Now we have all the information for create a Jira ticket 😸 I hope Jira API help us.

Here one custom field straight from Jira response: createMetaData ... expand: 'projects.issuetypes.fields'

{ hasDefaultValue:false name:"Epic Link" <--- it can be the "display_name" required:false schema:Object {type: "any", custom: "com.pyxis.greenhopper.jira:gh-epic-link", customId: 10000} custom:"com.pyxis.greenhopper.jira:gh-epic-link" customId:10000 type:"any" }

----- Update -----

For schema -> type: "array" there is allowedValues prop with { name: "", description: "", id: "" .... }

gioboa commented 5 years ago

I'm facing the problem to manage all the types. I really want a self configurable code, but we must define which types are menage in the code. Some types get the available values from Jira API and unfortunately the response for every field is different. 😢 There are also many different type of input. (date, link, number, string) @Kaffiend what do you think?

Kaffiend commented 5 years ago

Based on the schema of the custom field we then might have additional calls to get that fields options like a select (dropdown field), date we can just handle that on our own with validation, i'm trying to find the api call to get the options of configured select field. Ok so if the expanded call returns children on a custom field those ids should resolve the value of each option with this call /rest/api/2/customFieldOption/{id}

gioboa commented 5 years ago

In the createMetaData response there is also the availableValues and for some field there is the uri for retrieve all the values. I'm working for create a configurable code. I've almost done then if you want you can have a look into the code.

gioboa commented 5 years ago

I've done the self configurable implementation in this commit You can check the code and also if it works in your environment. Need to manage all the field types, but I think we are going in the right direction. 👍 ---- UPDATE ---- I managed also number field type. I'm waiting for your test. 😄

Kaffiend commented 5 years ago

ok, ill give it a try this evening and let you know 😄 UPDATE I tried it but our only custom field is a select type, ill have to add one to a test project and see how it handles string and number types

gioboa commented 5 years ago

@Kaffiend Do you have some feedback? If you don't have any feedback, we can close this issue. 👍 😄

Kaffiend commented 5 years ago

Apologies been a tad busy of late.

On Mon, Dec 10, 2018, 1:47 AM Giorgio Boa <notifications@github.com wrote:

Closed #38 https://github.com/gioboa/jira-plugin/issues/38.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/gioboa/jira-plugin/issues/38#event-2015068429, or mute the thread https://github.com/notifications/unsubscribe-auth/AHdrNRepdFJIUmB4IeHgS3Miht10xRpuks5u3gONgaJpZM4Yub8V .