Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add org content library #14535

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion frontend/dashboard/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import { useOrganizationsQuery } from '../hooks/queries';
import './App.css';
import { PageLayout } from 'dashboard/pages/PageLayout';
import { Trans, useTranslation } from 'react-i18next';
import { DASHBOARD_ROOT_ROUTE } from 'app-shared/constants';
import { DASHBOARD_ROOT_ROUTE, ORG_LIBRARY_BASENAME } from 'app-shared/constants';
import { Link } from '@digdir/designsystemet-react';
import { OrgContentLibrary } from '../pages/OrgContentLibrary';

export const App = (): JSX.Element => {
const { t } = useTranslation();
Expand Down Expand Up @@ -71,6 +72,10 @@ export const App = (): JSX.Element => {
path='/:selectedContext/new'
element={<CreateService organizations={organizations} user={user} />}
/>
<Route
path={`/${ORG_LIBRARY_BASENAME}/:selectedContext`}
element={<OrgContentLibrary />}
/>
</Route>
</Routes>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import { OrgContentLibrary } from './OrgContentLibrary';
import { screen } from '@testing-library/react';
import { textMock } from '@studio/testing/mocks/i18nMock';
import { renderWithProviders } from '../../testing/mocks';

describe('OrgContentLibrary', () => {
it('renders the library title', () => {
renderWithProviders(<OrgContentLibrary />);
const libraryTitle = screen.getByRole('heading', {
name: textMock('app_content_library.library_heading'),
});
expect(libraryTitle).toBeInTheDocument();
});

it('renders the library landing page by default', () => {
renderWithProviders(<OrgContentLibrary />);
const landingPageTitle = screen.getByRole('heading', {
name: textMock('app_content_library.landing_page.title'),
});
expect(landingPageTitle).toBeInTheDocument();
const landingPageDescription = screen.getByText(
textMock('app_content_library.landing_page.description'),
);
expect(landingPageDescription).toBeInTheDocument();
});

it('renders the code list menu element', () => {
renderWithProviders(<OrgContentLibrary />);
const codeListMenuElement = screen.getByRole('tab', {
name: textMock('app_content_library.code_lists.page_name'),
});
expect(codeListMenuElement).toBeInTheDocument();
});
});
21 changes: 21 additions & 0 deletions frontend/dashboard/pages/OrgContentLibrary/OrgContentLibrary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { ReactElement } from 'react';
import React from 'react';
import { ResourceContentLibraryImpl } from '@studio/content-library';

export function OrgContentLibrary(): ReactElement {
const { getContentResourceLibrary } = new ResourceContentLibraryImpl({
pages: {
codeList: {
props: {
codeListsData: [],
onDeleteCodeList: () => {},
onUpdateCodeListId: () => {},
onUpdateCodeList: () => {},
onUploadCodeList: () => {},
},
},
},
});

return <div>{getContentResourceLibrary()}</div>;
}
1 change: 1 addition & 0 deletions frontend/dashboard/pages/OrgContentLibrary/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './OrgContentLibrary';
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type CodeListPageProps = {
onUpdateCodeListId: (codeListId: string, newCodeListId: string) => void;
onUpdateCodeList: (updatedCodeList: CodeListWithMetadata) => void;
onUploadCodeList: (uploadedCodeList: File) => void;
codeListsUsages: CodeListReference[];
codeListsUsages?: CodeListReference[];
};

export function CodeListPage({
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/shared/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const APP_DEVELOPMENT_BASENAME = '/editor';
export const DASHBOARD_BASENAME = '/dashboard';
export const DASHBOARD_ROOT_ROUTE = '/';
export const RESOURCEADM_BASENAME = '/resourceadm';
export const STUDIO_LIBRARY_BASENAME = '/library';
export const ORG_LIBRARY_BASENAME = '/library';
export const PREVIEW_BASENAME = '/preview';
export const STUDIO_ROOT_BASENAME = '/';
export const DEFAULT_LANGUAGE = 'nb';
Expand Down