Skip to content

Commit

Permalink
refactor(SharingSidebarView): Use NC logger & sort imports
Browse files Browse the repository at this point in the history
Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
  • Loading branch information
nfebe committed Jul 4, 2024
1 parent 3982037 commit f9b1b19
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@nextcloud/files": "^3.1.1",
"@nextcloud/initial-state": "^2.1.0",
"@nextcloud/l10n": "^2.2.0",
"@nextcloud/logger": "^3.0.2",
"@nextcloud/router": "^3.0.0",
"@nextcloud/vue": "^8.12.0",
"nextcloud-server": "^0.15.10",
Expand Down
7 changes: 4 additions & 3 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import ACL_PROPERTIES from './model/Properties.js'
import Rule from './model/Rule.js'
import logger from './services/logger.ts'

/**
* @member {OC.Files.Client} client
Expand Down Expand Up @@ -263,16 +264,16 @@ class AclDavService {
return response
} else if (response.status === 403) {
// Handle permission denied scenario
console.error('Permission denied:', response.status, response.statusText)
logger.error('Permission denied:', { responseStatus: response.status, responseStatusText: response.statusText })
throw new Error(t('groupfolders', 'Permission denied. User does not have sufficient permissions.'))
} else {
// Handle unexpected status codes
console.error('Unexpected status:', response.status, response.statusText)
logger.error('Unexpected status:', { responseStatus: response.status, responseStatusText: response.statusText })
throw new Error(t('groupfolders', 'Unexpected status from server'))
}
}).catch(error => {
// Handle network errors or exceptions
console.error('Error in propPatch:', error)
logger.error('Error in propPatch:', { error })
throw error
})
}
Expand Down
23 changes: 12 additions & 11 deletions src/components/SharingSidebarView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,21 @@
</template>

<script>
import Vue from 'vue'
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'
import AclStateButton, { STATES } from './AclStateButton.vue'
import { showError } from '@nextcloud/dialogs'
import Rule from './../model/Rule.js'
import BinaryTools from './../BinaryTools.js'
import client from './../client.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import { generateUrl } from '@nextcloud/router'
import NcAvatar from '@nextcloud/vue/dist/Components/NcAvatar.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip.js'
import Plus from 'vue-material-design-icons/Plus.vue'
import Vue from 'vue'
import Close from 'vue-material-design-icons/Close.vue'
import Plus from 'vue-material-design-icons/Plus.vue'
import logger from '../services/logger.ts'
import BinaryTools from './../BinaryTools.js'
import client from './../client.js'
import Rule from './../model/Rule.js'
import AclStateButton, { STATES } from './AclStateButton.vue'

let searchRequestCancelSource = null

Expand Down Expand Up @@ -320,7 +321,7 @@ export default {
})
}).catch((error) => {
if (!axios.isCancel(error)) {
console.error('Failed to search results for groupfolder ACL')
logger.error('Failed to search results for groupfolder ACL')
}
})
},
Expand Down Expand Up @@ -379,9 +380,9 @@ export default {
this.loading = true
try {
await client.propPatch(this.model, this.list.filter(rule => !rule.inherited))
console.debug('Permissions updated successfully')
logger.debug('Permissions updated successfully')
} catch (error) {
console.error('Failed to save changes:', error)
logger.error('Failed to save changes:', { error })
Vue.set(this.list, index, itemRestorePoint)
showError(error)
} finally {
Expand Down
6 changes: 6 additions & 0 deletions src/services/logger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { getLoggerBuilder } from '@nextcloud/logger'

export default getLoggerBuilder()
.setApp('groupfolders')
.detectUser()
.build()

0 comments on commit f9b1b19

Please sign in to comment.