Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) File/package/canister remove/rename on hover #87

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 12 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
52 changes: 52 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Frontend

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# environment variables to set for dfx
env:
DFX_VERSION: 0.8.0
steps:
- uses: actions/checkout@v2
- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: "14"
- name: Install DFX and Vessel
run: |
echo y | DFX_VERSION=$DFX_VERSION bash -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)"
echo "/home/runner/bin" >> $GITHUB_PATH
./src/config/vessel-install.sh

- name: DFX build steps
run: |
echo "npm install from lockfile"
npm ci

echo "start dfx"
npm run prestart

echo "build for dfx artifacts"
dfx canister --no-wallet create --all
dfx build --all

- name: Test
run: npm run test

- name: Stop DFX
run: |
echo "dfx stop"
dfx stop
4 changes: 4 additions & 0 deletions dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
"build": {
"output": "build",
"packtool": "vessel sources"
},
"start": {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 I'll hardcode the port in the install script instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, I tried to remove this, and can deploy and run test just fine?

"address": "localhost",
"port": 8000
}
},
"networks": {
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/react-modal": "^3.13.1",
"@types/styled-components": "^5.1.10",
"lodash.debounce": "^4.0.8",
"react": "^17.0.2",
Expand All @@ -35,7 +36,7 @@
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test -- --config=config/jest.config.js",
"test": "craco test",
"eject": "craco eject",
"deploy": "dfx deploy --argument '(null)'",
"prestart": "dfx start --background --no-artificial-delay || exit 0",
Expand Down
9 changes: 0 additions & 9 deletions src/App.test.tsx

This file was deleted.

5 changes: 3 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,10 @@ export function App() {

useEffect(() => {
// Show Candid UI iframe if there are canisters
const isCandidReady =
const isCandidReady = Boolean(
workplaceState.selectedCanister &&
workplaceState.canisters[workplaceState.selectedCanister];
workplaceState.canisters[workplaceState.selectedCanister]
);
setShowCandidUI(isCandidReady);
setCandidWidth(isCandidReady ? "30vw" : "0");
}, [workplaceState.canisters, workplaceState.selectedCanister]);
Expand Down
8 changes: 4 additions & 4 deletions src/assets/fonts/CircularXX.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@
font-family: "CircularXX";
font-weight: 100;
src: local(CircularXX), local(CircularXXWeb-Light),
url(./CircularXXWeb-Light.woff2) format("woff2");
url(CircularXXWeb-Light.woff2) format("woff2");
}

@font-face {
font-family: "CircularXX";
font-weight: 400;
src: local(CircularXX), local(CircularXXWeb-Book),
url(./CircularXXWeb-Book.woff2) format("woff2");
url(CircularXXWeb-Book.woff2) format("woff2");
}

@font-face {
font-family: "CircularXX";
font-weight: 700;
src: local(CircularXX), local(CircularXXWeb-Medium),
url(./CircularXXWeb-Medium.woff) format("woff");
url(CircularXXWeb-Medium.woff) format("woff");
}

@font-face {
font-family: "CircularXX";
font-weight: 900;
src: local(CircularXX), local(CircularXXWeb-Bold),
url(./CircularXXWeb-Bold.woff2) format("woff2");
url(CircularXXWeb-Bold.woff2) format("woff2");
}
2 changes: 1 addition & 1 deletion src/assets/images/icon-file.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/assets/images/icon-folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/assets/images/icon-pencil.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/Editor.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState, useContext } from "react";
import { useEffect, useContext } from "react";
import styled from "styled-components";
import MonacoEditor, { useMonaco } from "@monaco-editor/react";
import ReactMarkdown from "react-markdown";
Expand Down
80 changes: 66 additions & 14 deletions src/components/Explorer.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import { useState, useEffect, useContext } from "react";
import styled from "styled-components";
import iconPackage from "../assets/images/icon-package.svg";
import iconCanister from "../assets/images/icon-canister.svg";
import iconClose from "../assets/images/icon-close.svg";
import iconPlus from "../assets/images/icon-plus.svg";
import { ListButton } from "./shared/SelectList";
import {
WorkplaceState,
WorkplaceDispatchContext,
} from "../contexts/WorkplaceState";

