Merge pull request #1774 from nextcloud/bugfix/noid/deprecated-js-api

This commit is contained in:
Julius Härtl
2020-05-18 09:06:45 +02:00
committed by GitHub
12 changed files with 77 additions and 73 deletions

View File

@@ -40,6 +40,55 @@
</div> </div>
</Modal> </Modal>
</template> </template>
<script>
import Modal from '@nextcloud/vue/dist/Components/Modal'
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
export default {
name: 'BoardSelector',
components: {
Modal,
},
data() {
return {
filter: '',
boards: [],
selectedBoard: null,
loading: true,
currentBoard: null,
}
},
computed: {
availableBoards() {
return this.boards.filter((board) => (
'' + board.id !== '' + this.currentBoard
&& board.title.match(this.filter)
))
},
},
beforeMount() {
this.fetchBoards()
const hash = window.location.hash.match(/\/boards\/([0-9]+)/)
this.currentBoard = hash.length > 0 ? hash[1] : null
},
methods: {
fetchBoards() {
axios.get(generateUrl('/apps/deck/boards')).then((response) => {
this.boards = response.data
this.loading = false
})
},
close() {
this.$root.$emit('close')
},
select() {
this.$root.$emit('select', this.selectedBoard)
},
},
}
</script>
<style scoped> <style scoped>
#modal-inner { #modal-inner {
width: 90vw; width: 90vw;
@@ -47,15 +96,8 @@
padding: 20px; padding: 20px;
} }
input {
width: 100%;
margin-bottom: 15px;
}
ul { ul {
min-height: 50vh; min-height: 100px;
max-height: 300px;
overflow: scroll;
} }
li { li {
@@ -87,51 +129,3 @@
} }
</style> </style>
<script>
import Modal from '@nextcloud/vue/dist/Components/Modal'
import axios from '@nextcloud/axios'
export default {
name: 'BoardSelector',
components: {
Modal,
},
data() {
return {
filter: '',
boards: [],
selectedBoard: null,
loading: true,
currentBoard: null,
}
},
computed: {
availableBoards() {
return this.boards.filter((board) => (
'' + board.id !== '' + this.currentBoard
&& board.title.match(this.filter)
))
},
},
beforeMount() {
this.fetchBoards()
const hash = window.location.hash.match(/\/boards\/([0-9]+)/)
this.currentBoard = hash.length > 0 ? hash[1] : null
},
methods: {
fetchBoards() {
axios.get(OC.generateUrl('/apps/deck/boards')).then((response) => {
this.boards = response.data
this.loading = false
})
},
close() {
this.$root.$emit('close')
},
select() {
this.$root.$emit('select', this.selectedBoard)
},
},
}
</script>

View File

