Skip to content

Commit

Permalink
Remove deprecated global API calls
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Apr 27, 2020
1 parent b5d0c62 commit a89529c
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 58 deletions.
83 changes: 42 additions & 41 deletions src/BoardSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,49 +39,10 @@
</div>
</Modal>
</template>
<style scoped>
#modal-inner {
width: 90vw;
max-width: 400px;
padding: 20px;
}

ul {
min-height: 100px;
}

li {
padding: 6px;
border: 1px solid transparent;
}

li:hover, li:focus {
background-color: var(--color-background-dark);
}

li.selected {
border: 1px solid var(--color-primary);
}

.board-bullet {
display: inline-block;
width: 12px;
height: 12px;
border: none;
border-radius: 50%;
cursor: pointer;
}

li > span,
.avatar {
vertical-align: middle;

}

</style>
<script>
import { Modal } from '@nextcloud/vue/dist/Components/Modal'
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'

export default {
name: 'BoardSelector',
Expand All @@ -107,7 +68,7 @@ export default {
},
methods: {
fetchBoards() {
axios.get(OC.generateUrl('/apps/deck/boards')).then((response) => {
axios.get(generateUrl('/apps/deck/boards')).then((response) => {
this.boards = response.data
this.loading = false
})
Expand All @@ -122,3 +83,43 @@ export default {

}
</script>
<style scoped>
#modal-inner {
width: 90vw;
max-width: 400px;
padding: 20px;
}

ul {
min-height: 100px;
}

li {
padding: 6px;
border: 1px solid transparent;
}

li:hover, li:focus {
background-color: var(--color-background-dark);
}

li.selected {
border: 1px solid var(--color-primary);
}

.board-bullet {
display: inline-block;
width: 12px;
height: 12px;
border: none;
border-radius: 50%;
cursor: pointer;
}

li > span,
.avatar {
vertical-align: middle;

}

</style>
5 changes: 3 additions & 2 deletions src/CardSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
</template>

<script>
import { generateUrl } from '@nextcloud/router'
import { Modal } from '@nextcloud/vue/dist/Components/Modal'
import { Multiselect } from '@nextcloud/vue/dist/Components/Multiselect'
import axios from '@nextcloud/axios'
Expand Down Expand Up @@ -77,15 +78,15 @@ export default {
},
methods: {
fetchBoards() {
axios.get(OC.generateUrl('/apps/deck/boards')).then((response) => {
axios.get(generateUrl('/apps/deck/boards')).then((response) => {
this.boards = response.data
this.loading = false
})
},
async fetchCardsFromBoard(board) {
try {
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)
response.data.forEach(stack => {
this.cardsFromBoard.push(...stack.cards)
Expand Down
3 changes: 2 additions & 1 deletion src/components/board/Stack.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
import { mapGetters, mapState } from 'vuex'
import { Container, Draggable } from 'vue-smooth-dnd'
import { Actions, ActionButton } from '@nextcloud/vue'
import { showError } from '@nextcloud/dialogs'
import CardItem from '../cards/CardItem'

export default {
Expand Down Expand Up @@ -205,7 +206,7 @@ export default {
})
this.$router.push({ name: 'card', params: { cardId: newCard.id } })
} catch (e) {
OCP.Toast.error('Could not create card: ' + e.response.data.message)
showError('Could not create card: ' + e.response.data.message)
} finally {
this.stateCardCreating = false
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/card/AttachmentList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import { Actions, ActionButton } from '@nextcloud/vue'
import relativeDate from '../../mixins/relativeDate'
import { formatFileSize } from '@nextcloud/files'
import { generateUrl } from '@nextcloud/router'

export default {
name: 'AttachmentList',
Expand Down Expand Up @@ -101,7 +102,7 @@ export default {
}
},
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() {
return (filesize) => formatFileSize(filesize)
Expand Down
3 changes: 2 additions & 1 deletion src/components/card/CardSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ import MarkdownItTaskLists from 'markdown-it-task-lists'
import { formatFileSize } from '@nextcloud/files'
import relativeDate from '../../mixins/relativeDate'
import AttachmentList from './AttachmentList'
import { generateUrl } from '@nextcloud/router'

const markdownIt = new MarkdownIt()
markdownIt.use(MarkdownItTaskLists, { enabled: true, label: true, labelAfter: true })
Expand Down Expand Up @@ -275,7 +276,7 @@ export default {
}
},
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() {
return (filesize) => formatFileSize(filesize)
Expand Down
4 changes: 2 additions & 2 deletions src/components/card/CardSidebarTabComments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { Avatar } from '@nextcloud/vue'
import CommentItem from './CommentItem'
import CommentForm from './CommentForm'
import InfiniteLoading from 'vue-infinite-loading'
import { getCurrentUser } from '@nextcloud/auth'
export default {
name: 'CardSidebarTabComments',
components: {
Expand All @@ -54,7 +54,7 @@ export default {
return {
newComment: '',
isLoading: false,
currentUser: OC.getCurrentUser(),
currentUser: getCurrentUser(),
}
},
computed: {
Expand Down
3 changes: 2 additions & 1 deletion src/components/cards/AvatarList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

<script>
import { Avatar, PopoverMenu, Tooltip } from '@nextcloud/vue'
import { generateUrl } from '@nextcloud/router'

export default {
name: 'AvatarList',
Expand Down Expand Up @@ -93,7 +94,7 @@ export default {
}
const user = assignable.participant.uid
const size = 32
const avatarUrl = OC.generateUrl('/avatar/{user}/{size}',
const avatarUrl = generateUrl('/avatar/{user}/{size}',
{
user: user,
size: size,
Expand Down
6 changes: 4 additions & 2 deletions src/components/cards/CardBadges.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ import AvatarList from './AvatarList'
import { Modal, Actions, ActionButton, Multiselect } from '@nextcloud/vue'
import { mapGetters, mapState } from 'vuex'
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'

export default {
name: 'CardBadges',
Expand Down Expand Up @@ -145,7 +147,7 @@ export default {
this.$store.dispatch('assignCardToUser', {
card: this.copiedCard,
assignee: {
userId: OC.getCurrentUser().uid,
userId: getCurrentUser().uid,
type: 0,
},
})
Expand All @@ -159,7 +161,7 @@ export default {
async loadStacksFromBoard(board) {
try {
console.debug(board)
const url = OC.generateUrl('/apps/deck/stacks/' + board.id)
const url = generateUrl('/apps/deck/stacks/' + board.id)
const response = await axios.get(url)
this.stacksFromBoard = response.data
} catch (err) {
Expand Down
7 changes: 4 additions & 3 deletions src/components/navigation/AppNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import { Multiselect } from '@nextcloud/vue'
import AppNavigationAddBoard from './AppNavigationAddBoard'
import AppNavigationBoardCategory from './AppNavigationBoardCategory'
import { loadState } from '@nextcloud/initial-state'
import { generateUrl, generateOcsUrl } from '@nextcloud/router'

const canCreateState = loadState('deck', 'canCreate')

Expand Down Expand Up @@ -118,13 +119,13 @@ export default {
},
beforeMount() {
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.groupLimitDisabled = false
}, (error) => {
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) => {
obj.push({
id: item,
Expand All @@ -146,7 +147,7 @@ export default {
},
updateConfig() {
this.groupLimitDisabled = true
axios.post(OC.generateUrl('apps/deck/config/groupLimit'), {
axios.post(generateUrl('apps/deck/config/groupLimit'), {
value: this.groupLimit,
}).then(() => {
this.groupLimitDisabled = false
Expand Down
3 changes: 2 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import store from './store/main'
import { sync } from 'vuex-router-sync'
import { translate, translatePlural } from '@nextcloud/l10n'
import { generateFilePath } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs'
import { Tooltip } from '@nextcloud/vue'
import ClickOutside from 'vue-click-outside'
import './models'
Expand Down Expand Up @@ -60,7 +61,7 @@ Vue.directive('focus', {
Vue.config.errorHandler = (err, vm, info) => {
if (err.response && err.response.data.message) {
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}`)
}
throw err
}
Expand Down
4 changes: 2 additions & 2 deletions src/services/CommentApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
*/

import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router'
import { generateOcsUrl, generateRemoteUrl } from '@nextcloud/router'

export class CommentApi {

url(url) {
url = `dav/comments/deckCard/${url}`
return OC.linkToRemote(url)
return generateRemoteUrl(url)
}

async loadComments({ cardId, limit, offset }) {
Expand Down
3 changes: 2 additions & 1 deletion src/store/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import 'url-search-params-polyfill'
import Vue from 'vue'
import Vuex from 'vuex'
import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router'
import { BoardApi } from './../services/BoardApi'
import stack from './stack'
import card from './card'
Expand Down Expand Up @@ -342,7 +343,7 @@ export default new Vuex.Store({
params.append('perPage', 20)
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)
})
}, 250),
Expand Down

0 comments on commit a89529c

Please sign in to comment.