diff --git a/pkg/interface/src/api/global.ts b/pkg/interface/src/api/global.ts index 9a06e48b5..3e37a5a07 100644 --- a/pkg/interface/src/api/global.ts +++ b/pkg/interface/src/api/global.ts @@ -11,6 +11,7 @@ import GroupsApi from './groups'; import LaunchApi from './launch'; import LinksApi from './links'; import PublishApi from './publish'; +import S3Api from './s3'; export default class GlobalApi extends BaseApi { chat = new ChatApi(this.ship, this.channel, this.store); @@ -22,6 +23,7 @@ export default class GlobalApi extends BaseApi { launch = new LaunchApi(this.ship, this.channel, this.store); links = new LinksApi(this.ship, this.channel, this.store); publish = new PublishApi(this.ship, this.channel, this.store); + s3 = new S3Api(this.ship, this.channel, this.store); constructor(public ship: Patp, public channel: any, public store: GlobalStore) { diff --git a/pkg/interface/src/api/s3.ts b/pkg/interface/src/api/s3.ts new file mode 100644 index 000000000..800548093 --- /dev/null +++ b/pkg/interface/src/api/s3.ts @@ -0,0 +1,37 @@ +import BaseApi from './base'; +import { StoreState } from '../store/type'; +import {S3Update} from '../types/s3-update'; + + +export default class S3Api extends BaseApi { + + setCurrentBucket(bucket: string) { + this.s3Action({ 'set-current-bucket': bucket }); + } + + addBucket(bucket: string) { + this.s3Action({ 'add-bucket': bucket }); + } + + removeBucket(bucket: string) { + this.s3Action({ 'remove-bucket': bucket }); + } + + setEndpoint(endpoint: string) { + this.s3Action({ setEndpoint: endpoint }); + } + + setAccessKeyId(accessKeyId: string) { + this.s3Action({ setAccessKeyId: accessKeyId }); + } + + setSecretAccessKey(secretAccessKey: string) { + this.s3Action({ setSecretAccessKey: secretAccessKey }); + } + + private s3Action(data: any) { + this.action('s3-store', 's3-action', data); + } + +} + diff --git a/pkg/interface/src/reducers/s3-update.ts b/pkg/interface/src/reducers/s3-update.ts index 1915feec1..8793c5b44 100644 --- a/pkg/interface/src/reducers/s3-update.ts +++ b/pkg/interface/src/reducers/s3-update.ts @@ -40,7 +40,7 @@ export default class S3Reducer { currentBucket(json: S3Update, state: S) { const data = _.get(json, 'setCurrentBucket', false); if (data && state.s3) { - + state.s3.configuration.currentBucket = data; } }