jesper-raemaekers / vscode-polarion

GNU General Public License v3.0
6 stars 2 forks source link

Create new work item in Polarion #2

Open blelevier opened 2 years ago

blelevier commented 2 years ago

Hi Jesper, I just started using python-polarion and vscode-polarion and must say that they are really helpful. Thanks for the great work! I'm just thinking out loud, I don't need these features right now, I'm just exploring ideas, and wanted to hear your point of view, if you see some limitations or any other feedback:

Would it be feasible to add some functionalities from the python-polarion package to this one? For example:

jesper-raemaekers commented 2 years ago

Hi,

Thanks for using it and providing feedback :)

I think providing a full editor for this might be a little much. If you start there is not real end as you run into custom field and types. But I think the 'create new task here' button should be possible.

I think that 'right click' and then 'Insert new workitem' followed by a popup for the title of the workitem can be a nice addition.

blelevier commented 2 years ago

Thanks for your comments Jesper. I would like to do a right click, and then click "Create work item". After that, the ID that was generated should be inserted in the code, for example: From: // This function implements {} To: // This function implements {CAR-12345}
I don't need to add the work item title, it could later be edited in Polarion, I'm just interested in generating a new id. I'm not very familiar with typescript, but will give it a try. I'll fork the repo and let you know any progress if that's ok. Thanks!

jesper-raemaekers commented 2 years ago

Okay then let me give you some pointers; You'd want to start by creating a 'insertworitem' function in the editor.ts file. Use the function 'handleOpenPolarion' as a guide because it already deals with the location of the cursor in the editor. You'd have to add this new function here: https://github.com/jesper-raemaekers/vscode-polarion/blob/main/src/extension.ts#L28 and https://github.com/jesper-raemaekers/vscode-polarion/blob/main/package.json#L92 so that the command is known to vscode and is added to the context menu.

i would recommend to ask work a title anyway because the title is the only required property of a workitem apart from the workitem type (and author but that is determined by login details).

IF you have done this you will run into the more obscure part, which is adding the workitem to polarion.

blelevier commented 2 years ago

Hi again Jesper! sorry for the delay. I started working today in this branch. I was able to add the option when right click--> Insert work item. I'm using a textbox to ask for the title. I think I'll use another textbox to ask for the work item type? Now I'm getting into the obscure part of creating the work item in Polarion haha. I guess it will be something like: await this.soapTracker.createWorkItem() I'm figuring out the parameter I need to pass in typescript, in python it is normally something like: (when using three variables type, title, and project_id.

work_item_properties = { 
    'type': { 
        'id': type_id },
    'project': { 
        'uri': f'subterra:data-service:objects:/default/{project_id}${{Project}}{project_id}' }, 
    'title': title, }

I'll give it a try. Will keep you posted. Thanks.

jesper-raemaekers commented 2 years ago

Or maybe make a list of possible workitems. I think this can be limited or a settings. The reason for this is that otherwise the user would need to type the exact type of the workitem. For a task that is simple, but another option could be softwareunitest which is not very user friendly.

As for the method to use, you can look at the xml file for this interface. Change it for your url, but for me it is: http://polarion.local/polarion/ws/services/TrackerWebService?wsdl Here you can find createWorkItem and that it only takes one argument ( a workitem).

<element name="createWorkItem">
<complexType>
<sequence>
<element name="content" type="tns3:WorkItem"/>
</sequence>
</complexType>
</element>

And you can lookup the workitem type in the same file:

<complexType name="WorkItem">
<sequence>
<element maxOccurs="1" minOccurs="0" name="approvals" type="tns3:ArrayOfApproval"/>
<element maxOccurs="1" minOccurs="0" name="assignee" type="tns4:ArrayOfUser"/>
<element maxOccurs="1" minOccurs="0" name="attachments" type="tns3:ArrayOfAttachment"/>
<element maxOccurs="1" minOccurs="0" name="author" type="tns4:User"/>
-- removed some element for sake of length ---
</sequence>
<attribute name="uri" type="tns2:SubterraURI"/>
<attribute name="unresolvable" type="xsd:boolean"/>
</complexType>

From this i would suggest trying:

await this.soapTracker.createWorkItem({'content': work_item_properties })

Good luck!

blelevier commented 2 years ago

Long time no see! Sorry for my absence. I'm really interested in making this feature work.

Taking into account CR as the name of the project and type-abc as the work item type, using the python polarion package I'm able to create a work item with:

  client = Polarion(url, user, password)
  service = client.getService('Tracker')
  work_item_properties = {'type': {'id': 'type-abc'},
                          'project': {'uri': 'subterra:data-service:objects:/default/CR${Project}CR'}}
  new_workitem = service.createWorkItem(work_item_properties)

So I was trying to do something similar here. Now, for this extension I tried playing around with

await this.soapTracker.createWorkItem({'content': work_item_properties })

but nothing so far, or perhaps I'm just bad at handling promises...

blelevier commented 2 years ago

In python I'm able to create a work item with:

  work_item_properties = {'type': {'id': 'type-abc'},
                          'title': 'Test',
                          'description': {'type': 'text/html',
                                          'content': 'Description example<br/>',
                                          'contentLossy': False},
                          'project': {'uri': 'subterra:data-service:objects:/default/CR${Project}CR'}}

  new_workitem = service.createWorkItem(work_item_properties)

I tried to do something similar: Just for debugging purposes, I set-up a breakpoint here and changed the line to use createWorkItemAsync:

  let work_item_properties = {'type': {'id': 'type-abc'},
                              'title': 'Test',
                              'description': {'type': 'text/html',
                                              'content': 'Description example<br/>',
                                              'contentLossy': false},
                              'project': {'uri': 'subterra:data-service:objects:/default/CR${Project}CR'}};
await this.soapTracker.createWorkItemAsync({work_item_properties}, null, this.sessionID)

That seems to work better, at least now I get errors about Polarion. So maybe I need to work on the work_item_properties. This is the error I get: image

WH-Yoshi commented 5 months ago

Hi, I'm not really in the subject right now and my purpose isn't to create a workitem... I was just doing some research about SubterraURI, and I can't find anything about it that show me how to create one. My purpose is to getProjectGroup and thus I need the uri of the group. I see that you have one subterra uri in your workitem and I was wondering if you could help me out about that... Thanks !