1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-07-16 00:14:34 +02:00

Desktop: Fixes #8898: Show a gear when a plugin doesn't specify an icon (#8909)

This commit is contained in:
Henry Heino
2023-09-19 03:29:19 -07:00
committed by GitHub
parent 06130a8e9a
commit ec7f5aaf9b
2 changed files with 35 additions and 1 deletions

View File

@ -262,5 +262,39 @@ describe('services_CommandService', () => {
await expectNotThrow(async () => service.isEnabled('test1', { cond1: true, cond2: false }));
}));
it('commands should allow specifying an icon', () => {
const service = newService();
const iconName = 'fas fa-check';
registerCommand(service, {
declaration: {
name: 'test-command-with-icon',
label: 'Adding icons to commands',
iconName,
},
runtime: {
execute: async () => {},
},
});
const command = service.commandByName('test-command-with-icon');
expect(command.declaration.iconName).toBe(iconName);
});
it('commands should have a non-empty default icon', () => {
const service = newService();
registerCommand(service, {
declaration: {
name: 'test1',
label: 'Test toolbar icon',
},
runtime: {
execute: async () => {},
},
});
const command = service.commandByName('test1');
expect(command.declaration.iconName).toBe('fas fa-cog');
});
});

View File

@ -182,7 +182,7 @@ export default class CommandService extends BaseService {
public registerDeclaration(declaration: CommandDeclaration) {
declaration = { ...declaration };
if (!declaration.label) declaration.label = '';
if (!declaration.iconName) declaration.iconName = '';
if (!declaration.iconName) declaration.iconName = 'fas fa-cog';
this.commands_[declaration.name] = {
declaration: declaration,