Skip to content

Commit

Permalink
Merge pull request #4434 from getkirby/fix/license
Browse files Browse the repository at this point in the history
New license dialog
  • Loading branch information
bastianallgeier authored Jun 27, 2022
2 parents 530f74e + 370a607 commit d210f26
Show file tree
Hide file tree
Showing 32 changed files with 91 additions and 5 deletions.
36 changes: 36 additions & 0 deletions config/areas/system/dialogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,42 @@
use Kirby\Toolkit\I18n;

return [
// license key
'license' => [
'load' => function () {
$license = App::instance()->system()->license();

// @codeCoverageIgnoreStart
// the system is registered but the license
// key is only visible for admins
if ($license === true) {
$license = 'Kirby 3';
}
// @codeCoverageIgnoreEnd

return [
'component' => 'k-form-dialog',
'props' => [
'size' => 'medium',
'fields' => [
'license' => [
'type' => 'info',
'label' => I18n::translate('license'),
'text' => $license ? $license : I18n::translate('license.unregistered.label'),
'theme' => $license ? 'code' : 'negative',
'help' => $license ?
// @codeCoverageIgnoreStart
'<a href="https://hub.getkirby.com">' . I18n::translate('license.manage') . ' &rarr;</a>' :
// @codeCoverageIgnoreEnd
'<a href="https://getkirby.com/buy">' . I18n::translate('license.buy') . ' &rarr;</a>'
]
],
'submitButton' => false,
'cancelButton' => false,
]
];
}
],
// license registration
'registration' => [
'load' => function () {
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "\u041b\u0438\u0446\u0435\u043d\u0437 \u0437\u0430 Kirby",
"license.buy": "Купи лиценз",
"license.register": "Регистрирай",
"license.manage": "Manage your licenses",
"license.register.help": "You received your license code after the purchase via email. Please copy and paste it to register.",
"license.register.label": "Please enter your license code",
"license.register.success": "Thank you for supporting Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Llic\u00e8ncia Kirby",
"license.buy": "Comprar una llicència",
"license.register": "Registrar",
"license.manage": "Manage your licenses",
"license.register.help": "Heu rebut el codi de la vostra llicència després de la compra, per correu electrònic. Copieu-lo i enganxeu-lo per registrar-vos.",
"license.register.label": "Si us plau, introdueixi el seu codi de llicència",
"license.register.success": "Gràcies per donar suport a Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Kirby licence",
"license.buy": "Zakoupit licenci",
"license.register": "Registrovat",
"license.manage": "Manage your licenses",
"license.register.help": "Licenční kód jste po zakoupení obdrželi na email. Vložte prosím kód a zaregistrujte Vaší kopii.",
"license.register.label": "Zadejte prosím licenční kód",
"license.register.success": "Děkujeme Vám za podporu Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Kirby licens",
"license.buy": "Køb en licens",
"license.register": "Registrer",
"license.manage": "Manage your licenses",
"license.register.help": "Du modtog din licenskode efter købet via email. Venligst kopier og indsæt den for at registrere.",
"license.register.label": "Indtast venligst din licenskode",
"license.register.success": "Tak for din støtte af Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Lizenz",
"license.buy": "Kaufe eine Lizenz",
"license.register": "Registrieren",
"license.manage": "Verwalte deine Lizenzen",
"license.register.help": "Den Lizenzcode findest du in der Bestätigungsmail zu deinem Kauf. Bitte kopiere und füge ihn ein, um Kirby zu registrieren.",
"license.register.label": "Bitte gib deinen Lizenzcode ein",
"license.register.success": "Vielen Dank für deine Unterstützung",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "\u0386\u03b4\u03b5\u03b9\u03b1 \u03a7\u03c1\u03ae\u03c3\u03b7\u03c2 \u03c4\u03bf\u03c5 Kirby",
"license.buy": "Αγοράστε μια άδεια",
"license.register": "Εγγραφή",
"license.manage": "Manage your licenses",
"license.register.help": "Έχετε λάβει τον κωδικό άδειας χρήσης μετά την αγορά μέσω ηλεκτρονικού ταχυδρομείου. Παρακαλώ αντιγράψτε και επικολλήστε τον για να εγγραφείτε.",
"license.register.label": "Παρακαλώ εισαγάγετε τον κωδικό άδειας χρήσης",
"license.register.success": "Σας ευχαριστούμε για την υποστήριξη του Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "License",
"license.buy": "Buy a license",
"license.register": "Register",
"license.manage": "Manage your licenses",
"license.register.help": "You received your license code after the purchase via email. Please copy and paste it to register.",
"license.register.label": "Please enter your license code",
"license.register.success": "Thank you for supporting Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/eo.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Permisilo",
"license.buy": "Aĉeti permisilon",
"license.register": "Registriĝi",
"license.manage": "Manage your licenses",
"license.register.help": "Vi ricevis vian kodon de permisilo retpoŝte, post aĉeti ĝin. Bonvolu kopii kaj alglui ĝin por registriĝi.",
"license.register.label": "Bonvolu entajpi vian kodon de permisilo",
"license.register.success": "Dankon pro subteni Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/es_419.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Licencia",
"license.buy": "Comprar una licencia",
"license.register": "Registrar",
"license.manage": "Manage your licenses",
"license.register.help": "Recibió su código de licencia después de la compra por correo electrónico. Por favor copie y pegue para registrarse.",
"license.register.label": "Por favor, ingresa tu código de licencia",
"license.register.success": "Gracias por apoyar a Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Licencia",
"license.buy": "Comprar una licencia",
"license.register": "Registro",
"license.manage": "Manage your licenses",
"license.register.help": "Recibió su código de licencia después de la compra por correo electrónico. Por favor copie y pegue para registrarse.",
"license.register.label": "Por favor ingrese su código de licencia",
"license.register.success": "Gracias por apoyar a Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "\u0645\u062c\u0648\u0632",
"license.buy": "خرید مجوز",
"license.register": "ثبت",
"license.manage": "Manage your licenses",
"license.register.help": "پس از خرید از طریق ایمیل، کد مجوز خود را دریافت کردید. لطفا برای ثبت‌نام آن را کپی و اینجا پیست کنید.",
"license.register.label": "لطفا کد مجوز خود را وارد کنید",
"license.register.success": "با تشکر از شما برای حمایت از کربی",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Lisenssi",
"license.buy": "Osta lisenssi",
"license.register": "Rekisteröi",
"license.manage": "Manage your licenses",
"license.register.help": "Lisenssiavain on lähetetty oston jälkeen sähköpostiisi. Kopioi ja liitä avain tähän.",
"license.register.label": "Anna lisenssiavain",
"license.register.success": "Kiitos kun tuet Kirbyä",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Licence",
"license.buy": "Acheter une licence",
"license.register": "S’enregistrer",
"license.manage": "Manage your licenses",
"license.register.help": "Vous avez reçu votre numéro de licence par courriel après l'achat. Veuillez le copier et le coller ici pour l'enregistrer.",
"license.register.label": "Veuillez saisir votre numéro de licence",
"license.register.success": "Merci pour votre soutien à Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Kirby licenc",
"license.buy": "Licenc vásárlása",
"license.register": "Regisztráció",
"license.manage": "Manage your licenses",
"license.register.help": "A vásárlás után emailben küldjük el a licenc-kódot. Regisztrációhoz másold ide a kapott kódot.",
"license.register.label": "Kérlek írd be a licenc-kódot",
"license.register.success": "Köszönjük, hogy támogatod a Kirby-t",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Lisensi Kirby",
"license.buy": "Beli lisensi",
"license.register": "Daftar",
"license.manage": "Manage your licenses",
"license.register.help": "Anda menerima kode lisensi via surel setelah pembelian. Salin dan tempel kode tersebut untuk mendaftarkan.",
"license.register.label": "Masukkan kode lisensi Anda",
"license.register.success": "Terima kasih atas dukungan untuk Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/is_IS.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Leyfi",
"license.buy": "Kaupa leyfi",
"license.register": "Skr\u00E1 Kirby",
"license.manage": "Manage your licenses",
"license.register.help": "Þú fékkst sendan tölvupóst með leyfiskóðanum þegar þú keyptir leyfi. Vinsamlegast afritaðu hann og settu hann hingað til að skrá þig.",
"license.register.label": "Vinsamlegast settu inn leyfiskóðan",
"license.register.success": "Þakka þér fyrir að velja Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Licenza di Kirby",
"license.buy": "Acquista una licenza",
"license.register": "Registra",
"license.manage": "Manage your licenses",
"license.register.help": "Hai ricevuto il codice di licenza tramite email dopo l'acquisto. Per favore inseriscilo per registrare Kirby.",
"license.register.label": "Inserisci il codice di licenza",
"license.register.success": "Ti ringraziamo per aver supportato Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "라이선스",
"license.buy": "라이선스 구매",
"license.register": "등록",
"license.manage": "Manage your licenses",
"license.register.help": "Kirby를 등록하려면 이메일로 전송받은 라이선스 코드와 이메일 주소를 입력하세요.",
"license.register.label": "라이선스 코드를 입력하세요.",
"license.register.success": "Kirby와 함께해주셔서 감사합니다.",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/lt.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Licenzija",
"license.buy": "Pirkti licenziją",
"license.register": "Registruoti",
"license.manage": "Manage your licenses",
"license.register.help": "Licenzijos kodą gavote el. paštu po apmokėjimo. Prašome įterpti čia, kad sistema būtų užregistruota.",
"license.register.label": "Prašome įrašyti jūsų licenzijos kodą",
"license.register.success": "Ačiū, kad palaikote Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Kirby lisens",
"license.buy": "Kjøp lisens",
"license.register": "Registrer",
"license.manage": "Manage your licenses",
"license.register.help": "Du skal ha mottatt din lisenskode for kjøpet via e-post. Vennligst kopier og lim inn denne for å registrere deg.",
"license.register.label": "Vennligst skriv inn din lisenskode",
"license.register.success": "Takk for at du støtter Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Licentie",
"license.buy": "Koop een licentie",
"license.register": "Registreren",
"license.manage": "Manage your licenses",
"license.register.help": "Je hebt de licentie via e-mail gekregen nadat je de aankoop hebt gedaan. Kopieer en plak de licentie om te registreren. ",
"license.register.label": "Vul je licentie in",
"license.register.success": "Bedankt dat je Kirby ondersteunt",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Licencja",
"license.buy": "Kup licencję",
"license.register": "Zarejestruj",
"license.manage": "Manage your licenses",
"license.register.help": "Po zakupieniu licencji otrzymałaś/-eś mailem klucz. Skopiuj go i wklej tutaj, aby dokonać rejestracji.",
"license.register.label": "Wprowadź swój kod licencji",
"license.register.success": "Dziękujemy za wspieranie Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Licen\u00e7a do Kirby ",
"license.buy": "Comprar licença",
"license.register": "Registrar",
"license.manage": "Manage your licenses",
"license.register.help": "Você recebeu o código da sua licença por email ao efetuar sua compra. Por favor, copie e cole o código para completar seu registro.",
"license.register.label": "Por favor, digite o código da sua licença",
"license.register.success": "Obrigado por apoiar o Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/pt_PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Licen\u00e7a do Kirby ",
"license.buy": "Comprar uma licença",
"license.register": "Registrar",
"license.manage": "Manage your licenses",
"license.register.help": "Recebeu o código da sua licença por email após a compra. Por favor, copie e cole-o para completar o registro.",
"license.register.label": "Por favor, digite o código da sua licença",
"license.register.success": "Obrigado por apoiar o Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Лицензия",
"license.buy": "Купить лицензию",
"license.register": "Зарегистрировать",
"license.manage": "Manage your licenses",
"license.register.help": "После покупки вы получили по эл. почте код лицензии. Пожалуйста скопируйте и вставьте сюда чтобы зарегистрировать.",
"license.register.label": "Пожалуйста вставьте код лицензии",
"license.register.success": "Спасибо за поддержку Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/sk.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Licencia",
"license.buy": "Zakúpiť licenciu",
"license.register": "Registrovať",
"license.manage": "Manage your licenses",
"license.register.help": "Licenčný kód vám bol doručený e-mailom po úspešnom nákupe. Prosím, skopírujte a prilepte ho na uskutočnenie registrácie.",
"license.register.label": "Prosím, zadajte váš licenčný kód",
"license.register.success": "Ďakujeme za vašu podporu Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/sv_SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Licens",
"license.buy": "Köp en licens",
"license.register": "Registrera",
"license.manage": "Manage your licenses",
"license.register.help": "Du fick din licenskod via e-post efter inköpet. Kopiera och klistra in den för att registrera licensen.",
"license.register.label": "Ange din licenskod",
"license.register.success": "Tack för att du stödjer Kirby",
Expand Down
1 change: 1 addition & 0 deletions i18n/translations/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@
"license": "Lisans",
"license.buy": "Bir lisans satın al",
"license.register": "Kayıt Ol",
"license.manage": "Manage your licenses",
"license.register.help": "Satın alma işleminden sonra e-posta yoluyla lisans kodunuzu aldınız. Lütfen kayıt olmak için kodu kopyalayıp yapıştırın.",
"license.register.label": "Lütfen lisans kodunu giriniz",
"license.register.success": "Kirby'yi desteklediğiniz için teşekkürler",
Expand Down
2 changes: 1 addition & 1 deletion panel/dist/js/index.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions panel/src/components/Views/SystemView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ export default {
return [
{
label: this.$t("license"),
value: this.$license
? this.license
value: this.license
? "Kirby 3"
: this.$t("license.unregistered.label"),
theme: this.$lincense ? null : "negative",
click: this.$lincense ? null : () => this.$dialog("registration")
theme: this.license ? null : "negative",
click: this.license
? () => this.$dialog("license")
: () => this.$dialog("registration")
},
{
label: this.$t("version"),
Expand Down
20 changes: 20 additions & 0 deletions tests/Panel/Areas/SystemDialogsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@ public function setUp(): void
$this->login();
}

public function testLicense(): void
{
$dialog = $this->dialog('license');
$props = $dialog['props'];

$this->assertFormDialog($dialog);

$field = $props['fields']['license'];

$this->assertSame('info', $field['type']);
$this->assertSame('License', $field['label']);
$this->assertSame('Unregistered', $field['text']);
$this->assertSame('negative', $field['theme']);
$this->assertSame('<a href="https://getkirby.com/buy">Buy a license &rarr;</a>', $field['help']);

$this->assertSame('medium', $props['size']);
$this->assertFalse($props['submitButton']);
$this->assertFalse($props['cancelButton']);
}

public function testRegistration(): void
{
$dialog = $this->dialog('registration');
Expand Down

0 comments on commit d210f26

Please sign in to comment.