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

Use extension names instead of IDs when erroring on enable/disable reqs #2563

Merged
merged 7 commits into from Jan 29, 2021

Conversation

dsevillamartin
Copy link
Member

@dsevillamartin dsevillamartin commented Jan 23, 2021

Fixes #2341

Changes proposed in this pull request:

  • Use extension name where available
  • Create Extension@getTitle method
  • Create ExtensionManager::pluckTitles method

image

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).

ORIGINAL DESCRIPTION

Changes needed:

Is there a better way to obtain the extension name? I assume we also want to change the extension to use its name (apart from dependencies/dependents) in error message, but this is a lot of duplicated code.
Not sure if we want to have a fallback to ID in case title doesn't exist.
I'm surprised the Extension class doesn't have a method to obtain the extension title.

Reviewers should focus on:

  • Should the method name be renamed? Could technically be a breaking change
  • Should these 2 methods be condensed into 1 in a separate class? The logic is the exact same.

@askvortsov1
Copy link
Sponsor Member

Is there a use case for the old method outside of this? If no, I say it's fine.

Maybe we could move them to a static util method on ExtensionManager to avoid duplication?

@SychO9
Copy link
Member

SychO9 commented Jan 24, 2021

I'm surprised the Extension class doesn't have a method to obtain the extension title.

I would be in favour of introducing that method here, and using it in the codebase (there should be 4 spots in total with this PR)

Should these 2 methods be condensed into 1 in a separate class? The logic is the exact same.

I think it's fine to leave it as is, I feel like it'd be overdoing it.

@dsevillamartin
Copy link
Member Author

dsevillamartin commented Jan 24, 2021

@askvortsov1

Is there a use case for the old method outside of this? If no, I say it's fine.

Maybe we could move them to a static util method on ExtensionManager to avoid duplication?

Not sure what you mean exactly with the second.

EDIT: Oh, to pass Extension[] and return string[] of titles/IDs


@SychO9

I would be in favour of introducing that method here, and using it in the codebase (there should be 4 spots in total with this PR)

I assume this would look something like getTitle() and return the title OR extension ID if the title doesn't exist, as a fallback?

@dsevillamartin
Copy link
Member Author

How do the added Extension@getTitle and ExtensionManager::pluckTitles methods look? I also replaced other instances of the composer attribute with the getTitle() method - but in separate commit so it's easier to review (not that there's much).

@askvortsov1
Copy link
Sponsor Member

Looks good to me!

@dsevillamartin dsevillamartin marked this pull request as ready for review January 27, 2021 20:49
@askvortsov1 askvortsov1 merged commit 843daf6 into master Jan 29, 2021
@askvortsov1 askvortsov1 deleted the ds/2341-use-extension-names-not-ids-in-error branch January 29, 2021 00:41
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.

Show extension titles instead of IDs for dependency error messages
3 participants