roadie-backstage-plugins icon indicating copy to clipboard operation
roadie-backstage-plugins copied to clipboard

[backstage-plugin-jira] Support custom jql queries

Open tbourrelovh opened this issue 2 years ago • 7 comments

We would like to be able to retrieve the number of issues matching a custom JQL query.

Feature Suggestion

It would be great to be able to provide JQL queries in our entities, alongside the plugin configuration. Those queries would be used to display the number of issues matching them.

Possible Implementation

I took the liberty to try out a potential implementation, you can see it on my fork : https://github.com/tbourrelovh/roadie-backstage-plugins/commit/12909b06de149e7d9a39881fb6a2027c58227b4b

Main changes being in :

  • plugins/frontend/backstage-plugin-jira/src/types.ts
  • plugins/frontend/backstage-plugin-jira/src/hooks/useProjectEntity.ts
  • plugins/frontend/backstage-plugin-jira/src/hooks/useCustomQueriesCount.ts
  • plugins/frontend/backstage-plugin-jira/src/components/JiraCard/components/CustomQueryStatus.tsx
  • plugins/frontend/backstage-plugin-jira/src/components/JiraCard/JiraCard.tsx
  • plugins/frontend/backstage-plugin-jira/src/api/index.ts

Some changes where induced by prettier 🙂

Entity configuration

metadata:
  ...
  annotations:
    jira/project-key: MYPROJECT
  jira:
    count:
      - title: "P1 & P2"
        query: 'project = MYPROJECT AND issuetype = Incident AND status = Open AND "Application Services DTR" = SERVICE AND Severity in (P1, P2)'
      - title: "P3, P4, P5"
        query: 'project = MYPROJECT AND issuetype = Incident AND status = Open AND "Application Services DTR" = SERVICE AND Severity in (P3, P4, P5)'
      - title: "All bugs"
        query: 'project = MYPROJECT AND issuetype = Bug  AND "Application Services DTR" = SERVICE'
    ...

Display

In term of displaying the data, I thought that it could be added in an another section under the actual count section.

backstage-plugin-jira custom jql

Context

We want to track the number of issues based on custom fields in our jira issues.

tbourrelovh avatar Jan 20 '22 11:01 tbourrelovh

https://app.shortcut.com/larder/story/6118

roadie-bot avatar Jan 20 '22 11:01 roadie-bot

@tbourrelovh Thanks for the feature suggestion! I think the idea is good, do you mind opening a PR and we could take it to the implementation and get started reviewing it, if you are comfortable with it!:)

kissmikijr avatar Jan 20 '22 15:01 kissmikijr

Great news @kissmikijr ! I'll gladly do it 👍

tbourrelovh avatar Jan 20 '22 16:01 tbourrelovh

I opened the PR https://github.com/RoadieHQ/roadie-backstage-plugins/pull/390

tbourrelovh avatar Jan 21 '22 09:01 tbourrelovh

Hey @tbourrelovh we have discussed with the maintainers of backstage. They said it is valid however they suggested for this particular use case a backend plugin would be more suitable and I agree, I think it will be better as a backend plugin.

We won't have the time for this in the near future, but feel free to try to move it into a backend plugin, however at this point I think it might be more useful to start ideating about this plugin in its current shape and form, I think it worth a redesign.

Thank you for your patience with this issue and pull request! :)

kissmikijr avatar Feb 09 '22 17:02 kissmikijr

Hey @kissmikijr

I read the thread you linked concerning the exchange you had with backstage maintainers. I share your concerns regarding how each team would be able to set the list of queries they'd like to be executed when using a backend plugin. Maybe it would be possible to read entity files to fetch the jira/project-key annotation and the queries to execute too, but it would still mean having the queries in a custom metadata section...

Moreover, having a backend plugin managing the requests would still mean having a frontend plugin responsible for displaying the data, am I right ?


Going on with the actual shape of the plugin. What do you have in mind concerning the redesign ?

On my internal fork, I have implemented a sort of "guard" to filter out JQL queries attempting to call another project than the one defined in the jira/project-key annotation, would you be interested in it ?


Sorry, lot of questions 😄 And don't worry, I prefer we take the time necessary to implement this feature in a future-proof manner, instead of making future changes harder...

tbourrelovh avatar Feb 10 '22 16:02 tbourrelovh

Hello @kissmikijr 🙂 Can I do something to move forward with the implementation ?

tbourrelovh avatar Mar 16 '22 14:03 tbourrelovh

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Oct 31 '23 10:10 github-actions[bot]