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

Issue #305: add check if slack panel is visible to prevent unnecessar… #332

Open
wants to merge 4 commits into
base: release-1.x
Choose a base branch
from

Conversation

annapieper
Copy link

No description provided.

Copy link
Contributor

@mvlasovatl mvlasovatl left a comment

Choose a reason for hiding this comment

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

@AnnaPiper Thank you for the submission!
Please see and address some comments.

@@ -42,7 +42,7 @@
<atlassian-json-api.version>0.9</atlassian-json-api.version>
<atlassian-concurrent.version>3.0.0</atlassian-concurrent.version>
<commons-codec.version>1.11</commons-codec.version>
<slack.common.version>1.1.13</slack.common.version>
<slack.common.version>1.1.14</slack.common.version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Versions of common modules aren't changed in this repo. Please roll back this change here and in other pom.xmls.

At the very beginning of work on plugin the team tried it, but then stopped. It appeared to be quite error prone and hard to manage that many different versions. Instead we don't publish common packages separately, only as part of a plugin. It makes code reuse between modules easier much. Once a change is done to a common module, just install it with the same version to the local repository and it's ready to be used in other modules.

</parent>

<groupId>com.atlassian.jira.plugins</groupId>
<artifactId>jira-slack-server-integration-plugin</artifactId>
<packaging>atlassian-plugin</packaging>
<version>3.0.10-SNAPSHOT</version>
<version>3.0.11-SNAPSHOT</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

This version of the plugin module is updated only on release by Maven Release plugin. Please roll it back.

});
var $issuePanel = $("#slack-issue-panel");
if (!issueKey || !$issuePanel.length) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than modifying the whole function to be a no-op, I'd recommend to prevent calling this function altogether. It would be less changes and the logic flow would be clearer.

Copy link
Author

Choose a reason for hiding this comment

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

I basically just added another condition to the already existing one that checks for the issueKey. Because getTemplate() is called 2 times it would be more code moving the condition out of the function. But if you want I can do the check before each function call.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed. I agree. Then it may stay as it is.

}
function isSlackPanelVisible() {
return $("#slack-issue-panel").length;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to prevent duplication of these functions in multiple files?
Also, since it isn't Typescript, let's be more strict regarding types. The functions follow Java naming convention for boolean-returning function, so let's convert returned values to booleans to prevent ambiguities.

Copy link
Author

Choose a reason for hiding this comment

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

I also thought about that duplicated code but I didn't find out how to do it because the two JS files are located in separate apps. Do you have an idea?

Agree on the prevention of ambiguitites.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see what you mean. This file is located in the common module, while other 2 ones are in Jira plugin module.
Ok, then some duplication is acceptable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also add a comment for these functions mentioning that they are expected to return true only when they are used in Jira plugin?
This file is also included into Confuence plugin descriptor and will be called there as well. The functions will return false there always, because there will be no elements with Jira-plugin-specific IDs on a Confluence page. It's better to keep this detail saved in a comment, then to learn it from debugging years later.

@@ -11,9 +11,10 @@ require([
var flag = null;

$(function () {
// skip if user is already in configuration view or edit pages
// skip if user is already in configuration view or edit pages or in issue view without active slack integration
Copy link
Contributor

Choose a reason for hiding this comment

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

The wording is technically incorrect here. What your meant probably is "or issue panel isn't shown".

@annapieper
Copy link
Author

@mvlasovatl I added the requested changes. If you still see problems with the versions let me know or maybe fix them by yourself as you know better where to put which version.

Copy link
Contributor

@mvlasovatl mvlasovatl left a comment

Choose a reason for hiding this comment

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

fix them by yourself

I suspect that's not how contributions work on Github :) Reviewers review, contributors contribute.
I added a couple more minor comments. Please take a look at them too.

@@ -6,7 +6,7 @@
<parent>
<artifactId>confluence-slack-integration</artifactId>
<groupId>com.atlassian.plugins</groupId>
<version>1.1.13</version>
<version>1.1.14</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

I am sorry for the confusion. All changes in pom.xml files in all modules need to be reverted. I just got used to thinking about repository modules as about 2 big groups: plugin and common modules. That's why I left just 2 comments - one comment for each group of changes.

}
function isSlackPanelVisible() {
return $("#slack-issue-panel").length;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also add a comment for these functions mentioning that they are expected to return true only when they are used in Jira plugin?
This file is also included into Confuence plugin descriptor and will be called there as well. The functions will return false there always, because there will be no elements with Jira-plugin-specific IDs on a Confluence page. It's better to keep this detail saved in a comment, then to learn it from debugging years later.

@mvlasovatl
Copy link
Contributor

Closer review revealed that only change in issuepanel-init.js may be applied without breaking other features. It properly prevents loading issue mentions data if issue panel is hidden.

update-slack-link-banner.js is responsible for showing a banner to an Admin when some workspace connection gets broken. This feature isn't related to issue panel in any way and shouldn't be disabled on all other pages. It may indeed generate some redundant traffic, but assuming that it affects only admins and that the request response has no body if all connections are good, it should be an acceptable price for proactive failure notification. So, changes in this file are to be reverted.

Code in token-status.js is responsible for warning a user when their authentication gets broken and if workspace connections get broken. It looks like it includes the logic from from update-slack-link-banner.js and adds even more information. I need to discuss this duplication with original developers. For now we may limit changes in this PR to issue mentions data loading prevention and maybe get back to duplicated endpoints later. Changes here are also to be reverted.

@annapieper
Copy link
Author

Thanks for the information. Let me know when you discussed it and came to a decision. I reverted the changes as requested.

… they may have unindented impact on other functionality
@yevhenhr yevhenhr deleted the branch atlassian-labs:release-1.x April 16, 2024 11:42
@yevhenhr yevhenhr closed this Apr 16, 2024
@yevhenhr yevhenhr reopened this Apr 16, 2024
@yevhenhr yevhenhr changed the base branch from dev to release-1.x May 19, 2024 23:05
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.

3 participants