Closed medienbaecker closed 3 years ago
@afbora Is this the right way to do it? Anything I've overlooked? What's with backwards compatibility?
Thanks for any nudge in the right direction 👍
@medienbaecker The change you made for the language is correct.
There are two options for backward compatibility:
@afbora Thanks for the feedback, much appreciated!
With "checking Kirby version in the code" you mean something specific like this?
currentLanguage() {
if(this.$store.state.languages) {
return this.$store.state.languages.current;
}
return this.$language;
},
Yes checking this.$store.state.languages
variable make sense, so clever!
If you need version control in more places, you can get like that:
async kirbyVersion() {
const system = await this.$api.system.get();
return system.version;
}
if (this.kirbyVersion >= 3.6) {
// todo
} else {
// todo
}
@afbora Ah, that's so good to know. Thank you! ❤️
@medienbaecker Wait! Only those with system
permission can see the Kirby version. It will not work again for users who do not have this permission. Version control may be required for backward compatibility. For this, each plugin may need to create its own version control api. Let's ask that to @bastianallgeier @lukasbestle.
I feel like we shouldn't expose Kirby's version, it could be a security risk. Maybe we could expose a "plugin API version" like 3.6
without the patch version. But the specific check for object keys etc. like Thomas has implemented it is the best solution in any case.
With Kirby 3.6 the PageLink button tries to access
currentLanguage
which throws an error because the store has been changed.This pull request changes
this.$store.state.languages.current
tothis.$language
as suggested here: https://getkirby.com/releases/3.6/breaking-changes#panel__helpers-librariesRelated issue: https://github.com/sylvainjule/kirby-markdown-field/issues/116