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

Desktop: Resolves #6143: Add Installed Plugins in "About Joplin" #6357

Closed
wants to merge 11 commits into from

Conversation

krishna8421
Copy link
Contributor

This PR resolves #6143

I didn't Add the 20 Limit cos the Menu itself adds a scrollbar when it.

For reference, I added some screenshots with 50 plugins.

Mac:
Screenshot 2022-04-02 at 2 58 33 AM
Screenshot 2022-04-02 at 2 58 59 AM

Windows:
Screenshot 2022-04-01 142227
Screenshot 2022-04-01 142357


describe('versionInfo', function() {

it('should return an array', (()=>{
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you add return type annotation to getPluginsArr then this test becomes useless

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 will remove the test and add types to the function

expect(plugins.length).toBe(0);
}));

it('should not push plugin to body if no plugin is found',(()=>{
Copy link
Collaborator

Choose a reason for hiding this comment

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

This test is not really doing anything meaningful as it never calls any code that is used by Joplin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you suggest any test case that I should Add?
I am having confusion about testing the file without any plugins in the test environment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Essentially you have a function from Plugins to string - this is all you need to test. When running in Joplin Plugins will be provided by the PluginService but in your test you can set the value manually and use it for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added New Tests


describe('versionInfo', function() {

it('should not push plugin to body if no plugin is found',() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand what this test is doing.
If it's checking getPluginsArr then why do you need the rest remaining code ('if' and 'map')? If it's checking the logic inside the if then what's point of checking it when this code is only used here in this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point, I'll remove that too.

@@ -32,6 +52,14 @@ export default function versionInfo(packageInfo: any) {
console.info(gitInfo);
}

const plugins = getPluginsArr(PluginService.instance().plugins);
if (plugins.length > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not just move this code inside the getPluginsArr function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The gitInfo push to the body was down there so I thought to leave same types of items at a similar palace, also getPluginsArr just take the obj and return the array we need.

Should I change it?

@@ -32,6 +52,14 @@ export default function versionInfo(packageInfo: any) {
console.info(gitInfo);
}

const plugins = getPluginsArr(PluginService.instance().plugins);
Copy link
Owner

Choose a reason for hiding this comment

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

From where versionInfo() is called, you already have the list of plugins in props.plugins, so you don't need to load the PluginService here. Just pass props.plugins to this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

props.plugins returns this with type of PluginState:
Screenshot 2022-04-03 at 8 38 20 PM

});
}
return plugins;
};
Copy link
Owner

Choose a reason for hiding this comment

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

I don't understand the purpose of this function. You're looping on the array to create a new array. Then later you loop on this new array to create the plugin strings. So why not eliminate this intermediate step and loop on the first array to directly create the plugin strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PluginService.instance().plugins gives an object(with all plugins also as object) with id as the key, so I converted it to an array of objects and fill the array with only the name and version of the plugin.

expect(plugins[1].version).toBe('0.2.1');
});

});
Copy link
Owner

Choose a reason for hiding this comment

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

None of this feels very useful. getPluginsArr is just a "for" loop and we assume that loops work. What you should test instead is the versionInfo() function - make sure that when there are plugins, it includes them in the output of the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, I'll add it.

@laurent22
Copy link
Owner

Sorry I'm not very keen on merging this.

@krishna8421
Copy link
Contributor Author

Any specific reason. Should I have to add something else?

@krishna8421 krishna8421 closed this May 2, 2022
@krishna8421 krishna8421 deleted the plugin-in-about branch May 2, 2022 06:34
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.

Desktop: Show installed plugins in Help - About Joplin
3 participants