@treely/strapi-slices 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@treely/strapi-slices",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "license": "MIT",
5
5
  "author": "Tree.ly GmbH",
6
6
  "description": "@treely/strapi-slices is a open source library maintained by Tree.ly.",
@@ -3,7 +3,9 @@ import CreditsAvailableState from './CreditsAvailableState';
3
3
  import FPMProject from './fpm/FPMProject';
4
4
 
5
5
  interface PortfolioProject extends FPMProject {
6
+ /** Remember to prefix the slug with portfolioHost */
6
7
  slug?: string;
8
+ portfolioHost?: string;
7
9
  thumbnail?: StrapiImage | null;
8
10
  creditsAvailable?: CreditsAvailableState;
9
11
  footerSubTitle?: string;
@@ -3,6 +3,7 @@ import Locale from '../Locale';
3
3
  interface StrapiPortfolio {
4
4
  name: string;
5
5
  title: string;
6
+ host?: string;
6
7
  slices: any[];
7
8
  locale: Locale;
8
9
  createdAt: string;
@@ -34,4 +34,27 @@ describe('The ProjectsGrid component', () => {
34
34
 
35
35
  expect(screen.getByText(fpmProjectMock.title)).toBeInTheDocument();
36
36
  });
37
+
38
+ it('links to the portfolio', () => {
39
+ setup();
40
+
41
+ expect(screen.getByRole('link')).toHaveProperty(
42
+ 'href',
43
+ 'http://localhost/portfolio/slug'
44
+ );
45
+ });
46
+
47
+ it('prefixes the url with the portfolio host', () => {
48
+ setup({
49
+ ...defaultProps,
50
+ projects: [
51
+ { ...defaultProps.projects[0], portfolioHost: 'https://example.org' },
52
+ ],
53
+ });
54
+
55
+ expect(screen.getByRole('link')).toHaveProperty(
56
+ 'href',
57
+ 'https://example.org/portfolio/slug'
58
+ );
59
+ });
37
60
  });
@@ -46,7 +46,9 @@ export const ProjectsGrid: React.FC<ProjectsGridProps> = ({
46
46
  condition={!!project.slug}
47
47
  wrapper={(children: JSX.Element) => (
48
48
  <Link
49
- href={`/portfolio/${project.slug}`}
49
+ href={`${project.portfolioHost || ''}/portfolio/${
50
+ project.slug
51
+ }`}
50
52
  passHref
51
53
  key={project.id}
52
54
  legacyBehavior
@@ -6,6 +6,7 @@ import messagesEn from './messages.en';
6
6
 
7
7
  const defaultProps: MapMarkerProps = {
8
8
  title: 'Project title',
9
+ portfolioHost: '',
9
10
  isPublic: true,
10
11
  };
11
12
 
@@ -37,7 +38,26 @@ describe('The MapMarker component', () => {
37
38
 
38
39
  expect(screen.getByTestId('mapmarker-pin').parentElement).toHaveProperty(
39
40
  'href',
40
- expect.stringContaining('/portfolio/slug')
41
+ 'http://localhost/portfolio/slug'
42
+ );
43
+
44
+ fireEvent.mouseEnter(screen.getByTestId('mapmarker-pin'));
45
+
46
+ waitFor(() => {
47
+ const button = screen.getByText(
48
+ messagesEn['sections.projectsMap.link.text']
49
+ );
50
+ expect(button).toBeInTheDocument();
51
+ expect(button).toHaveProperty('href', '/portfolio/slug');
52
+ });
53
+ });
54
+
55
+ it('prefixes the url with the portfolio host', () => {
56
+ setup({ slug: 'slug', portfolioHost: 'https://example.com' });
57
+
58
+ expect(screen.getByTestId('mapmarker-pin').parentElement).toHaveProperty(
59
+ 'href',
60
+ 'https://example.com/portfolio/slug'
41
61
  );
42
62
 
43
63
  fireEvent.mouseEnter(screen.getByTestId('mapmarker-pin'));
@@ -49,7 +69,7 @@ describe('The MapMarker component', () => {
49
69
  expect(button).toBeInTheDocument();
50
70
  expect(button).toHaveProperty(
51
71
  'href',
52
- expect.stringContaining('/portfolio/slug')
72
+ 'https://example.com/portfolio/slug'
53
73
  );
54
74
  });
55
75
  });
@@ -20,6 +20,7 @@ export interface MapMarkerProps {
20
20
  isPublic?: boolean;
21
21
  projectDeveloper?: string;
22
22
  slug?: string;
23
+ portfolioHost?: string;
23
24
  creditsAvailable?: CreditsAvailableState;
24
25
  }
25
26
 
@@ -28,6 +29,7 @@ const MapMarker = ({
28
29
  projectDeveloper,
29
30
  slug,
30
31
  creditsAvailable,
32
+ portfolioHost = '',
31
33
  isPublic = false,
32
34
  }: MapMarkerProps) => {
33
35
  const { formatMessage } = useContext(IntlContext);
@@ -42,7 +44,10 @@ const MapMarker = ({
42
44
  onMouseLeave={onClose}
43
45
  cursor="grab"
44
46
  >
45
- <Box as={slug ? NextLink : undefined} href={slug && `/portfolio/${slug}`}>
47
+ <Box
48
+ as={slug ? NextLink : undefined}
49
+ href={slug && `${portfolioHost}/portfolio/${slug}`}
50
+ >
46
51
  <MapPin
47
52
  size="40px"
48
53
  color={blue600}
@@ -64,7 +69,7 @@ const MapMarker = ({
64
69
  <>
65
70
  <CreditsAvailableBadge
66
71
  status={creditsAvailable}
67
- href={slug && `/portfolio/${slug}`}
72
+ href={slug && `${portfolioHost}/portfolio/${slug}`}
68
73
  />
69
74
  <Box height="3" />
70
75
  </>
@@ -84,7 +89,7 @@ const MapMarker = ({
84
89
  variant="outline"
85
90
  size="sm"
86
91
  as={NextLink}
87
- href={`/portfolio/${slug}`}
92
+ href={`${portfolioHost}/portfolio/${slug}`}
88
93
  mt="4"
89
94
  whiteSpace="nowrap"
90
95
  >
@@ -97,6 +97,7 @@ export const ProjectsMap: React.FC<ProjectsMapProps> = ({
97
97
  <MapMarker
98
98
  title={project.title}
99
99
  isPublic={project.isPublic}
100
+ portfolioHost={project.portfolioHost}
100
101
  slug={project.slug}
101
102
  creditsAvailable={project.creditsAvailable}
102
103
  projectDeveloper={project.projectDeveloper?.name}