Skip to content

Commit

Permalink
Merge pull request #56 from KilleenCode/select-folder-for-input
Browse files Browse the repository at this point in the history
Select folder for input through native UI
  • Loading branch information
RyKilleen authored Mar 21, 2022
2 parents 3addb00 + 7fe8a43 commit d9b9bb6
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "brancato",
"version": "0.6.0",
"version": "0.7.0",
"private": true,
"dependencies": {
"@algolia/autocomplete-js": "^1.5.3",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

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

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "brancato"
version = "0.6.0"
version = "0.7.0"
description = "A tool for stage-managing your life"
authors = ["Ryan Killeen"]
license = ""
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"package": {
"productName": "brancato",
"version": "0.6.0"
"version": "0.7.0"
},
"build": {
"distDir": "../build",
Expand Down
18 changes: 16 additions & 2 deletions src/forms/workflow-action.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { useFieldArray, UseFieldArrayRemove } from "react-hook-form";
import type { useForm } from "react-hook-form";
import { dialog } from "@tauri-apps/api";
import { NestedInputProps } from "./workflow-array";

type Props = {
nestIndex: number;
nestedRemove: UseFieldArrayRemove;
} & Pick<ReturnType<typeof useForm>, "control" | "register">;
} & NestedInputProps;

const WorkflowAction = ({
nestIndex,
control,
register,
nestedRemove,
getValues,
setValue,
}: Props) => {
const { fields, remove, append } = useFieldArray({
control,
Expand All @@ -31,6 +34,17 @@ const WorkflowAction = ({
})}
style={{ marginRight: "25px" }}
/>
<button
type="button"
onClick={() => {
let value = getValues(fieldName);
dialog
.open({ defaultPath: value ?? undefined })
.then((path) => setValue(fieldName, path));
}}
>
Folder Path
</button>

<button type="button" onClick={() => remove(k)}>
Delete
Expand Down
15 changes: 12 additions & 3 deletions src/forms/workflow-array.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { useFieldArray } from "react-hook-form";
import { useFieldArray, useForm } from "react-hook-form";
import { defaultWorkflow } from "../Config";
import WorkflowAction from "./workflow-action";

export default function WorkflowArray({ control, register }: any) {
export type NestedInputProps = Pick<
ReturnType<typeof useForm>,
"control" | "register" | "getValues" | "setValue"
>;
export default function WorkflowArray({
control,
register,
getValues,
setValue,
}: any) {
const { fields, append, remove } = useFieldArray({
control,
name: "workflows",
Expand All @@ -19,7 +28,7 @@ export default function WorkflowArray({ control, register }: any) {

<WorkflowAction
nestIndex={index}
{...{ control, register }}
{...{ control, register, getValues, setValue }}
nestedRemove={remove}
/>
</li>
Expand Down

0 comments on commit d9b9bb6

Please sign in to comment.