import { ListButton } from "./shared/SelectList";
import { PackageModal } from "./PackageModal";
import { FileModal } from "./FileModal";
import { CanisterModal } from "./CanisterModal";
import { DeploySetter } from "./DeplayModal";
import { FolderStructure } from "./FolderStructure";
import { Confirm } from "./shared/Confirm";

import { PackageInfo } from "../workers/file";
import { ILoggingStore } from "./Logger";
import { deleteCanister } from "../build";
import { FolderStructure } from "./FolderStructure";
import iconPackage from "../assets/images/icon-package.svg";
import iconCanister from "../assets/images/icon-canister.svg";
import iconClose from "../assets/images/icon-close.svg";
import iconPlus from "../assets/images/icon-plus.svg";

const StyledExplorer = styled.div`
width: var(--explorerWidth);
Expand Down Expand Up @@ -45,6 +48,9 @@ const CloseButton = styled(MyButton)`
margin-right: -1.1rem;
margin-left: -0.3rem;
`;
const ConfirmText = styled.p`
margin-bottom: 2rem;
`;

interface ExplorerProps {
state: WorkplaceState;
Expand All @@ -65,25 +71,48 @@ export function Explorer({ state, ttl, logger, deploySetter }: ExplorerProps) {
const [showPackage, setShowPackage] = useState(false);
const [showFileModal, setShowFileModal] = useState(false);
const [showCanisterModal, setShowCanisterModal] = useState(false);
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
const [fileToModify, setFileToModify] = useState("");
const dispatch = useContext(WorkplaceDispatchContext);

const onSelectFile = (selectedFile: string) => {
function handleRenameClick(e, selectedFile: string) {
e.stopPropagation();
setFileToModify(selectedFile);
setShowFileModal(true);
}
function handleDeleteClick(e, selectedFile: string) {
e.stopPropagation();
setFileToModify(selectedFile);
setShowDeleteConfirm(true);
}

function onSelectFile(selectedFile: string) {
dispatch({
type: "selectFile",
payload: {
path: selectedFile,
},
});
};
const loadPackage = (pack: PackageInfo) => {
}
function loadPackage(pack: PackageInfo) {
dispatch({
type: "loadPackage",
payload: {
name: pack.name,
package: pack,
},
});
};
}
function onDeleteFile() {
dispatch({
type: "deleteFile",
payload: {
path: fileToModify,
},
});
setFileToModify("");
}

const onCanister = async (selectedCanister: string, action: string) => {
switch (action) {
case "select":
Expand Down Expand Up @@ -178,17 +207,38 @@ export function Explorer({ state, ttl, logger, deploySetter }: ExplorerProps) {

return (
<StyledExplorer>
<FileModal isOpen={showFileModal} close={() => setShowFileModal(false)} />
<FileModal
isOpen={showFileModal}
close={() => {
setShowFileModal(false);
setFileToModify("");
}}
filename={fileToModify}
/>
<PackageModal
isOpen={showPackage}
close={() => setShowPackage(false)}
close={() => {
setShowPackage(false);
}}
loadPackage={loadPackage}
/>
<CanisterModal
isOpen={showCanisterModal}
close={() => setShowCanisterModal(false)}
deploySetter={deploySetter}
/>
<Confirm
isOpen={showDeleteConfirm}
onConfirm={onDeleteFile}
close={() => {
setShowDeleteConfirm(false);
setFileToModify("");
}}
>
<ConfirmText>
Are you sure you want to delete the file <code>{fileToModify}</code>?
</ConfirmText>
</Confirm>
<CategoryTitle>
Files
<MyButton onClick={() => setShowFileModal(true)} aria-label="Add file">
Expand All @@ -197,10 +247,12 @@ export function Explorer({ state, ttl, logger, deploySetter }: ExplorerProps) {
</CategoryTitle>
<FolderStructure
filePaths={Object.keys(state.files).sort()}
onSelectFile={onSelectFile}
activeFile={state.selectedFile}
onSelectFile={onSelectFile}
onRenameFile={handleRenameClick}
onDeleteFile={handleDeleteClick}
/>
<CategoryTitle>
<CategoryTitle style={{ borderTop: "1px solid var(--grey300)" }}>
Packages
<MyButton onClick={() => setShowPackage(true)} aria-label="Add package">
<img style={{ width: "1.6rem" }} src={iconPlus} alt="" />
Expand Down
Loading