InstanceLink
Reference
- The
InstanceLinkcomponent is Creates a link to a specific resource instance based on the providedtypeName,instanceId, andtargetLayout. - Supports opening the link in a new tab or the same tab.
- Optionally displays a "pop-out" icon (external link icon) next to the link.
- Allows for custom styling of the link and its container.
Props
-
children- Type:
ReactNode - Description: The content to be displayed inside the link (e.g., text or other components).
- Example:
"View Details"or<span>Instance Name</span>.
- Type:
-
typeName- Type:
string - Description: The type of the resource (e.g., "user", "project"). Used to construct the route path.
- Type:
-
instanceId- Type:
string - Description: The unique identifier of the resource instance. Used to construct the route path.
- Type:
-
targetLayout- Type:
string - Description: Specifies the layout or view type for the resource (e.g., "details", "edit"). Used to construct the route path.
- Type:
-
canCreateInstance- Type:
boolean - Description: Indicates whether the user has permission to create a new instance. Passed as part of the route's state.
- Type:
-
containerStyle- Type:
object - Description: Custom styles for the container
<Box>wrapping the link.
- Type:
-
openInNewTab- Type:
boolean - Default:
false - Description: If
true, the link opens in a new tab using thePopOutLinkcomponent.
- Type:
-
showPopOutIcon- Type:
boolean - Default:
false - Description: If
true, displays a FontAwesome external link icon (faExternalLinkAlt) next to the link.
- Type:
-
contentStyle- Type:
object - Default:
{} - Description: Custom styles for the link content.
- Type:
Usage Example
function Example(pageContext) {
const { protrakComponents } = React.useContext(customWidgetContext);
const { InstanceLink } = protrakComponents;
return (
<InstanceLink
typeName="project"
instanceId="12345"
targetLayout="details"
canCreateInstance={true}
containerStyle={{ margin: '10px' }}
openInNewTab={true}
showPopOutIcon={true}
contentStyle={{ fontWeight: 'bold' }}
>
View Project
</InstanceLink>
);
}
- This renders a link to
/project/details/12345. - The link opens in a new tab.
- A pop-out icon is displayed next to the link.
- Custom styles are applied to the container and link content.