Skip to content

Commit

Permalink
Implementation of 2966 bucket configure (#36)
Browse files Browse the repository at this point in the history
* Adding bucket config dialog and form. Dialog and form support create a new bucket and update. Form contains required bucket fields, submit and cancel.

* Removing $ - global in dialog visible and unnecessary eslint comment.

* Fixing the x close dialog

* Removing apply button disable support as it is not working at the moment

* Adding support for color-border: red for invalid input

* Removing update bucket config header and using newBucket instead for dialog

* Adding yup/schema and fixing form validation before submit. Refactoring of TextInput to support validation.

* Final commit - import ordering fix

* Replacing asterisk yup import

* Updating with new yup dependency

* Adding password component to support redacted for access and secret keys. Reordering imports and removing async.

* Removing space conditifion for redacted check

* Removed unnecessary div for dialog

* Fixed alphabetical emit ordering

* Fixed @ reference recommended vs relative.

* Removing isUpdate flag

* Removing isUpdate flag 2

* Fixed bucketConfigTitle set via ternary operator

* Removed console.log

* Deleting BucketConfigForm and putting Dialog inside of BucketList. Removing the rest of the isUpdate logic.

* Fixed import ordering, extra newline, replaced primeflex margins, relative path changed to an absolute, removed invalid attribute

* Removed extra line
  • Loading branch information
bcgv123 authored Feb 16, 2023
1 parent 6ee4070 commit bbb79bd
Show file tree
Hide file tree
Showing 10 changed files with 408 additions and 31 deletions.
73 changes: 72 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"primevue": "^3.21.0",
"vee-validate": "^4.7.1",
"vue": "^3.2.41",
"vue-router": "^4.1.5"
"vue-router": "^4.1.5",
"yup": "^1.0.0"
},
"devDependencies": {
"@pinia/testing": "^0.0.14",
Expand Down
148 changes: 148 additions & 0 deletions frontend/src/components/bucket/BucketConfigForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<script setup lang="ts">
import Button from 'primevue/button';
import { Form } from 'vee-validate';
import { object, string } from 'yup';
import { useToast } from 'primevue/usetoast';
import Password from '@/components/form/Password.vue';
import TextInput from '@/components/form/TextInput.vue';
import { useBucketStore } from '@/store';
import type { Bucket } from '@/interfaces';
const props = defineProps<{
bucket?: Bucket;
}>();
const bucketStore = useBucketStore();
const toast = useToast();
const emit = defineEmits(['cancel-bucket-config', 'submit-bucket-config']);
const initialValues = {
bucketName: props.bucket?.bucketName,
bucket: props.bucket?.bucket,
endpoint: props.bucket?.endpoint,
accessKeyId: props.bucket?.accessKeyId,
secretAccessKey: props.bucket?.secretAccessKey,
key: props.bucket?.key
};
const schema = object({
bucketName: string().max(255).required().label('Bucket name'),
bucket: string().max(255).required().label('Bucket'),
endpoint: string().max(255).required().label('Endpoint'),
accessKeyId: string().max(255).required().label('Access Key ID'),
secretAccessKey: string().max(255).required().label('Secret Access Key'),
key: string().max(255).required().label('Key'),
});
const onSubmit = async (values: any) => {
try {
const formBucket = {
bucketName: values.bucketName,
bucket: values.bucket,
endpoint: values.endpoint,
accessKeyId: values.accessKeyId !== 'REDACTED' ? values.accessKeyId : undefined,
secretAccessKey:
values.secretAccessKey !== 'REDACTED' ? values.secretAccessKey : undefined,
key: values.key,
active: true
} as Bucket;
props.bucket ?
await bucketStore.updateBucket(props.bucket!.bucketId, formBucket) :
await bucketStore.createBucket(formBucket);
await bucketStore.load();
emit('submit-bucket-config');
toast.add(
{
severity: 'success',
summary: 'Success',
detail: 'Bucket configuration successful',
life: 3000
}
);
} catch (error: any) {
emit('cancel-bucket-config');
toast.add(
{
severity: 'error',
summary: 'Bucket configuration was not successful',
detail: error,
life: 5000
}
);
}
};
const onCancel = () => {
emit('cancel-bucket-config');
};
</script>

<template>
<div>
<Form
:initial-values="initialValues"
:validation-schema="schema"
@submit="onSubmit"
>
<TextInput
name="bucketName"
label="Bucket name (what other users will see)"
/>
<TextInput
name="bucket"
label="Bucket"
/>
<TextInput
name="endpoint"
label="Endpoint"
/>
<Password
name="accessKeyId"
label="Access key Identifier"
/>
<Password
name="secretAccessKey"
label="Secret access key"
/>
<TextInput
name="key"
label="Key"
/>
<Button
class="mt-2"
label="Apply"
type="submit"
icon="pi pi-check"
autofocus
/>
<Button
class="p-button-text mt-2"
label="Cancel"
icon="pi pi-times"
@click="onCancel"
/>
</Form>
</div>
</template>

<style lang="scss" scoped>
:deep(.p-inputtext) {
width: 65% !important;
}
:deep(.pi-eye) {
right: auto !important;
margin-left: 10px;
}
:deep(.pi-eye-slash) {
right: auto !important;
margin-left: 10px;
}
</style>
72 changes: 68 additions & 4 deletions frontend/src/components/bucket/BucketList.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import BucketsTable from './BucketsTable.vue';
import BucketsSidebar from './BucketsSidebar.vue';
import Button from 'primevue/button';
import Dialog from 'primevue/dialog';
import { ref, onMounted, Ref } from 'vue';
import { BucketConfig as BucketConfigConst } from '@/utils/constants';
import BucketConfigForm from '@/components/bucket/BucketConfigForm.vue';
import BucketsSidebar from '@/components/bucket/BucketsSidebar.vue';
import BucketsTable from '@/components/bucket/BucketsTable.vue';
import { useBucketStore } from '@/store';
import { useToaster } from '@/composables/useToaster';
import type { Bucket } from '@/interfaces';
const bucketStore = useBucketStore();
const displayInfo: any = ref(null);
const displayBucketConfig: Ref<boolean> = ref(false);
const bucketConfigHeader: Ref<string> = ref('');
const bucketConfigTitle: Ref<string> = ref('');
const bucketToUpdate: Ref<Bucket | undefined> = ref(undefined);
const showInfo = async (bucketId: any) => {
displayInfo.value = await bucketStore.getBucketInfo(bucketId);
};
Expand All @@ -17,6 +27,17 @@ const closeInfo = () => {
displayInfo.value = null;
};
const showBucketConfig = (bucket?: Bucket) => {
bucketConfigHeader.value = BucketConfigConst.headerNewBucket;
bucketConfigTitle.value = bucket ? bucket.bucketName : BucketConfigConst.titleNewBucket;
bucketToUpdate.value = bucket;
displayBucketConfig.value = true;
};
const closeBucketConfig = () => {
displayBucketConfig.value = false;
};
onMounted(() => {
useToaster(bucketStore.load, { summary: 'Unable to load buckets.' });
});
Expand All @@ -28,9 +49,47 @@ onMounted(() => {
<h1>Select a bucket</h1>
<h3>Buckets are containers for storing objects.</h3>
</div>
<div>
<Button
label="Primary"
class="p-button-outlined mt-4"
@click="showBucketConfig()"
>
<font-awesome-icon icon="fa-solid fa-plus" />
Configure new bucket
</Button>
<Dialog
:visible="displayBucketConfig"
:style="{width: '50vw'}"
:modal="true"
@update:visible="closeBucketConfig"
>
<template #header>
<div class="flex">
<font-awesome-icon
icon="fas fa-cog"
class="pr-3 pt-2"
style="font-size: 2rem"
/>
<div>
<h1>{{ bucketConfigHeader }}</h1>
<h3>{{ bucketConfigTitle }}</h3>
</div>
</div>
</template>
<BucketConfigForm
:bucket="bucketToUpdate"
@submit-bucket-config="closeBucketConfig"
@cancel-bucket-config="closeBucketConfig"
/>
</Dialog>
</div>
<div class="flex mt-7">
<div class="flex-grow-1">
<BucketsTable @show-info="showInfo" />
<BucketsTable
@show-info="showInfo"
@show-bucket-config="showBucketConfig"
/>
</div>
<div
v-if="displayInfo"
Expand All @@ -54,4 +113,9 @@ h1 {
h3 {
font-weight: bold;
}
button {
float: right;
text-indent: 10px;
}
</style>
Loading

0 comments on commit bbb79bd

Please sign in to comment.