Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of 2966 bucket configure #36

Merged
merged 22 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5088a90
Adding bucket config dialog and form. Dialog and form support create …
Feb 9, 2023
c5612ff
Removing $ - global in dialog visible and unnecessary eslint comment.
Feb 9, 2023
ecd24d3
Fixing the x close dialog
Feb 10, 2023
93c2ad7
Removing apply button disable support as it is not working at the moment
Feb 10, 2023
a8ac418
Adding support for color-border: red for invalid input
Feb 10, 2023
8dc1e47
Removing update bucket config header and using newBucket instead for …
Feb 13, 2023
8204c39
Adding yup/schema and fixing form validation before submit. Refactori…
Feb 13, 2023
ac44835
Final commit - import ordering fix
Feb 14, 2023
2bf7f74
Replacing asterisk yup import
Feb 14, 2023
d2ac2b5
Updating with new yup dependency
Feb 14, 2023
8dad7f6
Adding password component to support redacted for access and secret k…
Feb 15, 2023
e6d7a40
Removing space conditifion for redacted check
Feb 15, 2023
6eb3d2d
Removed unnecessary div for dialog
Feb 15, 2023
136650f
Fixed alphabetical emit ordering
Feb 15, 2023
ab76b4b
Fixed @ reference recommended vs relative.
Feb 15, 2023
a4495cb
Removing isUpdate flag
Feb 15, 2023
70de82b
Removing isUpdate flag 2
Feb 15, 2023
eccde9e
Fixed bucketConfigTitle set via ternary operator
Feb 15, 2023
154e0d0
Removed console.log
Feb 15, 2023
95edc24
Deleting BucketConfigForm and putting Dialog inside of BucketList. Re…
Feb 16, 2023
b828312
Fixed import ordering, extra newline, replaced primeflex margins, rel…
Feb 16, 2023
1486ad3
Removed extra line
Feb 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
48 changes: 48 additions & 0 deletions frontend/src/components/bucket/BucketConfigDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<script setup lang="ts">
import Dialog from 'primevue/dialog';
import BucketConfigForm from '@/components/bucket/BucketConfigForm.vue';
import type { Bucket } from '@/interfaces';

const props = defineProps<{
display: boolean;
header: string;
title: string;
isUpdate: boolean;
bucket?: Bucket;
}>();

const emit = defineEmits(['close-bucket-config']);

const closeDialog = () => {
emit('close-bucket-config');
};
</script>

<template>
<Dialog
:visible="props.display"
:style="{width: '50vw'}"
:modal="true"
@update:visible="closeDialog"
>
<template #header>
<div class="flex">
<font-awesome-icon
icon="fas fa-cog"
class="pr-3 pt-2"
style="font-size: 2rem"
/>
<div>
<h1>{{ header }}</h1>
<h3>{{ title }}</h3>
</div>
</div>
</template>
<BucketConfigForm
:is-update="props.isUpdate"
:bucket="props.bucket"
@submit-bucket-config="closeDialog"
@cancel-bucket-config="closeDialog"
/>
</Dialog>
</template>
152 changes: 152 additions & 0 deletions frontend/src/components/bucket/BucketConfigForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
<script setup lang="ts">
import Button from 'primevue/button';
import { Form } from 'vee-validate';
import { object, string } from 'yup';
import { useBucketStore } from '@/store';
import { useToast } from 'primevue/usetoast';
import Password from '@/components/form/Password.vue';
import TextInput from '@/components/form/TextInput.vue';
bcgv123 marked this conversation as resolved.
Show resolved Hide resolved
import type { Bucket } from '@/interfaces';

const props = defineProps<{
isUpdate: boolean;
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.isUpdate ?
await bucketStore.updateBucket(props.bucket!.bucketId, formBucket) :
bcgv123 marked this conversation as resolved.
Show resolved Hide resolved
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
label="Apply"
type="submit"
icon="pi pi-check"
autofocus
/>
<Button
label="Cancel"
icon="pi pi-times"
class="p-button-text"
@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;
}

button {
margin-top: 20px;
}
bcgv123 marked this conversation as resolved.
Show resolved Hide resolved
</style>
Loading