ChangelogModal.svelte 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <script lang="ts">
  2. import { onMount, getContext } from 'svelte';
  3. import { Confetti } from 'svelte-confetti';
  4. import { WEBUI_NAME, config, settings } from '$lib/stores';
  5. import { WEBUI_VERSION } from '$lib/constants';
  6. import { getChangelog } from '$lib/apis';
  7. import Modal from './common/Modal.svelte';
  8. import { updateUserSettings } from '$lib/apis/users';
  9. const i18n = getContext('i18n');
  10. export let show = false;
  11. let changelog = null;
  12. onMount(async () => {
  13. const res = await getChangelog();
  14. changelog = res;
  15. });
  16. </script>
  17. <Modal bind:show size="lg">
  18. <div class="px-5 pt-4 dark:text-gray-300 text-gray-700">
  19. <div class="flex justify-between items-start">
  20. <div class="text-xl font-semibold">
  21. {$i18n.t("What's New in")}
  22. {$WEBUI_NAME}
  23. <Confetti x={[-1, -0.25]} y={[0, 0.5]} />
  24. </div>
  25. <button
  26. class="self-center"
  27. on:click={() => {
  28. localStorage.version = $config.version;
  29. show = false;
  30. }}
  31. >
  32. <svg
  33. xmlns="http://www.w3.org/2000/svg"
  34. viewBox="0 0 20 20"
  35. fill="currentColor"
  36. class="w-5 h-5"
  37. >
  38. <p class="sr-only">{$i18n.t('Close')}</p>
  39. <path
  40. d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"
  41. />
  42. </svg>
  43. </button>
  44. </div>
  45. <div class="flex items-center mt-1">
  46. <div class="text-sm dark:text-gray-200">{$i18n.t('Release Notes')}</div>
  47. <div class="flex self-center w-[1px] h-6 mx-2.5 bg-gray-200 dark:bg-gray-700" />
  48. <div class="text-sm dark:text-gray-200">
  49. v{WEBUI_VERSION}
  50. </div>
  51. </div>
  52. </div>
  53. <div class=" w-full p-4 px-5 text-gray-700 dark:text-gray-100">
  54. <div class=" overflow-y-scroll max-h-96 scrollbar-hidden">
  55. <div class="mb-3">
  56. {#if changelog}
  57. {#each Object.keys(changelog) as version}
  58. <div class=" mb-3 pr-2">
  59. <div class="font-semibold text-xl mb-1 dark:text-white">
  60. v{version} - {changelog[version].date}
  61. </div>
  62. <hr class="border-gray-100 dark:border-gray-850 my-2" />
  63. {#each Object.keys(changelog[version]).filter((section) => section !== 'date') as section}
  64. <div class="">
  65. <div
  66. class="font-semibold uppercase text-xs {section === 'added'
  67. ? 'text-white bg-blue-600'
  68. : section === 'fixed'
  69. ? 'text-white bg-green-600'
  70. : section === 'changed'
  71. ? 'text-white bg-yellow-600'
  72. : section === 'removed'
  73. ? 'text-white bg-red-600'
  74. : ''} w-fit px-3 rounded-full my-2.5"
  75. >
  76. {section}
  77. </div>
  78. <div class="my-2.5 px-1.5">
  79. {#each Object.keys(changelog[version][section]) as item}
  80. <div class="text-sm mb-2">
  81. <div class="font-semibold uppercase">
  82. {changelog[version][section][item].title}
  83. </div>
  84. <div class="mb-2 mt-1">{changelog[version][section][item].content}</div>
  85. </div>
  86. {/each}
  87. </div>
  88. </div>
  89. {/each}
  90. </div>
  91. {/each}
  92. {/if}
  93. </div>
  94. </div>
  95. <div class="flex justify-end pt-3 text-sm font-medium">
  96. <button
  97. on:click={async () => {
  98. localStorage.version = $config.version;
  99. await settings.set({ ...$settings, ...{ version: $config.version } });
  100. await updateUserSettings(localStorage.token, { ui: $settings });
  101. show = false;
  102. }}
  103. class="px-3.5 py-1.5 text-sm font-medium bg-black hover:bg-gray-900 text-white dark:bg-white dark:text-black dark:hover:bg-gray-100 transition rounded-full"
  104. >
  105. <span class="relative">{$i18n.t("Okay, Let's Go!")}</span>
  106. </button>
  107. </div>
  108. </div>
  109. </Modal>