Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show changelog in apps management #21082

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/settings/js/vue-0.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-0.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/settings/js/vue-5.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-5.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/settings/js/vue-6.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-6.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/settings/js/vue-7.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-7.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/settings/js/vue-8.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-8.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/settings/js/vue-settings-admin-security.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-admin-security.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/settings/js/vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/settings/js/vue-settings-personal-security.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-personal-security.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/settings/lib/Controller/AppSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ public function listApps(): JSONResponse {
$appstoreData = $appData['appstoreData'];
$appData['screenshot'] = isset($appstoreData['screenshots'][0]['url']) ? 'https://usercontent.apps.nextcloud.com/' . base64_encode($appstoreData['screenshots'][0]['url']) : '';
$appData['category'] = $appstoreData['categories'];
$appData['releases'] = $appstoreData['releases'];
}

$newVersion = $this->installer->isUpdateAvailable($appData['id']);
Expand Down
67 changes: 3 additions & 64 deletions apps/settings/src/components/AppDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,24 +139,23 @@
target="_blank"
rel="noreferrer noopener">{{ t('settings', 'Developer documentation') }} ↗</a>
</p>

<div class="app-details__description" v-html="renderMarkdown" />
<Markdown class="app-details__description" :text="app.description" />
</div>
</template>

<script>
import { Multiselect } from '@nextcloud/vue'
import marked from 'marked'
import dompurify from 'dompurify'

import AppManagement from '../mixins/AppManagement'
import PrefixMixin from './PrefixMixin'
import Markdown from './Markdown'

