dendronhq / dendron

The personal knowledge management (PKM) tool that grows as you do!
https://wiki.dendron.so
Apache License 2.0
6.53k stars 247 forks source link

enhance(create): show error when applying template but no template found #3881

Closed tlylt closed 1 year ago

tlylt commented 1 year ago

First Time Specifics

Code

I decided to change the condition in QuickPickTemplateSelector.ts to capture the case where the template is not found and return undefined from there. It is also possible to make that change downstream in ApplyTemplateCommand.ts (line 61) with something like:

    if (_.isUndefined(templateNote) || templateNote?.children.length === 0) {
      throw new DendronError({ message: `Template not found` });
    }

Similar to the existing logic when template is undefined, template not found will now trigger an error message. Let me know if there's any issue with the current approach.

Tests

I adjusted some code in the integration tests for apply template to add a case for template not found. Not sure if it's the best way to do it so please let me know if it needs to be updated.

Manual test: image

Docs

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.