Merge pull request #27265 from nextcloud/fix/private-class-properties

This commit is contained in:
John Molakvoæ 2021-06-02 18:58:44 +02:00 committed by GitHub
commit 9498f44d2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 170 additions and 168 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -23,10 +23,10 @@
export default class Setting { export default class Setting {
#close _close
#el _el
#name _name
#open _open
/** /**
* Create a new files app setting * Create a new files app setting
@ -38,32 +38,34 @@ export default class Setting {
* @param {Function} [component.close] callback for when setting is closed * @param {Function} [component.close] callback for when setting is closed
*/ */
constructor(name, { el, open, close }) { constructor(name, { el, open, close }) {
this.#name = name this._name = name
this.#el = el this._el = el
this.#open = open this._open = open
this.#close = close this._close = close
if (typeof this.#open !== 'function') {
this.#open = () => {} if (typeof this._open !== 'function') {
this._open = () => {}
} }
if (typeof this.#close !== 'function') {
this.#close = () => {} if (typeof this._close !== 'function') {
this._close = () => {}
} }
} }
get name() { get name() {
return this.#name return this._name
} }
get el() { get el() {
return this.#el return this._el
} }
get open() { get open() {
return this.#open return this._open
} }
get close() { get close() {
return this.#close return this._close
} }
} }

View File

@ -22,14 +22,14 @@
export default class Tab { export default class Tab {
#id _id
#name _name
#icon _icon
#mount _mount
#update _update
#destroy _destroy
#enabled _enabled
#scrollBottomReached _scrollBottomReached
/** /**
* Create a new tab instance * Create a new tab instance
@ -78,47 +78,47 @@ export default class Tab {
throw new Error('The scrollBottomReached argument should be a function') throw new Error('The scrollBottomReached argument should be a function')
} }
this.#id = id this._id = id
this.#name = name this._name = name
this.#icon = icon this._icon = icon
this.#mount = mount this._mount = mount
this.#update = update this._update = update
this.#destroy = destroy this._destroy = destroy
this.#enabled = enabled this._enabled = enabled
this.#scrollBottomReached = scrollBottomReached this._scrollBottomReached = scrollBottomReached
} }
get id() { get id() {
return this.#id return this._id
} }
get name() { get name() {
return this.#name return this._name
} }
get icon() { get icon() {
return this.#icon return this._icon
} }
get mount() { get mount() {
return this.#mount return this._mount
} }
get update() { get update() {
return this.#update return this._update
} }
get destroy() { get destroy() {
return this.#destroy return this._destroy
} }
get enabled() { get enabled() {
return this.#enabled return this._enabled
} }
get scrollBottomReached() { get scrollBottomReached() {
return this.#scrollBottomReached return this._scrollBottomReached
} }
} }

View File

@ -22,10 +22,10 @@
export default class Settings { export default class Settings {
#settings _settings
constructor() { constructor() {
this.#settings = [] this._settings = []
console.debug('OCA.Files.Settings initialized') console.debug('OCA.Files.Settings initialized')
} }
@ -37,11 +37,11 @@ export default class Settings {
* @returns {boolean} whether registering was successful * @returns {boolean} whether registering was successful
*/ */
register(view) { register(view) {
if (this.#settings.filter(e => e.name === view.name).length > 0) { if (this._settings.filter(e => e.name === view.name).length > 0) {
console.error('A setting with the same name is already registered') console.error('A setting with the same name is already registered')
return false return false
} }
this.#settings.push(view) this._settings.push(view)
return true return true
} }
@ -50,7 +50,7 @@ export default class Settings {
* @returns {OCA.Files.Settings.Setting[]} All currently registered settings * @returns {OCA.Files.Settings.Setting[]} All currently registered settings
*/ */
get settings() { get settings() {
return this.#settings return this._settings
} }
} }

View File

@ -22,18 +22,17 @@
export default class Sidebar { export default class Sidebar {
#state; _state;
#view;
constructor() { constructor() {
// init empty state // init empty state
this.#state = {} this._state = {}
// init default values // init default values
this.#state.tabs = [] this._state.tabs = []
this.#state.views = [] this._state.views = []
this.#state.file = '' this._state.file = ''
this.#state.activeTab = '' this._state.activeTab = ''
console.debug('OCA.Files.Sidebar initialized') console.debug('OCA.Files.Sidebar initialized')
} }
@ -45,7 +44,7 @@ export default class Sidebar {
* @returns {Object} the data state * @returns {Object} the data state
*/ */
get state() { get state() {
return this.#state return this._state
} }
/** /**
@ -56,9 +55,9 @@ export default class Sidebar {
* @returns {Boolean} * @returns {Boolean}
*/ */
registerTab(tab) { registerTab(tab) {
const hasDuplicate = this.#state.tabs.findIndex(check => check.id === tab.id) > -1 const hasDuplicate = this._state.tabs.findIndex(check => check.id === tab.id) > -1
if (!hasDuplicate) { if (!hasDuplicate) {
this.#state.tabs.push(tab) this._state.tabs.push(tab)
return true return true
} }
console.error(`An tab with the same id ${tab.id} already exists`, tab) console.error(`An tab with the same id ${tab.id} already exists`, tab)
@ -66,9 +65,9 @@ export default class Sidebar {
} }
registerSecondaryView(view) { registerSecondaryView(view) {
const hasDuplicate = this.#state.views.findIndex(check => check.id === view.id) > -1 const hasDuplicate = this._state.views.findIndex(check => check.id === view.id) > -1
if (!hasDuplicate) { if (!hasDuplicate) {
this.#state.views.push(view) this._state.views.push(view)
return true return true
} }
console.error('A similar view already exists', view) console.error('A similar view already exists', view)
@ -82,7 +81,7 @@ export default class Sidebar {
* @returns {String} the current opened file * @returns {String} the current opened file
*/ */
get file() { get file() {
return this.#state.file return this._state.file
} }
/** /**
@ -92,7 +91,7 @@ export default class Sidebar {
* @param {string} id the tab unique id * @param {string} id the tab unique id
*/ */
setActiveTab(id) { setActiveTab(id) {
this.#state.activeTab = id this._state.activeTab = id
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -27,7 +27,7 @@
export default class Share { export default class Share {
#share; _share;
/** /**
* Create the share object * Create the share object
@ -44,7 +44,7 @@ export default class Share {
ocsData.mail_send = !!ocsData.mail_send ocsData.mail_send = !!ocsData.mail_send
// store state // store state
this.#share = ocsData this._share = ocsData
} }
/** /**
@ -59,7 +59,7 @@ export default class Share {
* @memberof Sidebar * @memberof Sidebar
*/ */
get state() { get state() {
return this.#share return this._share
} }
/** /**
@ -70,7 +70,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get id() { get id() {
return this.#share.id return this._share.id
} }
/** /**
@ -81,7 +81,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get type() { get type() {
return this.#share.share_type return this._share.share_type
} }
/** /**
@ -93,7 +93,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get permissions() { get permissions() {
return this.#share.permissions return this._share.permissions
} }
/** /**
@ -104,7 +104,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
set permissions(permissions) { set permissions(permissions) {
this.#share.permissions = permissions this._share.permissions = permissions
} }
// SHARE OWNER -------------------------------------------------- // SHARE OWNER --------------------------------------------------
@ -116,7 +116,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get owner() { get owner() {
return this.#share.uid_owner return this._share.uid_owner
} }
/** /**
@ -127,7 +127,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get ownerDisplayName() { get ownerDisplayName() {
return this.#share.displayname_owner return this._share.displayname_owner
} }
// SHARED WITH -------------------------------------------------- // SHARED WITH --------------------------------------------------
@ -139,7 +139,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get shareWith() { get shareWith() {
return this.#share.share_with return this._share.share_with
} }
/** /**
@ -151,8 +151,8 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get shareWithDisplayName() { get shareWithDisplayName() {
return this.#share.share_with_displayname return this._share.share_with_displayname
|| this.#share.share_with || this._share.share_with
} }
/** /**
@ -164,8 +164,8 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get shareWithDisplayNameUnique() { get shareWithDisplayNameUnique() {
return this.#share.share_with_displayname_unique return this._share.share_with_displayname_unique
|| this.#share.share_with || this._share.share_with
} }
/** /**
@ -176,7 +176,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get shareWithLink() { get shareWithLink() {
return this.#share.share_with_link return this._share.share_with_link
} }
/** /**
@ -187,7 +187,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get shareWithAvatar() { get shareWithAvatar() {
return this.#share.share_with_avatar return this._share.share_with_avatar
} }
// SHARED FILE OR FOLDER OWNER ---------------------------------- // SHARED FILE OR FOLDER OWNER ----------------------------------
@ -199,7 +199,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get uidFileOwner() { get uidFileOwner() {
return this.#share.uid_file_owner return this._share.uid_file_owner
} }
/** /**
@ -211,8 +211,8 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get displaynameFileOwner() { get displaynameFileOwner() {
return this.#share.displayname_file_owner return this._share.displayname_file_owner
|| this.#share.uid_file_owner || this._share.uid_file_owner
} }
// TIME DATA ---------------------------------------------------- // TIME DATA ----------------------------------------------------
@ -224,7 +224,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get createdTime() { get createdTime() {
return this.#share.stime return this._share.stime
} }
/** /**
@ -235,7 +235,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get expireDate() { get expireDate() {
return this.#share.expiration return this._share.expiration
} }
/** /**
@ -246,7 +246,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
set expireDate(date) { set expireDate(date) {
this.#share.expiration = date this._share.expiration = date
} }
// EXTRA DATA --------------------------------------------------- // EXTRA DATA ---------------------------------------------------
@ -258,7 +258,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get token() { get token() {
return this.#share.token return this._share.token
} }
/** /**
@ -269,7 +269,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get note() { get note() {
return this.#share.note return this._share.note
} }
/** /**
@ -279,7 +279,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
set note(note) { set note(note) {
this.#share.note = note this._share.note = note
} }
/** /**
@ -291,7 +291,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get label() { get label() {
return this.#share.label return this._share.label
} }
/** /**
@ -302,7 +302,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
set label(label) { set label(label) {
this.#share.label = label this._share.label = label
} }
/** /**
@ -313,7 +313,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get mailSend() { get mailSend() {
return this.#share.mail_send === true return this._share.mail_send === true
} }
/** /**
@ -324,7 +324,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get hideDownload() { get hideDownload() {
return this.#share.hide_download === true return this._share.hide_download === true
} }
/** /**
@ -334,7 +334,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
set hideDownload(state) { set hideDownload(state) {
this.#share.hide_download = state === true this._share.hide_download = state === true
} }
/** /**
@ -345,7 +345,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get password() { get password() {
return this.#share.password return this._share.password
} }
/** /**
@ -355,7 +355,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
set password(password) { set password(password) {
this.#share.password = password this._share.password = password
} }
/** /**
@ -366,7 +366,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get sendPasswordByTalk() { get sendPasswordByTalk() {
return this.#share.send_password_by_talk return this._share.send_password_by_talk
} }
/** /**
@ -377,7 +377,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
set sendPasswordByTalk(sendPasswordByTalk) { set sendPasswordByTalk(sendPasswordByTalk) {
this.#share.send_password_by_talk = sendPasswordByTalk this._share.send_password_by_talk = sendPasswordByTalk
} }
// SHARED ITEM DATA --------------------------------------------- // SHARED ITEM DATA ---------------------------------------------
@ -389,7 +389,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get path() { get path() {
return this.#share.path return this._share.path
} }
/** /**
@ -400,7 +400,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get itemType() { get itemType() {
return this.#share.item_type return this._share.item_type
} }
/** /**
@ -411,7 +411,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get mimetype() { get mimetype() {
return this.#share.mimetype return this._share.mimetype
} }
/** /**
@ -422,7 +422,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get fileSource() { get fileSource() {
return this.#share.file_source return this._share.file_source
} }
/** /**
@ -435,7 +435,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get fileTarget() { get fileTarget() {
return this.#share.file_target return this._share.file_target
} }
/** /**
@ -446,7 +446,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get fileParent() { get fileParent() {
return this.#share.file_parent return this._share.file_parent
} }
// PERMISSIONS Shortcuts // PERMISSIONS Shortcuts
@ -517,7 +517,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get canEdit() { get canEdit() {
return this.#share.can_edit === true return this._share.can_edit === true
} }
/** /**
@ -528,7 +528,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get canDelete() { get canDelete() {
return this.#share.can_delete === true return this._share.can_delete === true
} }
/** /**
@ -538,7 +538,7 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get viaFileid() { get viaFileid() {
return this.#share.via_fileid return this._share.via_fileid
} }
/** /**
@ -548,29 +548,29 @@ export default class Share {
* @memberof Share * @memberof Share
*/ */
get viaPath() { get viaPath() {
return this.#share.via_path return this._share.via_path
} }
// TODO: SORT THOSE PROPERTIES // TODO: SORT THOSE PROPERTIES
get parent() { get parent() {
return this.#share.parent return this._share.parent
} }
get storageId() { get storageId() {
return this.#share.storage_id return this._share.storage_id
} }
get storage() { get storage() {
return this.#share.storage return this._share.storage
} }
get itemSource() { get itemSource() {
return this.#share.item_source return this._share.item_source
} }
get status() { get status() {
return this.#share.status return this._share.status
} }
} }

View File

@ -22,14 +22,14 @@
export default class ExternalLinkActions { export default class ExternalLinkActions {
#state; _state;
constructor() { constructor() {
// init empty state // init empty state
this.#state = {} this._state = {}
// init default values // init default values
this.#state.actions = [] this._state.actions = []
console.debug('OCA.Sharing.ExternalLinkActions initialized') console.debug('OCA.Sharing.ExternalLinkActions initialized')
} }
@ -41,7 +41,7 @@ export default class ExternalLinkActions {
* @returns {Object} the data state * @returns {Object} the data state
*/ */
get state() { get state() {
return this.#state return this._state
} }
/** /**
@ -53,7 +53,7 @@ export default class ExternalLinkActions {
*/ */
registerAction(action) { registerAction(action) {
if (typeof action === 'object' && action.icon && action.name && action.url) { if (typeof action === 'object' && action.icon && action.name && action.url) {
this.#state.actions.push(action) this._state.actions.push(action)
return true return true
} }
console.error('Invalid action provided', action) console.error('Invalid action provided', action)

View File

@ -22,14 +22,14 @@
export default class ShareSearch { export default class ShareSearch {
#state; _state;
constructor() { constructor() {
// init empty state // init empty state
this.#state = {} this._state = {}
// init default values // init default values
this.#state.results = [] this._state.results = []
console.debug('OCA.Sharing.ShareSearch initialized') console.debug('OCA.Sharing.ShareSearch initialized')
} }
@ -41,7 +41,7 @@ export default class ShareSearch {
* @returns {Object} the data state * @returns {Object} the data state
*/ */
get state() { get state() {
return this.#state return this._state
} }
/** /**
@ -61,7 +61,7 @@ export default class ShareSearch {
addNewResult(result) { addNewResult(result) {
if (result.displayName.trim() !== '' if (result.displayName.trim() !== ''
&& typeof result.handler === 'function') { && typeof result.handler === 'function') {
this.#state.results.push(result) this._state.results.push(result)
return true return true
} }
console.error('Invalid search result provided', result) console.error('Invalid search result provided', result)

View File

@ -22,21 +22,21 @@
export default class TabSections { export default class TabSections {
#sections; _sections;
constructor() { constructor() {
this.#sections = [] this._sections = []
} }
/** /**
* @param {registerSectionCallback} section To be called to mount the section to the sharing sidebar * @param {registerSectionCallback} section To be called to mount the section to the sharing sidebar
*/ */
registerSection(section) { registerSection(section) {
this.#sections.push(section) this._sections.push(section)
} }
getSections() { getSections() {
return this.#sections return this._sections
} }
} }