Skip to content

Commit

Permalink
feat: unify admin settings under Settings page
Browse files Browse the repository at this point in the history
Use two tabs on that page: `Users`, `Backups`.

Signed-off-by: Artem Chernyshev <[email protected]>
  • Loading branch information
Unix4ever committed May 8, 2024
1 parent 987f8cd commit 041a436
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 56 deletions.
35 changes: 25 additions & 10 deletions frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import OmniClusterScale from "@/views/omni/Clusters/Management/ClusterScale.vue"
import OmniMachines from "@/views/omni/Machines/Machines.vue";
import OmniMachineLogs from "@/views/omni/Machines/MachineLogs.vue";
import OmniUsers from "@/views/omni/Users/Users.vue";
import OmniSettings from "@/views/omni/Settings/Settings.vue";
import Authenticate from "@/views/omni/Auth/Authenticate.vue";
import OmniMachineClasses from "@/views/omni/MachineClasses/MachineClasses.vue";
import OmniMachineClass from "@/views/omni/MachineClasses/MachineClass.vue";
Expand Down Expand Up @@ -198,11 +199,6 @@ const routes: RouteRecordRaw[] = [
name: "Machines",
component: OmniMachines,
},
{
path: "/users",
name: "Users",
component: OmniUsers,
},
{
path: "/machine-classes",
name: "MachineClasses",
Expand All @@ -221,11 +217,6 @@ const routes: RouteRecordRaw[] = [
edit: true,
}
},
{
path: "/backups",
name: "BackupStorage",
component: OmniBackupStorageSettings,
},
{
path: "/machine/:machine/logs",
name: "MachineLogs",
Expand All @@ -241,6 +232,30 @@ const routes: RouteRecordRaw[] = [
name: "MachinePatchEdit",
component: PatchEdit,
},
{
path: "/settings",
name: "Settings",
component: OmniSettings,
redirect: {
name: "Users"
},
children: [
{
path: "users",
name: "Users",
components: {
inner: OmniUsers,
}
},
{
path: "backups",
name: "BackupStorage",
components: {
inner: OmniBackupStorageSettings,
}
},
]
},
], { sidebar: OmniSidebar }),
...withPrefix("/cluster/:cluster", [
{
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/views/omni/Settings/BackupStorage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ included in the LICENSE file.
-->
<template>
<div class="flex flex-col">
<div class="flex gap-1 items-start">
<page-header title="Configure Backups Storage" class="flex-1"/>
</div>
<t-alert v-if="error" title="Failed to Fetch Current Storage State" type="error">
{{ error }}
</t-alert>
Expand Down Expand Up @@ -52,7 +49,6 @@ import { withRuntime } from "@/api/options";
import { Code } from '@/api/google/rpc/code.pb';

import TButton from "@/components/common/Button/TButton.vue";
import PageHeader from "@/components/common/PageHeader.vue";
import TInput from "@/components/common/TInput/TInput.vue";
import TSpinner from "@/components/common/Spinner/TSpinner.vue";
import TAlert from "@/components/TAlert.vue";
Expand Down
69 changes: 69 additions & 0 deletions frontend/src/views/omni/Settings/Settings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!--
Copyright (c) 2024 Sidero Labs, Inc.

Use of this software is governed by the Business Source License
included in the LICENSE file.
-->
<template>
<div class="flex flex-col gap-4">
<div class="flex gap-1 items-start">
<page-header title="Settings" class="flex-1"/>
</div>
<tabs-header class="border-b border-naturals-N4 pb-3.5">
<tab-button is="router-link"
v-for="route in routes"
:key="route.name"
:to="route.to"
:selected="$route.name === route.to"
>
{{ route.name }}
</tab-button>
</tabs-header>
<router-view name="inner"/>
</div>
</template>

<script setup lang="ts">
import { Component, computed } from "vue";
import PageHeader from "@/components/common/PageHeader.vue";
import { RouteLocationRaw } from "vue-router";
import TabsHeader from "@/components/common/Tabs/TabsHeader.vue";
import TabButton from "@/components/common/Tabs/TabButton.vue";

type Props = {
inner: Component,
};

const routes = computed((): {name: string, to: RouteLocationRaw }[] => {
return [
{
name: "Users",
to: { name: "Users" },
},
{
name: "Backups",
to: { name: "BackupStorage" },
},
];
})

defineProps<Props>();
</script>

<style scoped>
.content {
@apply w-full border-b border-naturals-N4 flex;
}

.router-link-active {
@apply text-naturals-N13 relative;
}

.router-link-active::before {
@apply block absolute bg-primary-P3 w-full animate-fadein;
content: "";
height: 2px;
bottom: -15px;
}
</style>

16 changes: 4 additions & 12 deletions frontend/src/views/omni/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,11 @@ const items = computed(() => {
});
}

if (backupStatus.value.configurable && canManageBackupStore.value) {
if (canManageUsers.value || (backupStatus.value.configurable && canManageBackupStore.value)) {
result.push({
name: "Backups Storage",
route: getRoute("BackupStorage", "/omni/backups"),
icon: "circle-stack"
});
}

if (canManageUsers.value) {
result.push({
name: "Users",
route: getRoute("Users", "/omni/users"),
icon: "users",
name: "Settings",
route: getRoute("Settings", "/omni/settings"),
icon: "settings",
});
}

Expand Down
8 changes: 3 additions & 5 deletions frontend/src/views/omni/Users/Users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ Use of this software is governed by the Business Source License
included in the LICENSE file.
-->
<template>
<div class="flex flex-col">
<div class="flex gap-1 items-start">
<page-header title="Users" class="flex-1"/>
<div class="flex flex-col gap-2">
<div class="flex justify-end">
<t-button @click="openUserCreate" icon="user-add" icon-position="left" type="highlighted" :disabled="!canManageUsers || authType === AuthType.SAML">Add User</t-button>
</div>
<t-list :opts="watchOpts" pagination class="flex-1">
<t-list :opts="watchOpts" pagination class="flex-1" search>
<template #default="{ items }">
<div class="users-header">
<div class="users-grid">
Expand All @@ -34,7 +33,6 @@ import { itemID } from "@/api/watch";

import TList from "@/components/common/List/TList.vue";
import UserItem from "@/views/omni/Users/UserItem.vue";
import PageHeader from "@/components/common/PageHeader.vue";
import TButton from "@/components/common/Button/TButton.vue";
import { Resource } from "@/api/grpc";
import { canManageUsers } from "@/methods/auth";
Expand Down
41 changes: 20 additions & 21 deletions hack/test/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,33 +133,32 @@ mkdir -p "${PARTIAL_CONFIG_DIR}"
echo "${PARTIAL_CONFIG}" > "${PARTIAL_CONFIG_DIR}/controlplane.yaml"
echo "${PARTIAL_CONFIG}" > "${PARTIAL_CONFIG_DIR}/worker.yaml"

# TODO: re-enable this when we get fixed Talos version running in tests (1.6.8+,1.7.2+,1.8.x+)
# Launch half of the Talos VMs with partial config to join Omni
${ARTIFACTS}/talosctl cluster create \
--name test-1 \
--provisioner=qemu \
--cidr=172.20.0.0/24 \
--no-masquerade-cidrs=172.21.0.0/24 \
--controlplanes=1 \
--workers=3 \
--input-dir="${PARTIAL_CONFIG_DIR}" \
--vmlinuz-path="https://factory.talos.dev/image/${SCHEMATIC_ID}/v${TALOS_VERSION}/kernel-amd64" \
--initrd-path="https://factory.talos.dev/image/${SCHEMATIC_ID}/v${TALOS_VERSION}/initramfs-amd64.xz" \
--wait=false \
--mtu=1430 \
--memory=3072 \
--memory-workers=3072 \
--cpus=3 \
--cpus-workers=3 \
--with-uuid-hostnames
#${ARTIFACTS}/talosctl cluster create \
# --name test-1 \
# --provisioner=qemu \
# --cidr=172.20.0.0/24 \
# --no-masquerade-cidrs=172.21.0.0/24 \
# --controlplanes=1 \
# --workers=3 \
# --input-dir="${PARTIAL_CONFIG_DIR}" \
# --vmlinuz-path="https://factory.talos.dev/image/${SCHEMATIC_ID}/v${TALOS_VERSION}/kernel-amd64" \
# --initrd-path="https://factory.talos.dev/image/${SCHEMATIC_ID}/v${TALOS_VERSION}/initramfs-amd64.xz" \
# --wait=false \
# --mtu=1430 \
# --memory=3072 \
# --memory-workers=3072 \
# --cpus=3 \
# --cpus-workers=3 \
# --with-uuid-hostnames

# Launch the other half of the Talos VMs with the kernel args to join Omni
${ARTIFACTS}/talosctl cluster create \
--name test-2 \
--provisioner=qemu \
--cidr=172.21.0.0/24 \
--no-masquerade-cidrs=172.20.0.0/24 \
--cidr=172.20.0.0/24 \
--controlplanes=1 \
--workers=3 \
--workers=7 \
--skip-injecting-config \
--extra-boot-kernel-args "siderolink.api=grpc://$LOCAL_IP:8090?jointoken=${JOIN_TOKEN} talos.events.sink=[fdae:41e4:649b:9303::1]:8090 talos.logging.kernel=tcp://[fdae:41e4:649b:9303::1]:8092" \
--vmlinuz-path="https://factory.talos.dev/image/${SCHEMATIC_ID}/v${TALOS_VERSION}/kernel-amd64" \
Expand Down
12 changes: 8 additions & 4 deletions internal/e2e-tests/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,17 @@ func (s *E2ESuite) assertClusterCreation() {

s.click(page, `button:has-text("Save")`)

err = page.Locator("button#extensions-CP").WaitFor()

s.Require().NoError(err)

s.click(page, `button#extensions-CP`)

err = page.Locator(`span:has-text("qemu-guest-agent")`).WaitFor()
err = page.Locator(`span:has-text("usb-modem-drivers")`).WaitFor()

s.Require().NoError(err)

s.click(page, `span:has-text("qemu-guest-agent")`)
s.click(page, `span:has-text("usb-modem-drivers")`)

s.click(page, `button:has-text("Save")`)

Expand Down Expand Up @@ -461,10 +465,10 @@ func (s *E2ESuite) assertClusterCreation() {

s.click(page, "text=Extensions")

err = page.Locator(`text=siderolabs/qemu-guest-agent`).WaitFor()
err = page.Locator(`text=siderolabs/usb-modem-drivers`).WaitFor()
s.Require().NoError(err)

element := page.Locator("text=siderolabs/qemu-guest-agent")
element := page.Locator("text=siderolabs/usb-modem-drivers")
count, err := element.Count()
s.Require().NoError(err)

Expand Down

0 comments on commit 041a436

Please sign in to comment.