Skip to content

Commit

Permalink
added del installed gateways functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
YunPearce committed Mar 26, 2024
1 parent c34dba5 commit f8ab1f8
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 21 deletions.
10 changes: 7 additions & 3 deletions desk/app/near-gateways.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,12 @@
::
%delete
?~ (~(get by published) identifier.act)
~& >>> 'couldnt find in published gateways'
that
?~ (~(get by installed) identifier.act)
~& >>> 'couldnt find in published or installed gateways'
that
~& > 'Deleted gateway'
=. installed (~(del by installed) identifier.act)
that
~& > 'Deleted gateway'
=. published (~(del by published) identifier.act)
=. installed (~(del by installed) identifier.act)
Expand Down Expand Up @@ -396,5 +400,5 @@
-:(rear gateway)
::
::http{s}://{host}/~/scry/{app}{path}.{mark}
++ url 'https://s3.lonhep-tamfeb.startram.io/bucket/lonhep-tamfeb/2024.3.11..21.56.12-glob-0v7.l3ulb.vme1j.g5lip.sbco7.v4hf0.glob'
++ url 'glob of %near UI'
--
24 changes: 21 additions & 3 deletions ui/src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ import React, { useEffect, useState } from 'react';
import Urbit from '@urbit/http-api';
import HeardGateways from './components/HeardGateways.jsx'
import PublishedGateways from './components/PublishedGateways.jsx'
import DeleteGateway from './components/DeleteGateway.jsx'


export function App() {
const [showDelete, setShowDelete] = useState(false)
const [delGateway, setDelGateway] = useState({})
const api = new Urbit('', '', 'near-handler');
api.ship = window.ship;



const [heard, setHeard] = useState([])
const [published, setPublished] = useState([])
const [installed, setInstalled] = useState([])
Expand Down Expand Up @@ -38,19 +43,32 @@ export function App() {
}
}, [loading])

async function deleteGateway(gateway) {
api.poke({
app: "near-gateways",
mark: "near-action",
json: {"delete": {"ship": gateway.ship, "id": gateway.id}},
onSuccess: () => {setDelGateway({}), window.location.reload(), setShowDelete(false)},
onError: () => setError('Failed to delete gateway')
})
}



return (
<div className='containerBody'>
<div className='containerMain'>
{loading ? <div>loading</div> :
<div>
<div>
{showDelete ?
<div><DeleteGateway gateway={delGateway} setShowDelete={setShowDelete} deleteGateway={deleteGateway}/></div>
:<div></div>}
<h2 className='headers'>Published</h2>
<div className='containerComponent'>
<PublishedGateways published={published} loading={loading} api={api}/></div>
<PublishedGateways published={published} loading={loading} api={api} showDelete={showDelete} setShowDelete={setShowDelete} delGateway={delGateway} setDelGateway={setDelGateway} deleteGateway={deleteGateway}/></div>
<h2 className='headers'>Heard</h2>
<div className='containerComponent'>
<HeardGateways api={api} heard={heard} installed={installed} loading={loading}/></div>
<HeardGateways api={api} heard={heard} installed={installed} loading={loading} setShowDelete={setShowDelete} setDelGateway={setDelGateway}/></div>
</div>
}</div>
</div>
Expand Down
10 changes: 8 additions & 2 deletions ui/src/components/HeardGateways.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import React, { useState, useEffect } from 'react'

function HeardGateways(props) {
const [installedGateways, setInstalledGateways] = useState([])
const [newGateways, setNewGateways] = useState([])

const api= props.api
const heard = props.heard
const installed = props.installed
const loading = props.loading
const setShowDelete = props.setShowDelete
const setDelGateway = props.setDelGateway


const [installedGateways, setInstalledGateways] = useState([])
const [newGateways, setNewGateways] = useState([])

async function pokeInstall(gateway) {
console.log(gateway)
Expand Down Expand Up @@ -78,6 +82,8 @@ function HeardGateways(props) {
</div>
<div className="git">
<a href={url}>Gateway</a>
<button onClick={() => { setShowDelete(true), setDelGateway(gateway)}}
>Delete</button>
</div></div>
)})}
{newGateways !== null ?
Expand Down
14 changes: 2 additions & 12 deletions ui/src/components/PublishedGateways.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,13 @@ import DeleteGateway from './DeleteGateway.jsx'

function PublishedGateways(props) {
const [showNew, setShowNew] = useState(false)
const [showDelete, setShowDelete] = useState(false)
const [delGateway, setDelGateway] = useState({})

const published = props.published
const loading = props.loading
const api = props.api
const setShowDelete = props.setShowDelete
const setDelGateway = props.setDelGateway

async function deleteGateway(gateway) {
api.poke({
app: "near-gateways",
mark: "near-action",
json: {"delete": {"ship": gateway.ship, "id": gateway.id}},
onSuccess: () => {setDelGateway({}), window.location.reload(), setShowDelete(false)},
onError: () => setError('Failed to delete gateway')
})
}

return(
<div>
Expand All @@ -28,7 +19,6 @@ function PublishedGateways(props) {
<div>
<NewGateway api={api} setShowNew={setShowNew}/></div> :
<div></div>}
{showDelete ? <div><DeleteGateway gateway={delGateway} setShowDelete={setShowDelete} deleteGateway={deleteGateway}/></div> :<div></div>}
</div>
{(published !== null) && !loading ?
<div>
Expand Down
6 changes: 5 additions & 1 deletion ui/src/index.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@font-face {
font-family: "urbitSans";
/* font-family: "urbitSans";
src: url("./fonts/UrbitSansWeb-Regular.woff2") format('woff2');
10:09 */
font-family: "urbitSans";
src: url('https://media.urbit.org/fonts/UrbitSans/UrbitSansVFWeb-Regular.woff2')
format('woff2');
/* font-family: "urbitSansMono";
src: url("./fonts/UrbitSansMonoWeb-Thin.woff2") format('woff2'); */
}
Expand Down

0 comments on commit f8ab1f8

Please sign in to comment.