export default {
name: 'AppDetails',

components: {
Multiselect,
Markdown,
},
mixins: [AppManagement, PrefixMixin],

Expand Down Expand Up @@ -204,66 +203,6 @@ export default {
.filter(group => group.id !== 'disabled')
.sort((a, b) => a.name.localeCompare(b.name))
},
renderMarkdown() {
const renderer = new marked.Renderer()
renderer.link = function(href, title, text) {
let prot
try {
prot = decodeURIComponent(unescape(href))
.replace(/[^\w:]/g, '')
.toLowerCase()
} catch (e) {
return ''
}

if (prot.indexOf('http:') !== 0 && prot.indexOf('https:') !== 0) {
return ''
}

let out = '<a href="' + href + '" rel="noreferrer noopener"'
if (title) {
out += ' title="' + title + '"'
}
out += '>' + text + '</a>'
return out
}
renderer.image = function(href, title, text) {
if (text) {
return text
}
return title
}
renderer.blockquote = function(quote) {
return quote
}
return dompurify.sanitize(
marked(this.app.description.trim(), {
renderer,
gfm: false,
highlight: false,
tables: false,
breaks: false,
pedantic: false,
sanitize: true,
smartLists: true,
smartypants: false,
}),
{
SAFE_FOR_JQUERY: true,
ALLOWED_TAGS: [
'strong',
'p',
'a',
'ul',
'ol',
'li',
'em',
'del',
'blockquote',
],
}
)
},
},
mounted() {
if (this.app.groups.length > 0) {
Expand Down
197 changes: 197 additions & 0 deletions apps/settings/src/components/Markdown.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
<!--
- @copyright Copyright (c) 2020 Julius Härtl <[email protected]>
-
- @author Julius Härtl <[email protected]>
-
- @license GNU AGPL version 3 or any later version
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-->

<template>
<div class="settings-markdown" v-html="renderMarkdown" />
</template>

<script>
import marked from 'marked'
import dompurify from 'dompurify'

export default {
name: 'Markdown',
props: {
text: {
type: String,
default: '',
},
},
computed: {
renderMarkdown() {
const renderer = new marked.Renderer()
renderer.link = function(href, title, text) {
let prot
try {
prot = decodeURIComponent(unescape(href))
.replace(/[^\w:]/g, '')
.toLowerCase()
} catch (e) {
return ''
}

if (prot.indexOf('http:') !== 0 && prot.indexOf('https:') !== 0) {
return ''
}

let out = '<a href="' + href + '" rel="noreferrer noopener"'
if (title) {
out += ' title="' + title + '"'
}
out += '>' + text + '</a>'
return out
}
renderer.image = function(href, title, text) {
if (text) {
return text
}
return title
}
renderer.blockquote = function(quote) {
return quote
}
return dompurify.sanitize(
marked(this.text.trim(), {
renderer,
gfm: false,
highlight: false,
tables: false,
breaks: false,
pedantic: false,
sanitize: true,
smartLists: true,
smartypants: false,
}),
{
SAFE_FOR_JQUERY: true,
ALLOWED_TAGS: [
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'strong',
'p',
'a',
'ul',
'ol',
'li',
'em',
'del',
'blockquote',
],
}
)
},
},
}
</script>

<style scoped lang="scss">
.settings-markdown::v-deep {

h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: 600;
line-height: 120%;
margin-top: 24px;
margin-bottom: 12px;
color: var(--color-main-text);
}

h1 {
font-size: 36px;
margin-top: 48px;
}

h2 {
font-size: 28px;
margin-top: 48px;
}

h3 {
font-size: 24px;
}

h4 {
font-size: 21px;
}

h5 {
font-size: 17px;
}

h6 {
font-size: 14px;
}

pre {
white-space: pre;
overflow-x: auto;
background-color: var(--color-background-dark);
border-radius: var(--border-radius);
padding: 1em 1.3em;
margin-bottom: 1em;
}

p code {
background-color: var(--color-background-dark);
border-radius: var(--border-radius);
padding: .1em .3em;
}

li {
position: relative;
}

ul, ol {
padding-left: 10px;
margin-left: 10px;
}

ul li {
list-style-type: disc;
}

ul > li > ul > li {
list-style-type: circle;
}

ul > li > ul > li ul li {
list-style-type: square;
}

blockquote {
padding-left: 1em;
border-left: 4px solid var(--color-primary-element);
color: var(--color-text-maxcontrast);
margin-left: 0;
margin-right: 0;
}

}
</style>
40 changes: 39 additions & 1 deletion apps/settings/src/views/Apps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,23 @@
</template>

<!-- Tab content -->
<AppDetails :app="app" />

<AppSidebarTab id="desc"
icon="icon-category-office"
:name="t('settings', 'Details')"
:order="0">
<AppDetails :app="app" />
</AppSidebarTab>
<AppSidebarTab v-if="app.appstoreData && app.releases[0].translations.en.changelog"
id="desca"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

desca ?

Suggested change
id="desca"
id="changelog"

icon="icon-category-organization"
:name="t('settings', 'Changelog')"
:order="1">
<div v-for="release in app.releases" :key="release.version" class="app-sidebar-tabs__release">
<h2>{{ release.version }}</h2>
<Markdown v-if="changelog(release)" :text="changelog(release)" />
</div>
</AppSidebarTab>
</AppSidebar>
</Content>
</template>
Expand All @@ -131,6 +147,7 @@ import AppNavigationCounter from '@nextcloud/vue/dist/Components/AppNavigationCo
import AppNavigationItem from '@nextcloud/vue/dist/Components/AppNavigationItem'
import AppNavigationSpacer from '@nextcloud/vue/dist/Components/AppNavigationSpacer'
import AppSidebar from '@nextcloud/vue/dist/Components/AppSidebar'
import AppSidebarTab from '@nextcloud/vue/dist/Components/AppSidebarTab'
import Content from '@nextcloud/vue/dist/Components/Content'
import Vue from 'vue'
import VueLocalStorage from 'vue-localstorage'
Expand All @@ -139,6 +156,7 @@ import AppList from '../components/AppList'
import AppDetails from '../components/AppDetails'
import AppManagement from '../mixins/AppManagement'
import AppScore from '../components/AppList/AppScore'
import Markdown from '../components/Markdown'

Vue.use(VueLocalStorage)

Expand All @@ -155,7 +173,9 @@ export default {
AppNavigationSpacer,
AppScore,
AppSidebar,
AppSidebarTab,
Content,
Markdown,
},

mixins: [AppManagement],
Expand Down Expand Up @@ -228,6 +248,9 @@ export default {

}
},
changelog() {
return (release) => release.translations.en.changelog
},
},

watch: {
Expand Down Expand Up @@ -326,4 +349,19 @@ export default {
}
}

.app-sidebar-tabs__release {
h2 {
border-bottom: 1px solid var(--color-border);
}

// Overwrite changelog heading styles
::v-deep {
h3 {
font-size: 20px;
}
h4 {
font-size: 17px;
}
}
}
</style>