Skip to content

Commit

Permalink
feat: improve secrets dialog #2
Browse files Browse the repository at this point in the history
Signed-off-by: seven <[email protected]>
  • Loading branch information
Blankll committed Feb 22, 2024
1 parent aa5d534 commit 82378b4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
10 changes: 10 additions & 0 deletions src/views/secret/components/key-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ const { secrets } = toRefs(secretStore);
</script>

<style lang="scss" scoped>
.secret-list {
display: flex;
flex-wrap: wrap;
gap: 16px;
padding: 16px;
}
.secret-list .n-card:hover {
cursor: pointer;
}
.n-card {
max-width: 300px;
}
Expand Down
39 changes: 11 additions & 28 deletions src/views/secret/components/new-key-dialog.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<template>
<n-modal v-model:show="showModal">
<n-modal v-model:show="showModal" @esc="closeModal" @mask-click="closeModal">
<n-card
style="width: 600px"
role="dialog"
aria-modal="true"
:title="modalTitle"
:bordered="false"
class="secret-modal-card"
@mask-click="closeModal"
>
<template #header-extra>
<n-icon size="26" @click="closeModal">
Expand All @@ -16,7 +15,7 @@
</template>
<div class="modal-content">
<n-form
ref="connectFormRef"
ref="secretFormRef"
label-placement="left"
label-width="100"
:model="formData"
Expand All @@ -31,7 +30,7 @@
</n-grid>
</n-form>
</div>
<n-tabs type="line" animated>
<n-tabs type="line" animated class="secret-tabs">
<n-tab-pane name="sshKeys" tab="SSH Keys">
<n-grid cols="8" item-responsive responsive="screen" x-gap="10" y-gap="10">
<n-grid-item span="8">
Expand Down Expand Up @@ -115,7 +114,7 @@ const { saveSecret } = secretStore;
const lang = useLang();
// DOM
const connectFormRef = ref();
const secretFormRef = ref();
const showModal = ref(false);
const modalTitle = ref(lang.t('secret.new'));
Expand Down Expand Up @@ -151,39 +150,20 @@ const showMedal = (secret: Secret | null) => {
};
const closeModal = () => {
if (formData.value) {
formData.value = defaultFormData;
}
formData.value = defaultFormData;
showModal.value = false;
};
const validationPassed = watch(formData.value, async () => {
try {
return await connectFormRef.value?.validate((errors: Array<FormValidationError>) => !errors);
return await secretFormRef.value?.validate((errors: Array<FormValidationError>) => !errors);
} catch (e) {
return false;
}
});
// const verify = async (event: MouseEvent) => {
// event.preventDefault();
// testLoading.value = !testLoading.value;
// try {
// // @TODO: verify secret
// // await testConnection({ ...formData.value });
// message.success(lang.t('connection.testSuccess'));
// } catch (e) {
// const error = e as CustomError;
// message.error(`status: ${error.status}, details: ${error.details}`, {
// closable: true,
// keepAliveOnHover: true,
// duration: 10000,
// });
// } finally {
// testLoading.value = !testLoading.value;
// }
// };
//
// @TODO: verify secret
const submitSaveSecret = async (event: MouseEvent) => {
event.preventDefault();
saveLoading.value = !saveLoading.value;
Expand All @@ -201,6 +181,9 @@ defineExpose({ showMedal });
cursor: pointer;
}
}
.secret-tabs {
min-height: 320px;
}
.n-card__footer {
.card-footer {
display: flex;
Expand Down

0 comments on commit 82378b4

Please sign in to comment.