|
| 1 | +<script setup lang="ts"> |
| 2 | +import { onMounted, ref, computed } from 'vue'; |
| 3 | +import { useStore } from 'vuex'; |
| 4 | +import { MANAGEMENT } from '@shell/config/types'; |
| 5 | +import { getVendor } from '@shell/config/private-label'; |
| 6 | +
|
| 7 | +const store = useStore(); |
| 8 | +
|
| 9 | +const version = ref<any>(null); |
| 10 | +const settings = ref<any[]>([]); |
| 11 | +
|
| 12 | +const t = store.getters['i18n/t']; |
| 13 | +
|
| 14 | +const aboutVersionsComponentString = computed(() => t('about.versions.component')); |
| 15 | +const aboutTitleString = computed(() => t('about.title')); |
| 16 | +const aboutVersionsVersionString = computed(() => t('about.versions.version')); |
| 17 | +const aboutDownloadCLIString = computed(() => t('about.downloadCLI.title')); |
| 18 | +const allPackagesString = computed(() => t('epinio.about.allPackages')); |
| 19 | +
|
| 20 | +
|
| 21 | +const fetchData = async () => { |
| 22 | + settings.value = await store.dispatch(`management/findAll`, { type: MANAGEMENT.SETTING }); |
| 23 | + version.value = await store.dispatch('epinio/version'); |
| 24 | +}; |
| 25 | +
|
| 26 | +onMounted(fetchData); |
| 27 | +
|
| 28 | +const appName = computed(() => { |
| 29 | + const isSingleProduct = !!store.getters['isSingleProduct']; |
| 30 | + return isSingleProduct ? getVendor() : t('epinio.label'); |
| 31 | +}); |
| 32 | +
|
| 33 | +function createOSOption(label: string, icon: string, cliLink: string, imageList: any = null) { |
| 34 | + const slash = cliLink?.lastIndexOf('/'); |
| 35 | + return { |
| 36 | + label, |
| 37 | + icon, |
| 38 | + imageList, |
| 39 | + cliLink, |
| 40 | + cliFile: slash >= 0 ? cliLink.substr(slash + 1) : cliLink |
| 41 | + }; |
| 42 | +} |
| 43 | +
|
| 44 | +const downloads = computed(() => { |
| 45 | + if (!version.value) { |
| 46 | + return []; |
| 47 | + } |
| 48 | +
|
| 49 | + const gitUrl = `https://github.com/epinio/epinio/releases/download`; |
| 50 | + const versionStr = version.value.displayVersion; |
| 51 | + const app = appName.value.toLowerCase(); |
| 52 | +
|
| 53 | + return [ |
| 54 | + createOSOption('about.os.mac', 'icon-apple', `${gitUrl}/${versionStr}/${app}-darwin-x86_64`), |
| 55 | + createOSOption('about.os.linux', 'icon-linux', `${gitUrl}/${versionStr}/${app}-linux-x86_64`, downloadLinuxImages), |
| 56 | + createOSOption('about.os.windows', 'icon-windows', `${gitUrl}/${versionStr}/${app}-windows-x86_64.zip`) |
| 57 | + ]; |
| 58 | +}); |
| 59 | +
|
| 60 | +const downloadLinuxImages = null; |
| 61 | +
|
| 62 | +const versionString = computed(() => { |
| 63 | + if (!version.value) return ''; |
| 64 | + if (version.value.displayVersion === version.value.fullVersion) { |
| 65 | + return version.value.displayVersion; |
| 66 | + } |
| 67 | + return version.value.fullVersion; |
| 68 | +}); |
| 69 | +
|
| 70 | +</script> |
| 71 | + |
| 72 | +<template> |
| 73 | + <div class="about"> |
| 74 | + <template v-if="version"> |
| 75 | + <h1> |
| 76 | + {{ aboutTitleString }} |
| 77 | + </h1> |
| 78 | + <table> |
| 79 | + <thead> |
| 80 | + <tr> |
| 81 | + <th>{{ aboutVersionsComponentString }}</th> |
| 82 | + <th>{{ aboutVersionsVersionString }}</th> |
| 83 | + </tr> |
| 84 | + </thead> |
| 85 | + <tr v-if="version"> |
| 86 | + <td> |
| 87 | + <a |
| 88 | + href="https://github.com/epinio/epinio" |
| 89 | + target="_blank" |
| 90 | + rel="nofollow noopener noreferrer" |
| 91 | + > |
| 92 | + {{ appName }} |
| 93 | + </a> |
| 94 | + </td> |
| 95 | + <td>{{ versionString }}</td> |
| 96 | + </tr> |
| 97 | + </table> |
| 98 | + </template> |
| 99 | + |
| 100 | + <template v-if="version && downloads.length"> |
| 101 | + <h3 class="pt-40"> |
| 102 | + {{ aboutDownloadCLIString }} |
| 103 | + </h3> |
| 104 | + <table> |
| 105 | + <tr |
| 106 | + v-for="d in downloads" |
| 107 | + :key="d.icon" |
| 108 | + class="link" |
| 109 | + > |
| 110 | + <td> |
| 111 | + <div class="os"> |
| 112 | + <i :class="`icon ${d.icon} mr-5`" /> {{ t(d.label) }} |
| 113 | + </div> |
| 114 | + </td> |
| 115 | + <td> |
| 116 | + <a |
| 117 | + v-if="d.cliLink" |
| 118 | + :href="d.cliLink" |
| 119 | + >{{ d.cliFile }}</a> |
| 120 | + </td> |
| 121 | + </tr> |
| 122 | + </table> |
| 123 | + </template> |
| 124 | + |
| 125 | + <template v-if="version"> |
| 126 | + <a |
| 127 | + class="mt-5" |
| 128 | + target="_blank" |
| 129 | + :href="`https://github.com/epinio/epinio/releases/tag/${version.displayVersion}`" |
| 130 | + > |
| 131 | + {{ allPackagesString }} |
| 132 | + </a> |
| 133 | + </template> |
| 134 | + </div> |
| 135 | +</template> |
| 136 | + |
| 137 | +<style lang="scss" scoped> |
| 138 | +.about { |
| 139 | + table { |
| 140 | + border-collapse: collapse; |
| 141 | + overflow: hidden; |
| 142 | + border-radius: var(--border-radius); |
| 143 | +
|
| 144 | + tr > td:first-of-type { |
| 145 | + width: 20%; |
| 146 | + } |
| 147 | +
|
| 148 | + th, td { |
| 149 | + border: 1px solid var(--border); |
| 150 | + padding: 8px 5px; |
| 151 | + min-width: 150px; |
| 152 | + text-align: left; |
| 153 | + } |
| 154 | +
|
| 155 | + th { |
| 156 | + background-color: var(--sortable-table-top-divider); |
| 157 | + border-bottom: 1px solid var(--sortable-table-top-divider); |
| 158 | + } |
| 159 | +
|
| 160 | + a { |
| 161 | + cursor: pointer; |
| 162 | + } |
| 163 | +
|
| 164 | + .os { |
| 165 | + display: flex; |
| 166 | + align-items: center; |
| 167 | + } |
| 168 | + } |
| 169 | +} |
| 170 | +</style> |
0 commit comments