fix(extraSidebarComponent): remove unnecessary dependency from useEffect hook
feat(extraSidebarComponent): add support for tags selection in the extra sidebar component fix(nodeToolbarComponent): add missing import statements for new components feat(nodeToolbarComponent): add support for tags selection and public/private toggle in the node toolbar component
This commit is contained in:
parent
cf434eb7ba
commit
b97c25d3c7
2 changed files with 53 additions and 8 deletions
|
|
@ -60,7 +60,7 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//TODO: get tags from api
|
//TODO: get tags from api
|
||||||
setTags(["teste1", "teste2"]);
|
setTags(["teste1", "teste2"]);
|
||||||
}, [setTags]);
|
}, []);
|
||||||
|
|
||||||
function handleTagSelection(tag: string) {
|
function handleTagSelection(tag: string) {
|
||||||
setSelectedTags((prev) => {
|
setSelectedTags((prev) => {
|
||||||
|
|
@ -224,8 +224,8 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
<div className="w-full pt-2">
|
<div className="w-full pt-2">
|
||||||
<span className="text-sm">Add some tags to your Flow</span>
|
<span className="text-sm">Add some tags to your Flow</span>
|
||||||
<TagsSelector
|
<TagsSelector
|
||||||
tags={["teste1", "teste2"]}
|
tags={tags}
|
||||||
selectedTags={new Set()}
|
selectedTags={selectedTags}
|
||||||
setSelectedTags={handleTagSelection}
|
setSelectedTags={handleTagSelection}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -238,7 +238,7 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
</ConfirmationModal.Trigger>
|
</ConfirmationModal.Trigger>
|
||||||
</ConfirmationModal>
|
</ConfirmationModal>
|
||||||
),
|
),
|
||||||
[sharePublic]
|
[sharePublic, tags, selectedTags]
|
||||||
);
|
);
|
||||||
|
|
||||||
const ExportMemo = useMemo(
|
const ExportMemo = useMemo(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import { cloneDeep } from "lodash";
|
import { cloneDeep } from "lodash";
|
||||||
import { useContext, useState } from "react";
|
import { useContext, useEffect, useState } from "react";
|
||||||
import { useReactFlow, useUpdateNodeInternals } from "reactflow";
|
import { useReactFlow, useUpdateNodeInternals } from "reactflow";
|
||||||
import ShadTooltip from "../../../../components/ShadTooltipComponent";
|
import ShadTooltip from "../../../../components/ShadTooltipComponent";
|
||||||
import IconComponent from "../../../../components/genericIconComponent";
|
import IconComponent from "../../../../components/genericIconComponent";
|
||||||
|
import { TagsSelector } from "../../../../components/tagsSelectorComponent";
|
||||||
|
import ToggleShadComponent from "../../../../components/toggleShadComponent";
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
|
|
@ -67,6 +69,26 @@ export default function NodeToolbarComponent({
|
||||||
const [showModalAdvanced, setShowModalAdvanced] = useState(false);
|
const [showModalAdvanced, setShowModalAdvanced] = useState(false);
|
||||||
const [showconfirmShare, setShowconfirmShare] = useState(false);
|
const [showconfirmShare, setShowconfirmShare] = useState(false);
|
||||||
const [selectedValue, setSelectedValue] = useState("");
|
const [selectedValue, setSelectedValue] = useState("");
|
||||||
|
const [sharePublic, setSharePublic] = useState(true);
|
||||||
|
const [tags, setTags] = useState<string[]>([]);
|
||||||
|
const [selectedTags, setSelectedTags] = useState<Set<string>>(new Set());
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
//TODO: get tags from api
|
||||||
|
setTags(["teste1", "teste2"]);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
function handleTagSelection(tag: string) {
|
||||||
|
setSelectedTags((prev) => {
|
||||||
|
const newSet = new Set(prev);
|
||||||
|
if (newSet.has(tag)) {
|
||||||
|
newSet.delete(tag);
|
||||||
|
} else {
|
||||||
|
newSet.add(tag);
|
||||||
|
}
|
||||||
|
return newSet;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function handleShareComponent() {
|
function handleShareComponent() {
|
||||||
const componentFlow = cloneDeep(data);
|
const componentFlow = cloneDeep(data);
|
||||||
|
|
@ -279,6 +301,7 @@ export default function NodeToolbarComponent({
|
||||||
<ConfirmationModal
|
<ConfirmationModal
|
||||||
key={data.id}
|
key={data.id}
|
||||||
index={0}
|
index={0}
|
||||||
|
size="smaller"
|
||||||
modalContentTitle="Are you sure you want to share this component?"
|
modalContentTitle="Are you sure you want to share this component?"
|
||||||
title="Share Component"
|
title="Share Component"
|
||||||
confirmationText="Share"
|
confirmationText="Share"
|
||||||
|
|
@ -294,9 +317,31 @@ export default function NodeToolbarComponent({
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ConfirmationModal.Content>
|
<ConfirmationModal.Content>
|
||||||
<span>
|
<div className="flex h-full w-full flex-col gap-7">
|
||||||
This component will be available for everyone to use.
|
<div className="flex justify-start align-middle">
|
||||||
</span>
|
<ToggleShadComponent
|
||||||
|
disabled={false}
|
||||||
|
size="medium"
|
||||||
|
setEnabled={setSharePublic}
|
||||||
|
enabled={sharePublic}
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
{sharePublic
|
||||||
|
? "This component will be avaliable for everyone"
|
||||||
|
: "This component will be avaliable just for you"}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="w-full pt-2">
|
||||||
|
<span className="text-sm">
|
||||||
|
Add some tags to your component
|
||||||
|
</span>
|
||||||
|
<TagsSelector
|
||||||
|
tags={tags}
|
||||||
|
selectedTags={selectedTags}
|
||||||
|
setSelectedTags={handleTagSelection}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>{" "}
|
||||||
</ConfirmationModal.Content>
|
</ConfirmationModal.Content>
|
||||||
<ConfirmationModal.Trigger>
|
<ConfirmationModal.Trigger>
|
||||||
<div></div>
|
<div></div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue