You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Settings.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * @copyright Copyright (c) 2019 Gary Kim <gary@garykim.dev>
  3. *
  4. * @author Gary Kim <gary@garykim.dev>
  5. *
  6. * @license AGPL-3.0-or-later
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. export default class Settings {
  23. _settings
  24. constructor() {
  25. this._settings = []
  26. console.debug('OCA.Files.Settings initialized')
  27. }
  28. /**
  29. * Register a new setting
  30. *
  31. * @since 19.0.0
  32. * @param {OCA.Files.Settings.Setting} view element to add to settings
  33. * @return {boolean} whether registering was successful
  34. */
  35. register(view) {
  36. if (this._settings.filter(e => e.name === view.name).length > 0) {
  37. console.error('A setting with the same name is already registered')
  38. return false
  39. }
  40. this._settings.push(view)
  41. return true
  42. }
  43. /**
  44. * All settings elements
  45. *
  46. * @return {OCA.Files.Settings.Setting[]} All currently registered settings
  47. */
  48. get settings() {
  49. return this._settings
  50. }
  51. }