Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions src/activities.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import GitHubView from "./components/activities/explorer/GitHubView";
import LoginStatus from "./components/activities/explorer/LoginStatus";
import { FileIcon, RemoteControlIcon, BugReport, ProfileGreen, ProfileOrange, ProfileRed, ProfileWhite } from "./icons"
import { RiGithubFill } from "react-icons/ri";
import { GiThorHammer} from "react-icons/gi";
import { TiPipette } from "react-icons/ti";
import { ObjectTypes } from "./objectTypes";
import { FaGraduationCap } from "react-icons/fa";
import { BsGraphUpArrow } from "react-icons/bs";
Expand All @@ -22,7 +22,7 @@ export const Activities = {
},
ResourceSelection: {
id: "synbio.activity.resource-selection",
title: "Resource Selection",
title: "Resources",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#209 ✅

component: ExplorerActivityView,
icon: HiOutlinePuzzlePiece,
objectTypesToList: [
Expand Down Expand Up @@ -57,13 +57,12 @@ export const Activities = {
id: "synbio.activity.build",
title: "Build",
component: ExplorerActivityView,
icon: GiThorHammer,
icon: TiPipette,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#210 ✅

objectTypesToList: [
ObjectTypes.Plasmids.id,
ObjectTypes.Strains.id,
ObjectTypes.Assembly.id,
ObjectTypes.Build.id,
ObjectTypes.SampleDesigns.id,
ObjectTypes.Strains.id
]
},
Test: {
Expand All @@ -72,6 +71,7 @@ export const Activities = {
component: ExplorerActivityView,
icon: BiSolidFlask,
objectTypesToList: [
ObjectTypes.SampleDesigns.id,
ObjectTypes.Experiments.id,
ObjectTypes.Metadata.id,
ObjectTypes.Results.id //note: not all of these have templates
Expand Down
55 changes: 55 additions & 0 deletions src/commands.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import store from "./redux/store"
import { isPanelOpen, panelsActions, serializePanel } from "./redux/hooks/panelsHooks"
import { workDirActions, writeToFileHandle } from "./redux/hooks/workingDirectoryHooks"
import { useOpenPanel } from "./redux/hooks/panelsHooks"


export default {
Expand Down Expand Up @@ -67,6 +68,60 @@ export default {
// save
await writeToFileHandle(file, serializePanel(file.id))
}
},

FileDownload: {
id: createId("file-download"),
title: "Download File",
shortTitle: "Download",
description: "Download a file",
arguments: [
{
name: "fileNameOrId",
prompt: "Enter the file name or ID"
}
],
execute: async fileNameOrId => {
const file = findFileByNameOrId(fileNameOrId);
if (!file) return "File doesn't exist.";

const state = store.getState().workingDirectory;
let fileData = state.entities[file.id]?.data;

if (!fileData) {
const dirHandle = state.directoryHandle;
if (dirHandle && typeof dirHandle.getFileHandle === 'function') {
try {
const parts = file.id.split('/');
let cur = dirHandle;
for (let i = 0; i < parts.length - 1; i++) {
cur = await cur.getDirectoryHandle(parts[i]);
}
const fh = await cur.getFileHandle(parts[parts.length - 1]);
fileData = await fh.getFile();
} catch (err) {
console.warn('Failed to read file from directoryHandle', err);
}
} else {
console.warn('No usable directoryHandle in store. directoryHandle:', dirHandle);
}
}

if (!fileData) {
console.log("File data not found.");
return "File data not found.";
}

const blob = typeof fileData === "string" ? new Blob([fileData], { type: "text/plain" }) : fileData;
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = file.name;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/components/activities/explorer/ExplorerList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,15 @@ export default function ExplorerList({workDir, objectTypesToList}) {
</CreateNewButton>
}
{createListItems(filesOfType, objectType.icon)}
{objectType.isRepository &&
{objectType.isRepository ? objectType.id == "synbio.object-type.flapjack" ?
<Registries
defaultRegistry={objectType.defaultRegistry}
typeOfRegistry={objectType.listTitle}
title={objectType.title}/>:
<Registries
defaultRegistry={objectType?.defaultRegistry}
typeOfRegistry={objectType.listTitle}
title={objectType.title}/>
: <></>
}
</Accordion.Panel>
</Accordion.Item>
Expand Down
1 change: 1 addition & 0 deletions src/components/activities/explorer/ExplorerListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function ExplorerListItem({ fileId, icon }) {

// command list
const contextMenuCommands = [
commands.FileDownload,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#215 ✅

commands.FileDelete
]

Expand Down
6 changes: 2 additions & 4 deletions src/components/activities/explorer/ListRegistries.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ export default function ListRegistries({registry, defaultRegistry, onConfirmDele
// right click handler, opens up delete option
const handleRightClick = (event) => {
event.preventDefault()
if (registry !== defaultRegistry){
setRegistryToDelete(registry)
setContextMenuOpen(true)
}
setRegistryToDelete(registry)
setContextMenuOpen(true)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#207 ✅


// command list
Expand Down
4 changes: 2 additions & 2 deletions src/components/activities/explorer/Registries.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import { showNotification } from '@mantine/notifications';
/**
* Component to handle the creation, deletion, and containment of SynBioHub registries.
*/
export default function Registries({defaultRegistry, typeOfRegistry, title}){
export default function Registries({typeOfRegistry, title, defaultRegistry = null}){
const dispatch = useDispatch()

// Get default registry and additional ones from localStorage
const storedRegistries = JSON.parse(localStorage.getItem(typeOfRegistry)) || [];
const [registries, setRegistries] = useState([defaultRegistry, ...storedRegistries])
const [registries, setRegistries] = useState(defaultRegistry ? [defaultRegistry, ...storedRegistries] : [...storedRegistries])


const onCreate = (inputValue) => {
Expand Down
6 changes: 3 additions & 3 deletions src/modules/modular_login/FJInstanceSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const FJInstanceSelector = ({onClose, setRepoSelection }) => {
if (!showNotificationFlag) {
showNotification({
title: 'Logout Successful',
message: 'You have successfully logged out of the registry',
message: 'You have successfully logged out of the repository',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

color: 'green',
});
}
Expand Down Expand Up @@ -125,13 +125,13 @@ const FJInstanceSelector = ({onClose, setRepoSelection }) => {
) : (
<>
<Select
label={`Select a Flapjack registry`}
label={`Select a Flapjack repository`}
placeholder="Pick one"
data={instanceData}
onChange={(value) => {setNullSelected(false); setSelected(value)}}
value={selected}
/>
{nullSelected && <div style={{ color: 'red', marginTop: '1px', fontSize: '12px' }}>No selected registry. Please select an registry</div>}
{nullSelected && <div style={{ color: 'red', marginTop: '1px', fontSize: '12px' }}>No selected repository. Please select an repository</div>}
<div style={{ marginTop: '20px', display: 'flex' }}>
<Button mr="md" onClick={() => {setAddingInstance(null)}}>Add</Button>
{selected && (
Expand Down
10 changes: 5 additions & 5 deletions src/modules/modular_login/FJModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function FJModal({ opened, onClose, repoName }) {
}, [opened]);

return (
<Modal opened={opened} onClose={onClose} title={`Choose Registry`} size="lg">
<Modal opened={opened} onClose={onClose} title={`Choose Repository`} size="lg">
{repoSelection === "" ? (
<>
<Grid justify="center">
Expand All @@ -38,7 +38,7 @@ function FJModal({ opened, onClose, repoName }) {
/>
<div>
<Text fz="xs" mt={10} fw={700} c="dimmed">
Registry: {selectedFJ ? findInstance(selectedFJ, "FJ").instance : "Not Logged In"}
Repository: {selectedFJ ? findInstance(selectedFJ, "FJ").instance : "Not Logged In"}
</Text>

<Text fz="lg" fw={500}>
Expand All @@ -49,13 +49,13 @@ function FJModal({ opened, onClose, repoName }) {
</Text>
{selectedFJ ? <>
<Button mt="md" mr="sm" onClick={() => {handleRemoveInstance("Flapjack"); setRepoSelection("Flapjack")}}>
Change Flapjack Registry
Change Flapjack Repository
</Button>
<Button mt="md" ml="sm" onClick={() => {onClose(); setRepoSelection("")}}>
Confirm Registry Selection
Confirm Repository Selection
</Button>
</> : <Button mt="md" onClick={() => {setRepoSelection("Flapjack")}}>
Select Flapjack Registry
Select Flapjack Repository
</Button>}
</div>
</Grid.Col>
Expand Down
6 changes: 3 additions & 3 deletions src/modules/modular_login/SBHInstanceSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const SBHInstanceSelector = ({onClose, setRepoSelection }) => {
if (!showNotificationFlag) {
showNotification({
title: 'Logout Successful',
message: 'You have successfully logged out of the registry',
message: 'You have successfully logged out of the repository',
color: 'green',
});
}
Expand Down Expand Up @@ -137,13 +137,13 @@ const SBHInstanceSelector = ({onClose, setRepoSelection }) => {
<SBHInstanceLogin onClose={onClose} goBack={setShowLogin} setRepoSelection={setRepoSelection}/>
: ( <>
<Select
label={`Select a SynbioHub registry`}
label={`Select a SynbioHub repository`}
placeholder="Pick one"
data={instanceData}
onChange={(value) => {setNullSelected(false); setSelected(value)}}
value={selected}
/>
{nullSelected && <div style={{ color: 'red', marginTop: '1px', fontSize: '12px' }}>No selected registry. Please select an registry</div>}
{nullSelected && <div style={{ color: 'red', marginTop: '1px', fontSize: '12px' }}>No selected repository. Please select an repository</div>}
<div style={{ marginTop: '20px', display: 'flex' }}>
<Button mr="md" onClick={() => {setAddingInstance(null)}}>Add</Button>
{selected && (
Expand Down
10 changes: 5 additions & 5 deletions src/modules/modular_login/SBHModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function SBHModal({ opened, onClose, repoName }) {
}, [opened]);

return (
<Modal opened={opened} onClose={onClose} title={`Choose Registry`} size="lg">
<Modal opened={opened} onClose={onClose} title={`Choose Repository`} size="lg">
{repoSelection === "" ? (
<>
<Grid justify="center">
Expand All @@ -39,7 +39,7 @@ function SBHModal({ opened, onClose, repoName }) {
/>
<div>
<Text fz="xs" mt={10} fw={700} c="dimmed">
Registry: {selectedSBH ? findInstance(selectedSBH, "SBH").instance : "Not Logged In"}
Repository: {selectedSBH ? findInstance(selectedSBH, "SBH").instance : "Not Logged In"}
</Text>

<Text fz="lg" fw={500}>
Expand All @@ -50,13 +50,13 @@ function SBHModal({ opened, onClose, repoName }) {
</Text>
{selectedSBH ? <>
<Button mt="md" onClick={() => {handleRemoveInstance("SynbioHub"); setRepoSelection("SynbioHub")}}>
Change SynbioHub Registry
Change SynbioHub Repository
</Button>
<Button mt="md" ml="sm" onClick={() => {onClose(); setRepoSelection("")}}>
Confirm Registry Selection
Confirm Repository Selection
</Button>
</> : <Button mt="md" onClick={() => {setRepoSelection("SynbioHub")}}>
Select SynbioHub Registry
Select SynbioHub Repository
</Button>}
</div>
</Grid.Col>
Expand Down
14 changes: 7 additions & 7 deletions src/modules/modular_login/loginModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function LoginModal({ opened, onClose, repoName }) {
}, [opened]);

return (
<Modal opened={opened} onClose={onClose} title={`Choose Registry`} size="lg">
<Modal opened={opened} onClose={onClose} title={`Choose Repository`} size="lg">
{repoSelection === "" ? (
<>
<Grid>
Expand All @@ -48,7 +48,7 @@ function LoginModal({ opened, onClose, repoName }) {
/>
<div>
<Text fz="xs" mt={10} fw={700} c="dimmed">
Registry: {selectedSBH ? findInstance(selectedSBH, "SBH").instance : "Not Logged In"}
Repository: {selectedSBH ? findInstance(selectedSBH, "SBH").instance : "Not Logged In"}
</Text>

<Text fz="lg" fw={500}>
Expand All @@ -61,9 +61,9 @@ function LoginModal({ opened, onClose, repoName }) {
</Text>
</Group>
{selectedSBH ? <Button mt="md" onClick={() => {handleRemoveInstance("SynbioHub"); setRepoSelection("SynbioHub")}}>
Change SynbioHub Registry
Change SynbioHub Repository
</Button> : <Button mt="md" onClick={() => {setRepoSelection("SynbioHub")}}>
Select SynbioHub Registry
Select SynbioHub Repository
</Button>}
</div>
</Grid.Col>
Expand All @@ -77,7 +77,7 @@ function LoginModal({ opened, onClose, repoName }) {
/>
<div>
<Text fz="xs" mt={10} fw={700} c="dimmed">
Registry: {selectedFJ ? findInstance(selectedFJ, "FJ").instance : "Not Logged In"}
Repository: {selectedFJ ? findInstance(selectedFJ, "FJ").instance : "Not Logged In"}
</Text>

<Text fz="lg" fw={500}>
Expand All @@ -90,9 +90,9 @@ function LoginModal({ opened, onClose, repoName }) {
</Text>
</Group>
{selectedFJ ? <Button mt="md" onClick={() => {handleRemoveInstance("Flapjack"); setRepoSelection("Flapjack")}}>
Change Flapjack Registry
Change Flapjack Repository
</Button> : <Button mt="md" onClick={() => {setRepoSelection("Flapjack")}}>
Select Flapjack Registry
Select Flapjack Repository
</Button>}
</div>
</Grid.Col>
Expand Down
Loading
Loading