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

Remove deprecated global API calls #1774

Merged
merged 1 commit into from
May 18, 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
90 changes: 42 additions & 48 deletions src/BoardSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,56 +40,10 @@
</div>
</Modal>
</template>
<style scoped>
#modal-inner {
width: 90vw;
max-width: 400px;
padding: 20px;
}

input {
width: 100%;
margin-bottom: 15px;
}

ul {
min-height: 50vh;
max-height: 300px;
overflow: scroll;
}

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 Down Expand Up @@ -120,7 +74,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 @@ -135,3 +89,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 @@ -100,6 +100,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 @@ -208,7 +209,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 @@ -202,6 +202,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({
linkify: true,
Expand Down Expand Up @@ -279,7 +280,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/CardMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
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: 'CardMenu',
Expand Down Expand Up @@ -127,7 +129,7 @@ export default {
this.$store.dispatch('assignCardToUser', {
card: this.copiedCard,
assignee: {
userId: OC.getCurrentUser().uid,
userId: getCurrentUser()?.uid,
type: 0,
},
})
Expand All @@ -140,7 +142,7 @@ export default {
},
async loadStacksFromBoard(board) {
try {
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}`)
}
console.error(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 @@ -344,7 +345,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