better delete action wiring for shares and environments (#142)

This commit is contained in:
Michael Quigley 2023-01-05 15:59:51 -05:00
parent ee89cb6b36
commit 1708f5ed75
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
7 changed files with 48 additions and 11 deletions

View File

@ -39,7 +39,6 @@ const PropertyTable = (props) => {
cell: row => {
if(props.custom) {
if(row.property in props.custom) {
console.log(Date.now());
return props.custom[row.property](row);
}
}

View File

@ -1,5 +1,5 @@
import AccountDetail from "./AccountDetail";
import ShareDetail from "./ShareDetail";
import ShareDetail from "./share/ShareDetail";
import EnvironmentDetail from "./environment/EnvironmentDetail";
const Detail = (props) => {

View File

@ -1,17 +1,17 @@
import {Button} from "react-bootstrap";
import * as identity from "../../../api/environment";
import * as environment from "../../../api/environment";
const ActionsTab = (props) => {
const deleteEnvironment = (envZId) => {
if(window.confirm("Really delete environment '" + envZId + "' and all shares within?")) {
identity.disable({body: {identity: envZId}}).then(resp => {
environment.disable({body: {identity: envZId}}).then(resp => {
console.log(resp);
});
}
}
return (
<div class={"actions-tab"}>
<div className={"actions-tab"}>
<h3>Delete your environment '{props.environment.description}' ({props.environment.zId})?</h3>
<p>
This will remove all shares from this environment, and will remove the environment from the network. You

View File

@ -0,0 +1,28 @@
import * as share from "../../../api/share";
import {Button} from "react-bootstrap";
const ActionsTab = (props) => {
const deleteShare = (envZId, shrToken, reserved) => {
console.log(envZId, shrToken, reserved);
if(window.confirm("Really delete share '" + shrToken + "'?")) {
share.unshare({body: {envZId: envZId, shrToken: shrToken, reserved: reserved}}).then(resp => {
console.log(resp);
});
}
}
return (
<div className={"actions-tab"}>
<h3>Delete your share '{props.share.token}'?</h3>
<p>
This will remove the share (of <code>{props.share.backendProxyEndpoint}</code>) from your environment, making it
unavailable. You will need to terminate the backend for this share in your local environment.
</p>
<Button variant={"danger"} onClick={() => deleteShare(props.share.envZId, props.share.token, props.share.reserved)}>
Delete '{props.share.token}'
</Button>
</div>
);
};
export default ActionsTab;

View File

@ -1,11 +1,12 @@
import * as metadata from "../../api/metadata";
import * as metadata from "../../../api/metadata";
import {Sparklines, SparklinesLine, SparklinesSpots} from "react-sparklines";
import {useEffect, useState} from "react";
import {mdiEyeOffOutline, mdiEyeOutline, mdiShareVariant} from "@mdi/js";
import Icon from "@mdi/react";
import PropertyTable from "../PropertyTable";
import PropertyTable from "../../PropertyTable";
import {Tab, Tabs} from "react-bootstrap";
import {secretString} from "./util";
import {secretString} from "../util";
import ActionsTab from "./ActionsTab";
const ShareDetail = (props) => {
const [detail, setDetail] = useState({});
@ -14,7 +15,10 @@ const ShareDetail = (props) => {
useEffect(() => {
metadata.getShareDetail(props.selection.id)
.then(resp => {
setDetail(resp.data);
let detail = resp.data;
detail.envZId = props.selection.envZId;
console.log(detail);
setDetail(detail);
});
}, [props.selection]);
@ -23,7 +27,9 @@ const ShareDetail = (props) => {
let interval = setInterval(() => {
metadata.getShareDetail(props.selection.id)
.then(resp => {
setDetail(resp.data);
let detail = resp.data;
detail.envZId = props.selection.envZId;
setDetail(detail);
});
}, 1000);
return () => {
@ -61,6 +67,9 @@ const ShareDetail = (props) => {
<Tab eventKey={"detail"} title={"Detail"}>
<PropertyTable object={detail} custom={customProperties} />
</Tab>
<Tab eventKey={"actions"} title={"Actions"}>
<ActionsTab share={detail} />
</Tab>
</Tabs>
</div>
);

View File

@ -53,7 +53,7 @@ const Network = (props) => {
}
const nodeClicked = (node) => {
props.setSelection({id: node.id, type: node.type});
props.setSelection(node);
}
return (

View File

@ -50,6 +50,7 @@ export const mergeGraph = (oldGraph, user, newOverview) => {
}
let shrNode = {
id: shr.token,
envZId: env.environment.zId,
label: shrLabel,
type: "share",
val: 50