@@ -45,6 +45,7 @@
</template> </template>
<script> <script>
import { generateUrl } from '@nextcloud/router'
import Modal from '@nextcloud/vue/dist/Components/Modal' import Modal from '@nextcloud/vue/dist/Components/Modal'
import Multiselect from '@nextcloud/vue/dist/Components/Multiselect' import Multiselect from '@nextcloud/vue/dist/Components/Multiselect'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
@@ -77,7 +78,7 @@ export default {
}, },
methods: { methods: {
fetchBoards() { fetchBoards() {
axios.get(OC.generateUrl('/apps/deck/boards')).then((response) => { axios.get(generateUrl('/apps/deck/boards')).then((response) => {
this.boards = response.data this.boards = response.data
this.loading = false this.loading = false
}) })
@@ -85,7 +86,7 @@ export default {
async fetchCardsFromBoard(board) { async fetchCardsFromBoard(board) {
try { try {
this.cardsFromBoard = [] this.cardsFromBoard = []
const url = OC.generateUrl('/apps/deck/stacks/' + board.id) const url = generateUrl('/apps/deck/stacks/' + board.id)
const response = await axios.get(url) const response = await axios.get(url)
response.data.forEach(stack => { response.data.forEach(stack => {
this.cardsFromBoard.push(...stack.cards) this.cardsFromBoard.push(...stack.cards)

View File

@@ -100,6 +100,7 @@
import { mapGetters, mapState } from 'vuex' import { mapGetters, mapState } from 'vuex'
import { Container, Draggable } from 'vue-smooth-dnd' import { Container, Draggable } from 'vue-smooth-dnd'
import { Actions, ActionButton } from '@nextcloud/vue' import { Actions, ActionButton } from '@nextcloud/vue'
import { showError } from '@nextcloud/dialogs'
import CardItem from '../cards/CardItem' import CardItem from '../cards/CardItem'
export default { export default {
@@ -208,7 +209,7 @@ export default {
}) })
this.$router.push({ name: 'card', params: { cardId: newCard.id } }) this.$router.push({ name: 'card', params: { cardId: newCard.id } })
} catch (e) { } catch (e) {
OCP.Toast.error('Could not create card: ' + e.response.data.message) showError('Could not create card: ' + e.response.data.message)
} finally { } finally {
this.stateCardCreating = false this.stateCardCreating = false
} }

View File

@@ -60,6 +60,7 @@
import { Actions, ActionButton } from '@nextcloud/vue' import { Actions, ActionButton } from '@nextcloud/vue'
import relativeDate from '../../mixins/relativeDate' import relativeDate from '../../mixins/relativeDate'
import { formatFileSize } from '@nextcloud/files' import { formatFileSize } from '@nextcloud/files'
import { generateUrl } from '@nextcloud/router'
export default { export default {
name: 'AttachmentList', name: 'AttachmentList',
@@ -101,7 +102,7 @@ export default {
} }
}, },
attachmentUrl() { attachmentUrl() {
return (attachment) => OC.generateUrl(`/apps/deck/cards/${attachment.cardId}/attachment/${attachment.id}`) return (attachment) => generateUrl(`/apps/deck/cards/${attachment.cardId}/attachment/${attachment.id}`)
}, },
formattedFileSize() { formattedFileSize() {
return (filesize) => formatFileSize(filesize) return (filesize) => formatFileSize(filesize)

View File

@@ -202,6 +202,7 @@ import MarkdownItTaskLists from 'markdown-it-task-lists'
import { formatFileSize } from '@nextcloud/files' import { formatFileSize } from '@nextcloud/files'
import relativeDate from '../../mixins/relativeDate' import relativeDate from '../../mixins/relativeDate'
import AttachmentList from './AttachmentList' import AttachmentList from './AttachmentList'
import { generateUrl } from '@nextcloud/router'
const markdownIt = new MarkdownIt({ const markdownIt = new MarkdownIt({
linkify: true, linkify: true,
@@ -279,7 +280,7 @@ export default {
} }
}, },
attachmentUrl() { attachmentUrl() {
return (attachment) => OC.generateUrl(`/apps/deck/cards/${attachment.cardId}/attachment/${attachment.id}`) return (attachment) => generateUrl(`/apps/deck/cards/${attachment.cardId}/attachment/${attachment.id}`)
}, },
formattedFileSize() { formattedFileSize() {
return (filesize) => formatFileSize(filesize) return (filesize) => formatFileSize(filesize)

View File

@@ -35,7 +35,7 @@ import { Avatar } from '@nextcloud/vue'
import CommentItem from './CommentItem' import CommentItem from './CommentItem'
import CommentForm from './CommentForm' import CommentForm from './CommentForm'
import InfiniteLoading from 'vue-infinite-loading' import InfiniteLoading from 'vue-infinite-loading'
import { getCurrentUser } from '@nextcloud/auth'
export default { export default {
name: 'CardSidebarTabComments', name: 'CardSidebarTabComments',
components: { components: {
@@ -54,7 +54,7 @@ export default {
return { return {
newComment: '', newComment: '',
isLoading: false, isLoading: false,
currentUser: OC.getCurrentUser(), currentUser: getCurrentUser(),
} }
}, },
computed: { computed: {

View File

@@ -58,6 +58,7 @@
<script> <script>
import { Avatar, PopoverMenu, Tooltip } from '@nextcloud/vue' import { Avatar, PopoverMenu, Tooltip } from '@nextcloud/vue'
import { generateUrl } from '@nextcloud/router'
export default { export default {
name: 'AvatarList', name: 'AvatarList',
@@ -93,7 +94,7 @@ export default {
} }
const user = assignable.participant.uid const user = assignable.participant.uid
const size = 32 const size = 32
const avatarUrl = OC.generateUrl('/avatar/{user}/{size}', const avatarUrl = generateUrl('/avatar/{user}/{size}',
{ {
user: user, user: user,
size: size, size: size,

View File

@@ -70,6 +70,8 @@
import { Modal, Actions, ActionButton, Multiselect } from '@nextcloud/vue' import { Modal, Actions, ActionButton, Multiselect } from '@nextcloud/vue'
import { mapGetters, mapState } from 'vuex' import { mapGetters, mapState } from 'vuex'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
export default { export default {
name: 'CardMenu', name: 'CardMenu',
@@ -127,7 +129,7 @@ export default {
this.$store.dispatch('assignCardToUser', { this.$store.dispatch('assignCardToUser', {
card: this.copiedCard, card: this.copiedCard,
assignee: { assignee: {
userId: OC.getCurrentUser().uid, userId: getCurrentUser()?.uid,
type: 0, type: 0,
}, },
}) })
@@ -140,7 +142,7 @@ export default {
}, },
async loadStacksFromBoard(board) { async loadStacksFromBoard(board) {
try { try {
const url = OC.generateUrl('/apps/deck/stacks/' + board.id) const url = generateUrl('/apps/deck/stacks/' + board.id)
const response = await axios.get(url) const response = await axios.get(url)
this.stacksFromBoard = response.data this.stacksFromBoard = response.data
} catch (err) { } catch (err) {

View File

@@ -76,6 +76,7 @@ import { Multiselect } from '@nextcloud/vue'
import AppNavigationAddBoard from './AppNavigationAddBoard' import AppNavigationAddBoard from './AppNavigationAddBoard'
import AppNavigationBoardCategory from './AppNavigationBoardCategory' import AppNavigationBoardCategory from './AppNavigationBoardCategory'
import { loadState } from '@nextcloud/initial-state' import { loadState } from '@nextcloud/initial-state'
import { generateUrl, generateOcsUrl } from '@nextcloud/router'
const canCreateState = loadState('deck', 'canCreate') const canCreateState = loadState('deck', 'canCreate')
@@ -118,13 +119,13 @@ export default {
}, },
beforeMount() { beforeMount() {
if (this.isAdmin) { if (this.isAdmin) {
axios.get(OC.generateUrl('apps/deck/config')).then((response) => { axios.get(generateUrl('apps/deck/config')).then((response) => {
this.groupLimit = response.data.groupLimit this.groupLimit = response.data.groupLimit
this.groupLimitDisabled = false this.groupLimitDisabled = false
}, (error) => { }, (error) => {
console.error('Error while loading groupLimit', error.response) console.error('Error while loading groupLimit', error.response)
}) })
axios.get(OC.linkToOCS('cloud', 2) + 'groups').then((response) => { axios.get(generateOcsUrl('cloud', 2) + 'groups').then((response) => {
this.groups = response.data.ocs.data.groups.reduce((obj, item) => { this.groups = response.data.ocs.data.groups.reduce((obj, item) => {
obj.push({ obj.push({
id: item, id: item,
@@ -146,7 +147,7 @@ export default {
}, },
updateConfig() { updateConfig() {
this.groupLimitDisabled = true this.groupLimitDisabled = true
axios.post(OC.generateUrl('apps/deck/config/groupLimit'), { axios.post(generateUrl('apps/deck/config/groupLimit'), {
value: this.groupLimit, value: this.groupLimit,
}).then(() => { }).then(() => {
this.groupLimitDisabled = false this.groupLimitDisabled = false

View File

@@ -26,6 +26,7 @@ import store from './store/main'
import { sync } from 'vuex-router-sync' import { sync } from 'vuex-router-sync'
import { translate, translatePlural } from '@nextcloud/l10n' import { translate, translatePlural } from '@nextcloud/l10n'
import { generateFilePath } from '@nextcloud/router' import { generateFilePath } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs'
import { Tooltip } from '@nextcloud/vue' import { Tooltip } from '@nextcloud/vue'
import ClickOutside from 'vue-click-outside' import ClickOutside from 'vue-click-outside'
import './models' import './models'
@@ -60,7 +61,7 @@ Vue.directive('focus', {
Vue.config.errorHandler = (err, vm, info) => { Vue.config.errorHandler = (err, vm, info) => {
if (err.response && err.response.data.message) { if (err.response && err.response.data.message) {
const errorMessage = t('deck', 'Something went wrong') const errorMessage = t('deck', 'Something went wrong')
OCP.Toast.error(`${errorMessage}: ${err.response.data.status} ${err.response.data.message}`) showError(`${errorMessage}: ${err.response.data.status} ${err.response.data.message}`)
} }
console.error(err) console.error(err)
} }

View File

@@ -21,13 +21,13 @@
*/ */
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router' import { generateOcsUrl, generateRemoteUrl } from '@nextcloud/router'
export class CommentApi { export class CommentApi {
url(url) { url(url) {
url = `dav/comments/deckCard/${url}` url = `dav/comments/deckCard/${url}`
return OC.linkToRemote(url) return generateRemoteUrl(url)
} }
async loadComments({ cardId, limit, offset }) { async loadComments({ cardId, limit, offset }) {

View File

@@ -25,6 +25,7 @@ import 'url-search-params-polyfill'
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import axios from '@nextcloud/axios' import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router'
import { BoardApi } from './../services/BoardApi' import { BoardApi } from './../services/BoardApi'
import stack from './stack' import stack from './stack'
import card from './card' import card from './card'
@@ -344,7 +345,7 @@ export default new Vuex.Store({
params.append('perPage', 20) params.append('perPage', 20)
params.append('itemType', [0, 1, 7]) params.append('itemType', [0, 1, 7])
axios.get(OC.linkToOCS('apps/files_sharing/api/v1') + 'sharees', { params }).then((response) => { axios.get(generateOcsUrl('apps/files_sharing/api/v1') + 'sharees', { params }).then((response) => {
commit('setSharees', response.data.ocs.data) commit('setSharees', response.data.ocs.data)
}) })
}, 250), }, 250),