fabianmichael / kirby-markdown-field

Super-sophisticated markdown editor for Kirby 3, community built.
Other
162 stars 14 forks source link

[next] Change language store, 3.6. compatibility #121

Closed medienbaecker closed 3 years ago

medienbaecker commented 3 years ago

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 to this.$language as suggested here: https://getkirby.com/releases/3.6/breaking-changes#panel__helpers-libraries

Related issue: https://github.com/sylvainjule/kirby-markdown-field/issues/116

medienbaecker commented 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 👍

afbora commented 3 years ago

@medienbaecker The change you made for the language is correct.

There are two options for backward compatibility:

medienbaecker commented 3 years ago

@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;
},
afbora commented 3 years ago

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
}
medienbaecker commented 3 years ago

@afbora Ah, that's so good to know. Thank you! ❤️

afbora commented 3 years ago

@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.

lukasbestle commented 3 years ago

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.