mirror of
https://github.com/tloncorp/landscape.git
synced 2025-01-04 14:53:26 +03:00
Add region to s3 settings
This commit is contained in:
parent
46ffee3c20
commit
176c2df561
@ -17,6 +17,7 @@ interface CredentialsSubmit {
|
|||||||
endpoint: string;
|
endpoint: string;
|
||||||
accessId: string;
|
accessId: string;
|
||||||
accessSecret: string;
|
accessSecret: string;
|
||||||
|
region: string;
|
||||||
bucket: string;
|
bucket: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,6 +39,11 @@ export const StoragePrefs = () => {
|
|||||||
api.poke(setAccessKeyId(data.accessId));
|
api.poke(setAccessKeyId(data.accessId));
|
||||||
api.poke(setSecretAccessKey(data.accessSecret));
|
api.poke(setSecretAccessKey(data.accessSecret));
|
||||||
api.poke(setCurrentBucket(data.bucket));
|
api.poke(setCurrentBucket(data.bucket));
|
||||||
|
api.poke({
|
||||||
|
app: 's3-store',
|
||||||
|
mark: 's3-action',
|
||||||
|
json: { 'set-region': data.region },
|
||||||
|
});
|
||||||
}, [])
|
}, [])
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -113,6 +119,20 @@ export const StoragePrefs = () => {
|
|||||||
className="input default-ring bg-gray-50"
|
className="input default-ring bg-gray-50"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="mb-8 flex flex-col space-y-2">
|
||||||
|
<label className="font-semibold" htmlFor="region">
|
||||||
|
Region<span title="Required field">*</span>
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
disabled={!loaded}
|
||||||
|
required
|
||||||
|
id="region"
|
||||||
|
type="text"
|
||||||
|
defaultValue={s3.configuration?.region}
|
||||||
|
{...register('region', { required: true })}
|
||||||
|
className="input default-ring bg-gray-50"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<div className="mb-8 flex flex-col space-y-2">
|
<div className="mb-8 flex flex-col space-y-2">
|
||||||
<label className="font-semibold" htmlFor="bucket">
|
<label className="font-semibold" htmlFor="bucket">
|
||||||
Bucket Name<span title="Required field">*</span>
|
Bucket Name<span title="Required field">*</span>
|
||||||
|
@ -18,7 +18,8 @@ const configuration = (json: S3Update, state: StorageState): StorageState => {
|
|||||||
if (data) {
|
if (data) {
|
||||||
state.s3.configuration = {
|
state.s3.configuration = {
|
||||||
buckets: new Set(data.buckets),
|
buckets: new Set(data.buckets),
|
||||||
currentBucket: data.currentBucket
|
currentBucket: data.currentBucket,
|
||||||
|
region: data.region,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
@ -32,6 +33,14 @@ const currentBucket = (json: S3Update, state: StorageState): StorageState => {
|
|||||||
return state;
|
return state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const region = (json: S3Update, state: StorageState): StorageState => {
|
||||||
|
const data = _.get(json, 'setRegion', false);
|
||||||
|
if (data && state.s3) {
|
||||||
|
state.s3.configuration.region = data;
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
};
|
||||||
|
|
||||||
const addBucket = (json: S3Update, state: StorageState): StorageState => {
|
const addBucket = (json: S3Update, state: StorageState): StorageState => {
|
||||||
const data = _.get(json, 'addBucket', false);
|
const data = _.get(json, 'addBucket', false);
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -81,5 +90,6 @@ export const reduce = [
|
|||||||
removeBucket,
|
removeBucket,
|
||||||
endpoint,
|
endpoint,
|
||||||
accessKeyId,
|
accessKeyId,
|
||||||
secretAccessKey
|
secretAccessKey,
|
||||||
|
region
|
||||||
];
|
];
|
||||||
|
@ -28,6 +28,7 @@ export interface BaseStorageState {
|
|||||||
configuration: {
|
configuration: {
|
||||||
buckets: Set<string>;
|
buckets: Set<string>;
|
||||||
currentBucket: string;
|
currentBucket: string;
|
||||||
|
region: string;
|
||||||
};
|
};
|
||||||
credentials: S3Credentials | null;
|
credentials: S3Credentials | null;
|
||||||
};
|
};
|
||||||
@ -65,7 +66,8 @@ export const useStorageState = createState<BaseStorageState>(
|
|||||||
s3: {
|
s3: {
|
||||||
configuration: {
|
configuration: {
|
||||||
buckets: new Set(),
|
buckets: new Set(),
|
||||||
currentBucket: ''
|
currentBucket: '',
|
||||||
|
region: 'global'
|
||||||
},
|
},
|
||||||
credentials: null
|
credentials: null
|
||||||
}
|
}
|
||||||
@ -84,4 +86,4 @@ export const useStorageState = createState<BaseStorageState>(
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
export default useStorageState;
|
export default useStorageState;
|
||||||
|
Loading…
Reference in New Issue
Block a user