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

Update sshkey page #2554

Merged
merged 24 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0c8d798
- Remove Active keys table
samaradel Apr 14, 2024
5153e27
- Collect SSH key functions in one file
samaradel Apr 16, 2024
3c4f6f5
remove type keyword
samaradel Apr 16, 2024
3245d9d
- Update functions with grid
samaradel Apr 17, 2024
4afe88e
Remove sshkey name from validator regex
samaradel Apr 17, 2024
cbd67ef
Add migrateSshKeys function in activate function
samaradel Apr 17, 2024
fbdba43
Revert "Add migrateSshKeys function in activate function"
samaradel Apr 17, 2024
4b56259
Revert "Remove sshkey name from validator regex"
samaradel Apr 17, 2024
f1963fa
Revert "- Update functions with grid"
samaradel Apr 17, 2024
a366dc9
Revert "remove type keyword"
samaradel Apr 17, 2024
382f06a
Revert "- Collect SSH key functions in one file"
samaradel Apr 17, 2024
14d3005
Fix listing imported keys when its imported without name
samaradel Apr 17, 2024
8957552
Apply loading while activating or deactivating ssh keys
samaradel Apr 17, 2024
9ce6514
Enhanced the 'SSH-Keys' page with the following:
Mahmoud-Emad Apr 18, 2024
a75228a
Fix: Fix bug in listing ssh-keys for a new user, fix issue in display…
Mahmoud-Emad Apr 18, 2024
88ab913
Fix: Fix bug in listing ssh-keys for a new user, fix issue in display…
Mahmoud-Emad Apr 18, 2024
6a18966
Apply comments:
Mahmoud-Emad Apr 18, 2024
33eb81e
Removed unused loggers.
Mahmoud-Emad Apr 18, 2024
c5fd3b5
Update the header font size.
Mahmoud-Emad Apr 18, 2024
709a1a8
Fix: Fixed the issue of exporting some keys by looping over the selec…
Mahmoud-Emad Apr 18, 2024
e3359fd
Enhancements:
Mahmoud-Emad Apr 21, 2024
b2acbb5
Fix: Handled Insufficient Balance Error
Mahmoud-Emad Apr 21, 2024
bd73ce3
Update: Update the status of the key if the balance is enough
Mahmoud-Emad Apr 21, 2024
d097eea
Update: Handle error message, handle error blocks.
Mahmoud-Emad Apr 21, 2024
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
4 changes: 2 additions & 2 deletions packages/playground/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ const routes: AppRoute[] = [
tooltip: "Find or Publish your Flist on 0-Hub.",
},
{
title: "SSH Key",
title: "SSH Keys",
icon: "mdi-key-plus",
route: DashboardRoutes.Deploy.SSHKey,
tooltip: "Generate or update your SSH Key.",
tooltip: "Generate or update your SSH Keys.",
},
],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<v-card class="" variant="tonal">
<v-card class="my-6" variant="tonal">
<v-card-title>
<v-icon>mdi-key-chain</v-icon>
Manage SSH keys
Expand All @@ -17,7 +17,15 @@

<v-card-actions>
<VSpacer />
<v-btn color="primary" variant="flat" @click="openManageDialog = true" class="mr-2">Manage SSH keys</v-btn>
<v-btn
color="primary"
variant="flat"
@click="openManageDialog = true"
class="mr-2 my-1"
:disabled="sshKeysManagement.list() && sshKeysManagement.list().length === 0"
>
Manage SSH keys
</v-btn>
</v-card-actions>
</v-card>

Expand All @@ -38,16 +46,16 @@

<v-row>
<v-tooltip
v-for="_key of sshKeys"
v-for="_key of sshKeysManagement.list()"
:key="_key.id"
:text="selectedKeys.includes(_key) ? 'Selected' : 'Not selected'"
:text="isKeySelected(_key) ? 'Selected' : 'Not selected'"
location="bottom"
>
<template #activator="{ props }">
<v-chip
class="pa-5 ml-5 mt-5"
:variant="selectedKeys.includes(_key) ? 'flat' : 'outlined'"
:color="selectedKeys.includes(_key) ? 'primary' : 'white'"
:variant="isKeySelected(_key) ? 'flat' : 'outlined'"
:color="isKeySelected(_key) ? 'primary' : 'white'"
v-bind="props"
@click="selectKey(_key)"
>
Expand Down Expand Up @@ -85,8 +93,8 @@ import SshDataDialog from "@/components/ssh_keys/SshDataDialog.vue";
import { useForm, ValidatorStatus } from "@/hooks/form_validator";
import type { InputValidatorService } from "@/hooks/input_validator";
import { DashboardRoutes } from "@/router/routes";
import { useProfileManager } from "@/stores";
import type { SSHKeyData } from "@/types";
import SSHKeysManagement from "@/utils/ssh";

export default defineComponent({
name: "ManageSshDeployemnt",
Expand All @@ -98,30 +106,34 @@ export default defineComponent({
setup(_, { emit }) {
const defaultKeyData = { createdAt: "", id: 0, publicKey: "", name: "", isActive: false };
const openManageDialog = ref<boolean>(false);
const profileManager = useProfileManager();
const sshKeys = profileManager.profile?.ssh as SSHKeyData[];
const selectedKey = ref<SSHKeyData>(defaultKeyData);
const selectedKeys = ref<SSHKeyData[]>([]);
const isViewSSHKey = ref<boolean>(false);
const sshKeysManagement = new SSHKeysManagement();

// Each key will be added then add `\n` as a new line.
const selectedKeysString = ref<string>("");

onMounted(() => {
selectedKeys.value = sshKeys.filter(_key => _key.isActive === true);
selectedKeys.value = sshKeysManagement.list().filter(_key => _key.isActive === true);
handleKeys();
emit("selectedKeys", selectedKeysString.value);
});

const isKeySelected = (key: SSHKeyData) => {
return selectedKeys.value.some(selectedKey => selectedKey.id === key.id);
};

function selectKey(key: SSHKeyData) {
if (selectedKeys.value.includes(key)) {
const index = selectedKeys.value.indexOf(key);
if (isKeySelected(key)) {
const index = selectedKeys.value.findIndex(selectedKey => selectedKey.id === key.id);
if (index !== -1) {
selectedKeys.value.splice(index, 1);
}
} else {
selectedKeys.value.push(key);
}

handleKeys();
emit("selectedKeys", selectedKeysString.value);
}
Expand Down Expand Up @@ -167,18 +179,19 @@ export default defineComponent({

return {
openManageDialog,
sshKeys,
selectedKeys,
selectedKey,
isViewSSHKey,
defaultKeyData,
selectedKeysString,
DashboardRoutes,
sshKeysManagement,

capitalize,
onSelectKey,
onCloseSelectKey,
selectKey,
isKeySelected,
};
},
});
Expand Down
Loading
Loading