Machine: add install button
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
import { RouteSectionProps, useNavigate } from "@solidjs/router";
|
import { RouteSectionProps, useNavigate } from "@solidjs/router";
|
||||||
import { SidebarPane } from "@/src/components/Sidebar/SidebarPane";
|
import { SidebarPane } from "@/src/components/Sidebar/SidebarPane";
|
||||||
import { navigateToClan, useClanURI, useMachineName } from "@/src/hooks/clan";
|
import { navigateToClan, useClanURI, useMachineName } from "@/src/hooks/clan";
|
||||||
import { Show } from "solid-js";
|
import { createSignal, Show } from "solid-js";
|
||||||
import { SectionGeneral } from "./SectionGeneral";
|
import { SectionGeneral } from "./SectionGeneral";
|
||||||
|
import { InstallModal } from "@/src/workflows/Install/install";
|
||||||
|
import { Button } from "@/src/components/Button/Button";
|
||||||
|
|
||||||
export const Machine = (props: RouteSectionProps) => {
|
export const Machine = (props: RouteSectionProps) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -13,10 +15,30 @@ export const Machine = (props: RouteSectionProps) => {
|
|||||||
navigateToClan(navigate, clanURI);
|
navigateToClan(navigate, clanURI);
|
||||||
};
|
};
|
||||||
|
|
||||||
const machineName = useMachineName();
|
const [showInstall, setShowModal] = createSignal(false);
|
||||||
|
|
||||||
|
let container: Node;
|
||||||
return (
|
return (
|
||||||
<Show when={useMachineName()} keyed>
|
<Show when={useMachineName()} keyed>
|
||||||
|
<Button
|
||||||
|
hierarchy="primary"
|
||||||
|
onClick={() => setShowModal(true)}
|
||||||
|
class="absolute top-0 right-0 m-4"
|
||||||
|
>
|
||||||
|
Install me!
|
||||||
|
</Button>
|
||||||
|
<Show when={showInstall()}>
|
||||||
|
<div
|
||||||
|
class="absolute top-0 left-0 w-full h-full flex justify-center items-center z-50 bg-white/90"
|
||||||
|
ref={(el) => (container = el)}
|
||||||
|
>
|
||||||
|
<InstallModal
|
||||||
|
machineName={useMachineName()}
|
||||||
|
mount={container!}
|
||||||
|
onClose={() => setShowModal(false)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Show>
|
||||||
<SidebarPane title={useMachineName()} onClose={onClose}>
|
<SidebarPane title={useMachineName()} onClose={onClose}>
|
||||||
<SectionGeneral />
|
<SectionGeneral />
|
||||||
</SidebarPane>
|
</SidebarPane>
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ const InstallStepper = () => {
|
|||||||
export interface InstallModalProps {
|
export interface InstallModalProps {
|
||||||
machineName: string;
|
machineName: string;
|
||||||
initialStep?: InstallSteps[number]["id"];
|
initialStep?: InstallSteps[number]["id"];
|
||||||
|
mount?: Node;
|
||||||
|
onClose?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const steps = [
|
const steps = [
|
||||||
@@ -80,9 +82,11 @@ export const InstallModal = (props: InstallModalProps) => {
|
|||||||
return (
|
return (
|
||||||
<StepperProvider stepper={stepper}>
|
<StepperProvider stepper={stepper}>
|
||||||
<Modal
|
<Modal
|
||||||
|
mount={props.mount}
|
||||||
title="Install machine"
|
title="Install machine"
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
console.log("Install aborted");
|
console.log("Install modal closed");
|
||||||
|
props.onClose?.();
|
||||||
}}
|
}}
|
||||||
// @ts-expect-error some steps might not have
|
// @ts-expect-error some steps might not have
|
||||||
metaHeader={stepper.currentStep()?.title ? <MetaHeader /> : undefined}
|
metaHeader={stepper.currentStep()?.title ? <MetaHeader /> : undefined}
|
||||||
|
|||||||
Reference in New Issue
Block a user