-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of 2966 bucket configure (#36)
* 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
Showing
10 changed files
with
408 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.