Skip to content

Commit

Permalink
Merge pull request #2243 from nextcloud/feature/2063/ocp_toast_to_nc_…
Browse files Browse the repository at this point in the history
…dialogs

Use nc/dialogs instead of ocp.toast
  • Loading branch information
georgehrke authored May 5, 2020
2 parents c6c13e3 + d57b254 commit aaa064a
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 50 deletions.
17 changes: 11 additions & 6 deletions src/components/AppNavigation/CalendarList/CalendarListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ import ActionText from '@nextcloud/vue/dist/Components/ActionText'
import AppNavigationIconBullet from '@nextcloud/vue/dist/Components/AppNavigationIconBullet'
import AppNavigationItem from '@nextcloud/vue/dist/Components/AppNavigationItem'
import ClickOutside from 'vue-click-outside'
import {
showInfo,
showSuccess,
showError,
} from '@nextcloud/dialogs'
import {
generateRemoteUrl,
} from '@nextcloud/router'
Expand Down Expand Up @@ -313,7 +318,7 @@ export default {
toggleEnabled() {
this.$store.dispatch('toggleCalendarEnabled', { calendar: this.calendar })
.catch((error) => {
this.$toast.error(this.$t('calendar', 'An error occurred, unable to change visibility of the calendar.'))
showError(this.$t('calendar', 'An error occurred, unable to change visibility of the calendar.'))
console.error(error)
})
},
Expand All @@ -332,7 +337,7 @@ export default {
try {
await this.$store.dispatch('deleteCalendar', { calendar: this.calendar })
} catch (error) {
this.$toast.error(this.$t('calendar', 'An error occurred, unable to delete the calendar.'))
showError(this.$t('calendar', 'An error occurred, unable to delete the calendar.'))
console.error(error)
} finally {
clearInterval(this.deleteInterval)
Expand Down Expand Up @@ -394,10 +399,10 @@ export default {

try {
await this.$copyText(url)
this.$toast.success(this.$t('calendar', 'Calendar link copied to clipboard.'))
showSuccess(this.$t('calendar', 'Calendar link copied to clipboard.'))
} catch (error) {
console.debug(error)
this.$toast.error(this.$t('calendar', 'Calendar link could not be copied to clipboard.'))
showError(this.$t('calendar', 'Calendar link could not be copied to clipboard.'))
}
},
/**
Expand Down Expand Up @@ -432,7 +437,7 @@ export default {
this.showRenameInput = false
this.showRenameSaving = false
} catch (error) {
this.$toast(this.$t('calendar', 'An error occurred, unable to rename the calendar.'))
showInfo(this.$t('calendar', 'An error occurred, unable to rename the calendar.'))
console.error(error)

this.showRenameLabel = false
Expand Down Expand Up @@ -472,7 +477,7 @@ export default {
this.showColorInput = false
this.showColorSaving = false
} catch (error) {
this.$toast(this.$t('calendar', 'An error occurred, unable to change the calendar\'s color.'))
showInfo(this.$t('calendar', 'An error occurred, unable to change the calendar\'s color.'))
console.error(error)

this.showColorLabel = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ import {
generateUrl,
linkTo,
} from '@nextcloud/router'
import {
showSuccess,
showError,
} from '@nextcloud/dialogs'
import HttpClient from '@nextcloud/axios'

export default {
Expand Down Expand Up @@ -205,7 +209,7 @@ export default {
await this.$store.dispatch('publishCalendar', { calendar: this.calendar })
} catch (error) {
console.debug(error)
this.$toast.error(this.$t('calendar', 'An error occurred, unable to publish calendar.'))
showError(this.$t('calendar', 'An error occurred, unable to publish calendar.'))
} finally {
this.publishingCalendar = false
}
Expand Down Expand Up @@ -233,7 +237,7 @@ export default {
})
} catch (error) {
console.error(error)
this.$toast.error(this.$t('calendar', 'An error occurred, unable to send email.'))
showError(this.$t('calendar', 'An error occurred, unable to send email.'))
} finally {
this.showEMailLabel = true
this.showEMailInput = false
Expand All @@ -251,10 +255,10 @@ export default {
// copy link for calendar to clipboard
try {
await this.$copyText(url)
this.$toast.success(this.$t('calendar', 'Calendar link copied to clipboard.'))
showSuccess(this.$t('calendar', 'Calendar link copied to clipboard.'))
} catch (error) {
console.debug(error)
this.$toast.error(this.$t('calendar', 'Calendar link could not be copied to clipboard.'))
showError(this.$t('calendar', 'Calendar link could not be copied to clipboard.'))
} finally {
this.showCopyPublicLinkLabel = true
this.showCopyPublicLinkSpinner = false
Expand All @@ -279,7 +283,7 @@ export default {
this.showCopySubscriptionLinkSuccess = true
this.showCopySubscriptionLinkError = false

this.$toast.success(this.$t('calendar', 'Calendar link copied to clipboard.'))
showSuccess(this.$t('calendar', 'Calendar link copied to clipboard.'))
} catch (error) {
console.debug(error)
this.menuOpen = true
Expand All @@ -288,7 +292,7 @@ export default {
this.showCopySubscriptionLinkSuccess = false
this.showCopySubscriptionLinkError = true

this.$toast.error(this.$t('calendar', 'Calendar link could not be copied to clipboard.'))
showError(this.$t('calendar', 'Calendar link could not be copied to clipboard.'))
} finally {
setTimeout(() => {
this.showCopySubscriptionLinkLabel = true
Expand Down Expand Up @@ -320,7 +324,7 @@ export default {
this.showCopyEmbedCodeLinkSuccess = true
this.showCopyEmbedCodeLinkError = false

this.$toast.success(this.$t('calendar', 'Embed code copied to clipboard.'))
showSuccess(this.$t('calendar', 'Embed code copied to clipboard.'))
} catch (error) {
console.debug(error)
this.menuOpen = true
Expand All @@ -329,7 +333,7 @@ export default {
this.showCopyEmbedCodeLinkSuccess = false
this.showCopyEmbedCodeLinkError = true

this.$toast.error(this.$t('calendar', 'Embed code could not be copied to clipboard.'))
showError(this.$t('calendar', 'Embed code could not be copied to clipboard.'))
} finally {
setTimeout(() => {
this.showCopyEmbedCodeLinkLabel = true
Expand All @@ -349,7 +353,7 @@ export default {
} catch (error) {
console.debug(error)
this.unpublishingCalendar = false
this.$toast.error(this.$t('calendar', 'Unpublishing calendar failed'))
showError(this.$t('calendar', 'Unpublishing calendar failed'))
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
import ActionCheckbox from '@nextcloud/vue/dist/Components/ActionCheckbox'
import AppNavigationItem from '@nextcloud/vue/dist/Components/AppNavigationItem'
import Avatar from '@nextcloud/vue/dist/Components/Avatar'
import {
showInfo,
} from '@nextcloud/dialogs'

export default {
name: 'CalendarListItemSharingShareItem',
Expand Down Expand Up @@ -98,7 +101,7 @@ export default {
this.updatingSharee = false
} catch (error) {
console.error(error)
this.$toast(this.$t('calendar', 'An error occurred, unable to change the unshare the calendar.'))
showInfo(this.$t('calendar', 'An error occurred, unable to change the unshare the calendar.'))

this.updatingSharee = false
}
Expand All @@ -118,7 +121,7 @@ export default {
this.updatingSharee = false
} catch (error) {
console.error(error)
this.$toast(this.$t('calendar', 'An error occurred, unable to change the permission of the share.'))
showInfo(this.$t('calendar', 'An error occurred, unable to change the permission of the share.'))

this.updatingSharee = false
}
Expand Down
11 changes: 7 additions & 4 deletions src/components/AppNavigation/CalendarList/CalendarListNew.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
import ActionInput from '@nextcloud/vue/dist/Components/ActionInput'
import ActionText from '@nextcloud/vue/dist/Components/ActionText'
import AppNavigationItem from '@nextcloud/vue/dist/Components/AppNavigationItem'
import {
showError,
} from '@nextcloud/dialogs'

import { uidToHexColor } from '../../../utils/color.js'

Expand Down Expand Up @@ -192,7 +195,7 @@ export default {
})
} catch (error) {
console.debug(error)
this.$toast.error(this.$t('calendar', 'An error occurred, unable to create the calendar.'))
showError(this.$t('calendar', 'An error occurred, unable to create the calendar.'))
} finally {
this.showCreateCalendarSaving = false
this.showCreateCalendarLabel = true
Expand All @@ -219,7 +222,7 @@ export default {
})
} catch (error) {
console.debug(error)
this.$toast.error(this.$t('calendar', 'An error occurred, unable to create the calendar.'))
showError(this.$t('calendar', 'An error occurred, unable to create the calendar.'))
} finally {
this.showCreateCalendarTaskListSaving = false
this.showCreateCalendarTaskListLabel = true
Expand All @@ -244,7 +247,7 @@ export default {
hostname = url.hostname
} catch (error) {
console.error(error)
this.$toast.error(this.$t('calendar', 'Please enter a valid link (starting with http://, https://, webcal://, or webcals://)'))
showError(this.$t('calendar', 'Please enter a valid link (starting with http://, https://, webcal://, or webcals://)'))
return
}

Expand All @@ -256,7 +259,7 @@ export default {
})
} catch (error) {
console.debug(error)
this.$toast.error(this.$t('calendar', 'An error occurred, unable to create the calendar.'))
showError(this.$t('calendar', 'An error occurred, unable to create the calendar.'))
} finally {
this.showCreateSubscriptionSaving = false
this.showCreateSubscriptionLabel = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ import AppNavigationItem from '@nextcloud/vue/dist/Components/AppNavigationItem'
import {
generateRemoteUrl,
} from '@nextcloud/router'
import {
showSuccess,
showError,
} from '@nextcloud/dialogs'

export default {
name: 'PublicCalendarListItem',
Expand Down Expand Up @@ -167,7 +171,7 @@ export default {
this.showCopySubscriptionLinkSuccess = true
this.showCopySubscriptionLinkError = false

this.$toast.success(this.$t('calendar', 'Calendar link copied to clipboard.'))
showSuccess(this.$t('calendar', 'Calendar link copied to clipboard.'))
} catch (error) {
console.debug(error)
this.menuOpen = true
Expand All @@ -176,7 +180,7 @@ export default {
this.showCopySubscriptionLinkSuccess = false
this.showCopySubscriptionLinkError = true

this.$toast.error(this.$t('calendar', 'Calendar link could not be copied to clipboard.'))
showError(this.$t('calendar', 'Calendar link could not be copied to clipboard.'))
} finally {
setTimeout(() => {
this.showCopySubscriptionLinkLabel = true
Expand Down
8 changes: 6 additions & 2 deletions src/components/AppNavigation/EmbedTopNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ import {
mapGetters,
} from 'vuex'
import { generateRemoteUrl } from '@nextcloud/router'
import {
showSuccess,
showError,
} from '@nextcloud/dialogs'
import AppNavigationHeaderDatePicker from './AppNavigationHeader/AppNavigationHeaderDatePicker.vue'
import AppNavigationHeaderTodayButton from './EmbedHeader/EmbedHeaderTodayButton.vue'
Expand Down Expand Up @@ -75,10 +79,10 @@ export default {
// copy link for calendar to clipboard
try {
await this.$copyText(url)
this.$toast.success(this.$t('calendar', 'Calendar link copied to clipboard.'))
showSuccess(this.$t('calendar', 'Calendar link copied to clipboard.'))
} catch (error) {
console.debug(error)
this.$toast.error(this.$t('calendar', 'Calendar link could not be copied to clipboard.'))
showError(this.$t('calendar', 'Calendar link could not be copied to clipboard.'))
}
},
},
Expand Down
26 changes: 15 additions & 11 deletions src/components/AppNavigation/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ import {
mapState,
} from 'vuex'
import moment from '@nextcloud/moment'
import {
showSuccess,
showError,
} from '@nextcloud/dialogs'

import SettingsImportSection from './Settings/SettingsImportSection.vue'
import SettingsTimezoneSelect from './Settings/SettingsTimezoneSelect.vue'
Expand Down Expand Up @@ -210,7 +214,7 @@ export default {
this.savingBirthdayCalendar = false
} catch (error) {
console.error(error)
this.$toast.error(this.$t('calendar', 'New setting was not saved successfully.'))
showError(this.$t('calendar', 'New setting was not saved successfully.'))
this.savingBirthdayCalendar = false
}
},
Expand All @@ -222,7 +226,7 @@ export default {
this.savingEventLimit = false
} catch (error) {
console.error(error)
this.$toast.error(this.$t('calendar', 'New setting was not saved successfully.'))
showError(this.$t('calendar', 'New setting was not saved successfully.'))
this.savingEventLimit = false
}
},
Expand All @@ -234,7 +238,7 @@ export default {
this.savingTasks = false
} catch (error) {
console.error(error)
this.$toast.error(this.$t('calendar', 'New setting was not saved successfully.'))
showError(this.$t('calendar', 'New setting was not saved successfully.'))
this.savingTasks = false
}
},
Expand All @@ -246,7 +250,7 @@ export default {
this.savingPopover = false
} catch (error) {
console.error(error)
this.$toast.error(this.$t('calendar', 'New setting was not saved successfully.'))
showError(this.$t('calendar', 'New setting was not saved successfully.'))
this.savingPopover = false
}
},
Expand All @@ -258,7 +262,7 @@ export default {
this.savingWeekend = false
} catch (error) {
console.error(error)
this.$toast.error(this.$t('calendar', 'New setting was not saved successfully.'))
showError(this.$t('calendar', 'New setting was not saved successfully.'))
this.savingWeekend = false
}
},
Expand All @@ -273,7 +277,7 @@ export default {
this.savingWeekNumber = false
} catch (error) {
console.error(error)
this.$toast.error(this.$t('calendar', 'New setting was not saved successfully.'))
showError(this.$t('calendar', 'New setting was not saved successfully.'))
this.savingWeekNumber = false
}
},
Expand All @@ -297,7 +301,7 @@ export default {
this.savingSlotDuration = false
} catch (error) {
console.error(error)
this.$toast.error(this.$t('calendar', 'New setting was not saved successfully.'))
showError(this.$t('calendar', 'New setting was not saved successfully.'))
this.savingSlotDuration = false
}
},
Expand All @@ -307,10 +311,10 @@ export default {
async copyPrimaryCalDAV() {
try {
await this.$copyText(generateRemoteUrl('dav'))
this.$toast.success(this.$t('calendar', 'CalDAV link copied to clipboard.'))
showSuccess(this.$t('calendar', 'CalDAV link copied to clipboard.'))
} catch (error) {
console.debug(error)
this.$toast.error(this.$t('calendar', 'CalDAV link could not be copied to clipboard.'))
showError(this.$t('calendar', 'CalDAV link could not be copied to clipboard.'))
}

},
Expand All @@ -324,10 +328,10 @@ export default {

try {
await this.$copyText(url)
this.$toast.success(this.$t('calendar', 'CalDAV link copied to clipboard.'))
showSuccess(this.$t('calendar', 'CalDAV link copied to clipboard.'))
} catch (error) {
console.debug(error)
this.$toast.error(this.$t('calendar', 'CalDAV link could not be copied to clipboard.'))
showError(this.$t('calendar', 'CalDAV link could not be copied to clipboard.'))
}
},
/**
Expand Down
Loading

0 comments on commit aaa064a

Please sign in to comment.