fix(typesContext.tsx): set official property of component.node to false to mark it as unofficial
fix(extraSidebarComponent/index.tsx): set official property of component to false if it is explicitly set to false fix(sideBarDraggableComponent/index.tsx): add official property to SidebarDraggableComponent props and use it to conditionally render delete option in SelectItem fix(api/index.ts): add official property to APIClassType to indicate if it is an official API
This commit is contained in:
parent
8ac9a70c68
commit
82e1131ed2
4 changed files with 25 additions and 10 deletions
|
|
@ -144,13 +144,17 @@ export function TypesProvider({ children }: { children: ReactNode }) {
|
||||||
removeCountFromString(component.node?.display_name!) +
|
removeCountFromString(component.node?.display_name!) +
|
||||||
` (${increment})`;
|
` (${increment})`;
|
||||||
}
|
}
|
||||||
|
component.node!.official = false;
|
||||||
components[key] = component;
|
components[key] = component;
|
||||||
savedComponentsJSON.components = components;
|
savedComponentsJSON.components = components;
|
||||||
localStorage.setItem(id, JSON.stringify(savedComponentsJSON));
|
localStorage.setItem(id, JSON.stringify(savedComponentsJSON));
|
||||||
setData((prev) => {
|
setData((prev) => {
|
||||||
let newData = { ...prev };
|
let newData = { ...prev };
|
||||||
//clone to prevent reference erro
|
//clone to prevent reference erro
|
||||||
newData["custom_components"][key] = _.cloneDeep(component.node);
|
newData["custom_components"][key] = _.cloneDeep({
|
||||||
|
...component.node,
|
||||||
|
official: false,
|
||||||
|
});
|
||||||
return newData;
|
return newData;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -266,6 +266,12 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
display_name={
|
display_name={
|
||||||
dataFilter[SBSectionName][SBItemName].display_name
|
dataFilter[SBSectionName][SBItemName].display_name
|
||||||
}
|
}
|
||||||
|
official={
|
||||||
|
dataFilter[SBSectionName][SBItemName].official ===
|
||||||
|
false
|
||||||
|
? false
|
||||||
|
: true
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</ShadTooltip>
|
</ShadTooltip>
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ export default function SidebarDraggableComponent({
|
||||||
color,
|
color,
|
||||||
onDragStart,
|
onDragStart,
|
||||||
apiClass,
|
apiClass,
|
||||||
|
official,
|
||||||
}: {
|
}: {
|
||||||
apiClass: APIClassType;
|
apiClass: APIClassType;
|
||||||
display_name: string;
|
display_name: string;
|
||||||
|
|
@ -29,6 +30,7 @@ export default function SidebarDraggableComponent({
|
||||||
error: boolean;
|
error: boolean;
|
||||||
color: string;
|
color: string;
|
||||||
onDragStart: DragEventHandler<HTMLDivElement>;
|
onDragStart: DragEventHandler<HTMLDivElement>;
|
||||||
|
official: boolean;
|
||||||
}) {
|
}) {
|
||||||
const open = useRef(false);
|
const open = useRef(false);
|
||||||
const { deleteComponent } = useContext(typesContext);
|
const { deleteComponent } = useContext(typesContext);
|
||||||
|
|
@ -108,15 +110,17 @@ export default function SidebarDraggableComponent({
|
||||||
Download{" "}
|
Download{" "}
|
||||||
</div>{" "}
|
</div>{" "}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
<SelectItem value={"delete"}>
|
{!official && (
|
||||||
<div className="flex">
|
<SelectItem value={"delete"}>
|
||||||
<IconComponent
|
<div className="flex">
|
||||||
name="Trash2"
|
<IconComponent
|
||||||
className="relative top-0.5 mr-2 h-4 w-4"
|
name="Trash2"
|
||||||
/>{" "}
|
className="relative top-0.5 mr-2 h-4 w-4"
|
||||||
Delete{" "}
|
/>{" "}
|
||||||
</div>{" "}
|
Delete{" "}
|
||||||
</SelectItem>
|
</div>{" "}
|
||||||
|
</SelectItem>
|
||||||
|
)}
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ export type APIClassType = {
|
||||||
beta?: boolean;
|
beta?: boolean;
|
||||||
documentation: string;
|
documentation: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
|
official?: boolean;
|
||||||
[key: string]: Array<string> | string | APITemplateType | boolean | undefined;
|
[key: string]: Array<string> | string | APITemplateType | boolean | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue