Closed HussainTaj-arbisoft closed 2 months ago
I believe all we have to do is update the frontend code to consider the linked content's type when generating these tooltip URLs. However, I cannot estimate the effort for this at the moment.
This won't quite work. The tooltips are generated via ResourceLinkMarkdownSyntax
, which has two responsibilities:
{{< resource_link uuid="abc-123" title="some title" >}}
into an HTML tag. The HTML then gets edited via CKEditor.But really the only information available during this conversion is the shortcode and its arguments (uuid, title). So we don't know the type of the resource.
IMO, the best way to implement this feature would be:
/sites/:sitename//resources/:uuid
. Instead, provide link /sites/site-name/content/:uuid
..../site/:sitename/content/:uuid
. This page would fetch the resource and re-route to /site/:sitename/pages/:uuid
or /site/:sitename/videogalleries/:uuid
or /site/:sitename/resources/:uuid
based on resource type. Roughly, the "page" in (2) would look like
import { useParams, useLocation } from "react-router"
/**
* A page to be served at /content/:uuid that fetches the resource and reroutes
* the user to the appropriate page, i.e.,
* /type/pages/:uuid
* /type/resources/:uuid
* /type/video-galleries/:uuid
* etc
*/
const GenericContentReroutePage = () => {
const { uuid } = useParams() // get the uuid from the URL'
const location = useLocation() // lets us reroute the user to a different page
const [resource] = useWebsiteContent(uuid)
useEffect(() => {
if (!resource?.type) return
location.replace({
pathname: `/type/${resource.type}/${uuid}`
})
}, [uuid, location, resource?.type])
}
The tooltip shown in the above picture only works (correctly) for
resource
type content.When used for other types, this UI (tooltip) always opens a
resource
SiteContent form, regardless of the type of the linked content.This incorrect form confuses the user. The user can also enter data for the presented fields. This can result in the pollution of data as the user can add resource fields to other types of content.
Expected Behavior
For a content type
x
, the link should beCurrent Behavior
For any content type, the link is
Steps to Reproduce
Possible Solution
I believe all we have to do is update the frontend code to consider the linked content's type when generating these tooltip URLs. However, I cannot estimate the effort for this at the moment.