ProviderStore.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. Copyright (C) 2017 Cloudbase Solutions SRL
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. import alt from '../alt'
  15. import ProviderActions from '../actions/ProviderActions'
  16. class ProviderStore {
  17. constructor() {
  18. this.connectionInfoSchema = []
  19. this.providers = null
  20. this.providersLoading = false
  21. this.optionsSchema = []
  22. this.optionsSchemaLoading = false
  23. this.bindListeners({
  24. handleGetConnectionInfoSchemaSuccess: ProviderActions.GET_CONNECTION_INFO_SCHEMA_SUCCESS,
  25. handleLoadProviders: ProviderActions.LOAD_PROVIDERS,
  26. handleLoadProvidersSuccess: ProviderActions.LOAD_PROVIDERS_SUCCESS,
  27. handleLoadOptionsSchema: ProviderActions.LOAD_OPTIONS_SCHEMA,
  28. handleLoadOptionsSchemaSuccess: ProviderActions.LOAD_OPTIONS_SCHEMA_SUCCESS,
  29. handleLoadOptionsSchemaFailed: ProviderActions.LOAD_OPTIONS_SCHEMA_FAILED,
  30. })
  31. }
  32. handleGetConnectionInfoSchemaSuccess(schema) {
  33. this.connectionInfoSchema = schema
  34. }
  35. handleLoadProviders() {
  36. this.providers = null
  37. this.providersLoading = true
  38. }
  39. handleLoadProvidersSuccess(providers) {
  40. this.providers = providers
  41. this.providersLoading = false
  42. }
  43. handleLoadOptionsSchema() {
  44. this.optionsSchemaLoading = true
  45. }
  46. handleLoadOptionsSchemaSuccess(schema) {
  47. this.optionsSchemaLoading = false
  48. this.optionsSchema = schema
  49. }
  50. handleLoadOptionsSchemaFailed() {
  51. this.optionsSchemaLoading = false
  52. }
  53. }
  54. export default alt.createStore(ProviderStore)