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

feat(jira-server): push a task to Jira Server integration #6059

Merged
merged 68 commits into from
Mar 25, 2022

Conversation

igorlesnenko
Copy link
Contributor

@igorlesnenko igorlesnenko commented Feb 15, 2022

Resolves #5810 #5994 #6238

How to test:

  • Add Jira Server integration
  • Create a task in parabol
  • Push task to Jira Server using push to integration menu
  • See the task was created on Jira Server
  • Add another member to a parabol team
  • Login as a new member
  • Create a task
  • Login as a previous member
  • Run the above query for the other member task
  • See the task was created on Jira Server and a comment added
  • Edit task in Jira Server
  • Open parabol board, see the task is loaded correctly

image

igorlesnenko and others added 30 commits January 24, 2022 20:48
It already has an id.
Copy link
Member

@mattkrick mattkrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 few little things, but nothing major. looking good!

@@ -5,7 +5,8 @@ import JiraSVG from './JiraSVG'

const iconLookup = {
_xGitHubIssue: GitHubSVG,
JiraIssue: JiraSVG
JiraIssue: JiraSVG,
JiraServerIssue: JiraSVG
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice we use the same jira logo here, but a different jira logo for the team members integrations page.
From atlassian's logo page (https://atlassian.design/resources/logo-library), it looks like our jira server logo used on the integrations page may be outdated. @Dschoordsch should we update that to use the new version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like for tabs in poker meetings we use an older logo. I can replace it, but not sure which logo to use.

Here I just used the same logo, as expected there will be rarely both Jira and JiraServer integrations added.
However, in poker meeting tabs, 2 identical logos looks weird to me.

Not sure, if there is a separate server logo exists. Maybe add some s badge to the logo or something?

cc @Dschoordsch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the logo on our instance of Jira Server, whatcha think?
jira-software-logo-jira-software-logo-11562914188wp8r59nt10

Copy link
Contributor Author

@igorlesnenko igorlesnenko Mar 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattkrick I see this square logo both on Jira Server and Jira in the header. However, I think we can use it for Jira Server to have different logos. Should we?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the logo for Jira Software, I think we should use it instead of the 3 arrows on the task card. Better version is available in the atlassian logo library. For the integration banner I had used the old logo they still use in their Jira Server documentation, could be the same Jira Software logo though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the logo
image

packages/client/shared/gqlIds/IntegrationRepoId.ts Outdated Show resolved Hide resolved
packages/client/shared/gqlIds/JiraServerIssueId.ts Outdated Show resolved Hide resolved
packages/server/dataloader/jiraServerLoaders.ts Outdated Show resolved Hide resolved
packages/server/graphql/types/Task.ts Outdated Show resolved Hide resolved
import {ExternalLinks} from '~/types/constEnums'
import IntegrationRepoId from '~/shared/gqlIds/IntegrationRepoId'

export default class JiraServerTaskIntegrationManager implements TaskIntegrationManager {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 it looks like this the TaskIntegrationManager is tightly coupled to the JiraServerRestManager.

I propose removing the complexity of the getManager() and instead just merging the 2:

export default class JiraServerTaskIntegrationManager
  extends TaskIntegrationManager, JiraServerRestManager

Note: extends vs. implements requires refactoring the TaskIntegrationManager to an abstract class. IMO abstract classes are cleaner than interfaces because it can lead to a single source of truth

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattkrick As I see, class in TypeScript can't extend 2 classes.

I also think JiraServerTaskIntegrationManager and JiraServerRestManager have different purposes.

JiraServerTaskIntegrationManager exposes a unified API that is defined by abstract class or interface.
All Integration managers extend same abstract class and expose same API, for example taskIntegrationManager.createTask

This way avoid a lot of if constructions here

const createTaskResponse = await taskIntegrationManager.createTask({
rawContentStr,
integrationRepoId,
createdBySomeoneElseComment,
context,
info
})

However, internally, createTask relies on different createTask APIs — for GitHub it is GraphQL mutation, for JiraServer it is JiraServerRestManager etc.
If I simply extend, then there will be no unified shape of manager API, unified shape of input and output.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, you're making a lot of sense. i'm all for making things non null wherever we can!
What if we invert the abstraction so we still only have 1 class that communicates with the service?

For example:

// Use an interface, just like your original, but no optional args on createTask!
interface TaskIntegrationManager {
  title: string

  createTask(params: {
    rawContentStr: string
    integrationRepoId: string
  }): Promise<CreateTaskResponse>
}

// The managers that talk to the service implement the TaskIntegrationManager
export default class JiraServerRestManager implements TaskIntegrationManager {
  constructor(auth, provider) {}
  createTask(str, repoId){}
}

// we grab the context, info in the constructor so methods like createTask don't need extra stuff
export default class GitHubServerManager implements TaskIntegrationManager {
  constructor(auth, provider, context, info) {}
  createTask(str, repoId){}
}

that way, our server managers can have all the wacky methods they want, but they'll still need to implement a few basic ones if they want to call themselves a TaskIntegrationManager

whatcha think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattkrick Yes, I think we may merge two classes (JiraServerRestManager and JiraServerTaskIntegrationManager) into one.

But in this case, the resulting class would expose different methods that sound similar. For example: createIssue which is just a REST API call wrapper, and createTask — above mentioned unified method that wraps REST API method and might include additional actions.

Is it OK?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think that's great!
if you wanna get fancy, the taskIntegrationFactory could return this Manager as a TaskIntegrationManager interface so those other methods will be hidden 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattkrick made some refactoring, can you take a look?

@mattkrick mattkrick mentioned this pull request Mar 16, 2022
3 tasks
@igorlesnenko
Copy link
Contributor Author

Made some fixes and little refactoring, including #6238

@igorlesnenko igorlesnenko requested a review from mattkrick March 23, 2022 21:23
@@ -5,7 +5,8 @@ import JiraSVG from './JiraSVG'

const iconLookup = {
_xGitHubIssue: GitHubSVG,
JiraIssue: JiraSVG
JiraIssue: JiraSVG,
JiraServerIssue: JiraSVG
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the logo on our instance of Jira Server, whatcha think?
jira-software-logo-jira-software-logo-11562914188wp8r59nt10

@igorlesnenko igorlesnenko requested a review from mattkrick March 24, 2022 03:22
if (
userId &&
viewerId !== userId &&
'addCreatedBySomeoneElseComment' in taskIntegrationManager
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i imagine this'll become non-null in the future, but happy to leave as is for now so we can get this big chunk merged master

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattkrick it is already non-null in the interface, so removing this check in my next PR

@mattkrick
Copy link
Member

wonderful stuff! the extra focus applied here to set the patterns should pay off when we repeat this pattern for the next integrations

@mattkrick mattkrick merged commit 4712bec into master Mar 25, 2022
@mattkrick mattkrick deleted the jira-server-create-task branch March 25, 2022 22:19
@github-actions github-actions bot mentioned this pull request Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jira Server: createTaskIntegration
3 participants