You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AppDetails.vue 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <!--
  2. - @copyright Copyright (c) 2018 Julius Härtl <jus@bitgrid.net>
  3. -
  4. - @author Julius Härtl <jus@bitgrid.net>
  5. -
  6. - @license GNU AGPL version 3 or any later version
  7. -
  8. - This program is free software: you can redistribute it and/or modify
  9. - it under the terms of the GNU Affero General Public License as
  10. - published by the Free Software Foundation, either version 3 of the
  11. - License, or (at your option) any later version.
  12. -
  13. - This program is distributed in the hope that it will be useful,
  14. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. - GNU Affero General Public License for more details.
  17. -
  18. - You should have received a copy of the GNU Affero General Public License
  19. - along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. -
  21. -->
  22. <template>
  23. <div id="app-details-view" style="padding: 20px;">
  24. <h2>
  25. <div v-if="!app.preview" class="icon-settings-dark" />
  26. <svg v-if="app.previewAsIcon && app.preview"
  27. width="32"
  28. height="32"
  29. viewBox="0 0 32 32">
  30. <defs><filter :id="filterId"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0" /></filter></defs>
  31. <image x="0"
  32. y="0"
  33. width="32"
  34. height="32"
  35. preserveAspectRatio="xMinYMin meet"
  36. :filter="filterUrl"
  37. :xlink:href="app.preview"
  38. class="app-icon" />
  39. </svg>
  40. {{ app.name }}
  41. </h2>
  42. <img v-if="app.screenshot" :src="app.screenshot" width="100%">
  43. <div v-if="app.level === 300 || app.level === 200 || hasRating" class="app-level">
  44. <span v-if="app.level === 300"
  45. v-tooltip.auto="t('settings', 'This app is supported via your current Nextcloud subscription.')"
  46. class="supported icon-checkmark-color">
  47. {{ t('settings', 'Supported') }}</span>
  48. <span v-if="app.level === 200"
  49. v-tooltip.auto="t('settings', 'Official apps are developed by and within the community. They offer central functionality and are ready for production use.')"
  50. class="official icon-checkmark">
  51. {{ t('settings', 'Official') }}</span>
  52. <AppScore v-if="hasRating" :score="app.appstoreData.ratingOverall" />
  53. </div>
  54. <div v-if="author" class="app-author">
  55. {{ t('settings', 'by') }}
  56. <span v-for="(a, index) in author" :key="index">
  57. <a v-if="a['@attributes'] && a['@attributes']['homepage']" :href="a['@attributes']['homepage']">{{ a['@value'] }}</a><span v-else-if="a['@value']">{{ a['@value'] }}</span><span v-else>{{ a }}</span><span v-if="index+1 < author.length">, </span>
  58. </span>
  59. </div>
  60. <div v-if="licence" class="app-licence">
  61. {{ licence }}
  62. </div>
  63. <div class="actions">
  64. <div class="actions-buttons">
  65. <input v-if="app.update"
  66. class="update primary"
  67. type="button"
  68. :value="t('settings', 'Update to {version}', {version: app.update})"
  69. :disabled="installing || loading(app.id)"
  70. @click="update(app.id)">
  71. <input v-if="app.canUnInstall"
  72. class="uninstall"
  73. type="button"
  74. :value="t('settings', 'Remove')"
  75. :disabled="installing || loading(app.id)"
  76. @click="remove(app.id)">
  77. <input v-if="app.active"
  78. class="enable"
  79. type="button"
  80. :value="t('settings','Disable')"
  81. :disabled="installing || loading(app.id)"
  82. @click="disable(app.id)">
  83. <input v-if="!app.active && (app.canInstall || app.isCompatible)"
  84. v-tooltip.auto="enableButtonTooltip"
  85. class="enable primary"
  86. type="button"
  87. :value="enableButtonText"
  88. :disabled="!app.canInstall || installing || loading(app.id)"
  89. @click="enable(app.id)">
  90. <input v-else-if="!app.active"
  91. v-tooltip.auto="forceEnableButtonTooltip"
  92. class="enable force"
  93. type="button"
  94. :value="forceEnableButtonText"
  95. :disabled="installing || loading(app.id)"
  96. @click="forceEnable(app.id)">
  97. </div>
  98. <div class="app-groups">
  99. <div v-if="app.active && canLimitToGroups(app)" class="groups-enable">
  100. <input :id="prefix('groups_enable', app.id)"
  101. v-model="groupCheckedAppsData"
  102. type="checkbox"
  103. :value="app.id"
  104. class="groups-enable__checkbox checkbox"
  105. @change="setGroupLimit">
  106. <label :for="prefix('groups_enable', app.id)">{{ t('settings', 'Limit to groups') }}</label>
  107. <input type="hidden"
  108. class="group_select"
  109. :title="t('settings', 'All')"
  110. value="">
  111. <Multiselect v-if="isLimitedToGroups(app)"
  112. :options="groups"
  113. :value="appGroups"
  114. :options-limit="5"
  115. :placeholder="t('settings', 'Limit app usage to groups')"
  116. label="name"
  117. track-by="id"
  118. class="multiselect-vue"
  119. :multiple="true"
  120. :close-on-select="false"
  121. :tag-width="60"
  122. @select="addGroupLimitation"
  123. @remove="removeGroupLimitation"
  124. @search-change="asyncFindGroup">
  125. <span slot="noResult">{{ t('settings', 'No results') }}</span>
  126. </Multiselect>
  127. </div>
  128. </div>
  129. </div>
  130. <ul class="app-dependencies">
  131. <li v-if="app.missingMinOwnCloudVersion">
  132. {{ t('settings', 'This app has no minimum Nextcloud version assigned. This will be an error in the future.') }}
  133. </li>
  134. <li v-if="app.missingMaxOwnCloudVersion">
  135. {{ t('settings', 'This app has no maximum Nextcloud version assigned. This will be an error in the future.') }}
  136. </li>
  137. <li v-if="!app.canInstall">
  138. {{ t('settings', 'This app cannot be installed because the following dependencies are not fulfilled:') }}
  139. <ul class="missing-dependencies">
  140. <li v-for="(dep, index) in app.missingDependencies" :key="index">
  141. {{ dep }}
  142. </li>
  143. </ul>
  144. </li>
  145. </ul>
  146. <p class="documentation">
  147. <a v-if="!app.internal"
  148. class="appslink"
  149. :href="appstoreUrl"
  150. target="_blank"
  151. rel="noreferrer noopener">{{ t('settings', 'View in store') }} ↗</a>
  152. <a v-if="app.website"
  153. class="appslink"
  154. :href="app.website"
  155. target="_blank"
  156. rel="noreferrer noopener">{{ t('settings', 'Visit website') }} ↗</a>
  157. <a v-if="app.bugs"
  158. class="appslink"
  159. :href="app.bugs"
  160. target="_blank"
  161. rel="noreferrer noopener">{{ t('settings', 'Report a bug') }} ↗</a>
  162. <a v-if="app.documentation && app.documentation.user"
  163. class="appslink"
  164. :href="app.documentation.user"
  165. target="_blank"
  166. rel="noreferrer noopener">{{ t('settings', 'User documentation') }} ↗</a>
  167. <a v-if="app.documentation && app.documentation.admin"
  168. class="appslink"
  169. :href="app.documentation.admin"
  170. target="_blank"
  171. rel="noreferrer noopener">{{ t('settings', 'Admin documentation') }} ↗</a>
  172. <a v-if="app.documentation && app.documentation.developer"
  173. class="appslink"
  174. :href="app.documentation.developer"
  175. target="_blank"
  176. rel="noreferrer noopener">{{ t('settings', 'Developer documentation') }} ↗</a>
  177. </p>
  178. <div class="app-description" v-html="renderMarkdown" />
  179. </div>
  180. </template>
  181. <script>
  182. import { Multiselect } from 'nextcloud-vue'
  183. import marked from 'marked'
  184. import dompurify from 'dompurify'
  185. import AppScore from './AppList/AppScore'
  186. import AppManagement from './AppManagement'
  187. import PrefixMixin from './PrefixMixin'
  188. import SvgFilterMixin from './SvgFilterMixin'
  189. export default {
  190. name: 'AppDetails',
  191. components: {
  192. Multiselect,
  193. AppScore
  194. },
  195. mixins: [AppManagement, PrefixMixin, SvgFilterMixin],
  196. props: ['category', 'app'],
  197. data() {
  198. return {
  199. groupCheckedAppsData: false
  200. }
  201. },
  202. computed: {
  203. appstoreUrl() {
  204. return `https://apps.nextcloud.com/apps/${this.app.id}`
  205. },
  206. licence() {
  207. if (this.app.licence) {
  208. return t('settings', '{license}-licensed', { license: ('' + this.app.licence).toUpperCase() })
  209. }
  210. return null
  211. },
  212. hasRating() {
  213. return this.app.appstoreData && this.app.appstoreData.ratingNumOverall > 5
  214. },
  215. author() {
  216. if (typeof this.app.author === 'string') {
  217. return [
  218. {
  219. '@value': this.app.author
  220. }
  221. ]
  222. }
  223. if (this.app.author['@value']) {
  224. return [this.app.author]
  225. }
  226. return this.app.author
  227. },
  228. appGroups() {
  229. return this.app.groups.map(group => { return { id: group, name: group } })
  230. },
  231. groups() {
  232. return this.$store.getters.getGroups
  233. .filter(group => group.id !== 'disabled')
  234. .sort((a, b) => a.name.localeCompare(b.name))
  235. },
  236. renderMarkdown() {
  237. var renderer = new marked.Renderer()
  238. renderer.link = function(href, title, text) {
  239. try {
  240. var prot = decodeURIComponent(unescape(href))
  241. .replace(/[^\w:]/g, '')
  242. .toLowerCase()
  243. } catch (e) {
  244. return ''
  245. }
  246. if (prot.indexOf('http:') !== 0 && prot.indexOf('https:') !== 0) {
  247. return ''
  248. }
  249. var out = '<a href="' + href + '" rel="noreferrer noopener"'
  250. if (title) {
  251. out += ' title="' + title + '"'
  252. }
  253. out += '>' + text + '</a>'
  254. return out
  255. }
  256. renderer.image = function(href, title, text) {
  257. if (text) {
  258. return text
  259. }
  260. return title
  261. }
  262. renderer.blockquote = function(quote) {
  263. return quote
  264. }
  265. return dompurify.sanitize(
  266. marked(this.app.description.trim(), {
  267. renderer: renderer,
  268. gfm: false,
  269. highlight: false,
  270. tables: false,
  271. breaks: false,
  272. pedantic: false,
  273. sanitize: true,
  274. smartLists: true,
  275. smartypants: false
  276. }),
  277. {
  278. SAFE_FOR_JQUERY: true,
  279. ALLOWED_TAGS: [
  280. 'strong',
  281. 'p',
  282. 'a',
  283. 'ul',
  284. 'ol',
  285. 'li',
  286. 'em',
  287. 'del',
  288. 'blockquote'
  289. ]
  290. }
  291. )
  292. }
  293. },
  294. mounted() {
  295. if (this.app.groups.length > 0) {
  296. this.groupCheckedAppsData = true
  297. }
  298. }
  299. }
  300. </script>
  301. <style scoped>
  302. .force {
  303. background: var(--color-main-background);
  304. border-color: var(--color-error);
  305. color: var(--color-error);
  306. }
  307. .force:hover,
  308. .force:active {
  309. background: var(--color-error);
  310. border-color: var(--color-error) !important;
  311. color: var(--color-main-background);
  312. }
  313. </style>