Skip to content

Commit

Permalink
Merge pull request #9 from CSCfi/content-registration
Browse files Browse the repository at this point in the history
Content registration etc
  • Loading branch information
maariaw authored Nov 24, 2023
2 parents a979bc6 + 15c7e14 commit b937c28
Show file tree
Hide file tree
Showing 60 changed files with 5,924 additions and 5,171 deletions.
2 changes: 1 addition & 1 deletion common-ui/components/locale-chooser/use-locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export default function useLocales(): UseLocalesResult {
}

const locales: { locale: Locale; label: string }[] = [
{ locale: 'en', label: 'In English (EN)' },
{ locale: 'fi', label: 'Suomeksi (FI)' },
{ locale: 'sv', label: 'På svenska (SV)' },
{ locale: 'en', label: 'In English (EN)' },
];

return {
Expand Down
16 changes: 10 additions & 6 deletions datamodel-ui/src/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import Document, { DocumentContext } from 'next/document';
import Document, { DocumentContext, DocumentInitialProps } from 'next/document';
import { ServerStyleSheet } from 'styled-components';

// https://github.com/msreekm/nextjs-material-ui-styled-components-boilerplate/blob/master/pages/_document.js
//Fixing the custom render page error, https://nextjs.org/docs/pages/building-your-application/routing/custom-document
export default class MyDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
static async getInitialProps(
ctx: DocumentContext
): Promise<DocumentInitialProps> {
const sheet = new ServerStyleSheet();
const originalRenderPage = ctx.renderPage;

try {
// Run the React rendering logic synchronously
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: (App) => (props) =>
sheet.collectStyles(<App {...props} />),
// Useful for wrapping the whole react tree
enhanceApp: (App) => App,
// Useful for wrapping in a per-page basis
enhanceComponent: (Component) => Component,
});

const initialProps = await ctx.defaultGetInitialProps(ctx);
return {
...initialProps,
Expand Down
7 changes: 7 additions & 0 deletions mscr-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ The `pages/api` directory is mapped to `/api/*`. Files in this directory are tre
## Troubleshooting and more documentation

You can find more documentation in [docs](../docs).

curl -X 'PUT' \
'http://localhost:9004/datamodel-api/v2/schemaFull?metadata=%7Bmetadata%3A%7B%20%20%20%22namespace%22%3A%20%22http%3A%2F%2Ftest.com%22%2C%20%22%20%20%20%20%20%22format%22%3A%20%22JSONSCHEMA%22%2C%20%20%20%22status%22%3A%20%22INCOMPLETE%22%2C%20%20%20%22label%22%3A%20%7B%20%20%20%20%20%22en%22%3A%20%22string%22%20%20%20%7D%2C%20%20%20%22description%22%3A%20%7B%20%20%20%20%20%22en%22%3A%20%22string%22%20%20%20%7D%2C%20%20%20%22languages%22%3A%20%5B%20%20%20%20%20%22en%22%20%20%20%5D%2C%20%20%20%22organizations%22%3A%20%5B%227d3a3c00-5a6b-489b-a3ed-63bb58c26a63%22%5D%20%7D%7D' \
-H 'accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI0Y2U3MDkzNy02ZmE0LTQ5YWYtYTIyOS1iNWYxMDMyOGFkYjgiLCJleHAiOjE3MTUzMzk5NjUsImlhdCI6MTY5OTYxNTE2NX0.oNDwK2Cv3C4LZ2bt8Z9F4druC58fTs_dXfbK3WSpYuW1gTK_ZplCvrBP8h6orZJbnW6fpk_I1rMuw7yFUhM2tA' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@test_json_trimmed.json;type=application/json'
Binary file added mscr-ui/public/supporting_eosc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 42 additions & 41 deletions mscr-ui/src/common/components/crosswalk-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function CrosswalkList({
}: CrosswalkListProps) {
const { t } = useTranslation('admin');

if (items.length < 1) {
if (items && items.length < 1) {
return <div>{'There is no Schemas or Crosswalks to show'}</div>;
}

Expand Down Expand Up @@ -56,47 +56,48 @@ export default function CrosswalkList({
</ListItem>
</List>
<List className="inline-list">
{items.map((item) => (
<ListItem
key={item.pid}
onClick={() => handleClick(item.pid)}
onMouseEnter={() => item.onMouseEnter && item.onMouseEnter()}
onMouseLeave={() => item.onMouseLeave && item.onMouseLeave()}
onKeyDown={(e) => e.key === 'Enter' && item.onClick()}
>
<Grid container spacing={2}>
<Grid item xs={2}>
{item.label}
{items &&
items.map((item) => (
<ListItem
key={item.pid}
onClick={() => handleClick(item.pid)}
onMouseEnter={() => item.onMouseEnter && item.onMouseEnter()}
onMouseLeave={() => item.onMouseLeave && item.onMouseLeave()}
onKeyDown={(e) => e.key === 'Enter' && item.onClick()}
>
<Grid container spacing={2}>
<Grid item xs={2}>
{item.label}
</Grid>
<Grid item xs={2}>
{item.prefix}
</Grid>
<Grid item xs={2}>
{item.status}
</Grid>
<Grid item xs={2}>
{item.revision}
</Grid>
<Grid item xs={2}>
{item.pid}
</Grid>
<Grid item xs={2}>
{Array.isArray(deleteDisabled) &&
deleteDisabled.includes(item.pid) ? (
<></>
) : (
<Button
variant="secondaryNoBorder"
icon="remove"
onClick={() => handleRemoval(item.pid)}
>
{t('remove')}
</Button>
)}
</Grid>
</Grid>
<Grid item xs={2}>
{item.prefix}
</Grid>
<Grid item xs={2}>
{item.status}
</Grid>
<Grid item xs={2}>
{item.revision}
</Grid>
<Grid item xs={2}>
{item.pid}
</Grid>
<Grid item xs={2}>
{Array.isArray(deleteDisabled) &&
deleteDisabled.includes(item.pid) ? (
<></>
) : (
<Button
variant="secondaryNoBorder"
icon="remove"
onClick={() => handleRemoval(item.pid)}
>
{t('remove')}
</Button>
)}
</Grid>
</Grid>
</ListItem>
))}
</ListItem>
))}
</List>
</div>
);
Expand Down
21 changes: 19 additions & 2 deletions mscr-ui/src/common/components/crosswalk/crosswalk.slice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ export const crosswalkApi = createApi({
data: value,
}),
}),
//Register Crosswalk with file
putCrosswalkFull: builder.mutation<any, FormData>({
query: (file) => ({
url: '/crosswalkFull',
method: 'PUT',
data: file,
headers: {
'content-Type': 'multipart/form-data;',
},
}),
}),
getCrosswalk: builder.query<Crosswalk, string>({
query: (pid) => ({
url: `/crosswalk/${pid}`,
Expand Down Expand Up @@ -58,14 +69,20 @@ export const crosswalkApi = createApi({

export const {
usePutCrosswalkMutation,
usePutCrosswalkFullMutation,
useGetCrosswalkQuery,
usePostCrosswalkMutation,
useDeleteCrosswalkMutation,
util: { getRunningQueriesThunk },
} = crosswalkApi;

export const { putCrosswalk, getCrosswalk, postCrosswalk, deleteCrosswalk } =
crosswalkApi.endpoints;
export const {
putCrosswalk,
putCrosswalkFull,
getCrosswalk,
postCrosswalk,
deleteCrosswalk,
} = crosswalkApi.endpoints;

// Slice setup below

Expand Down
14 changes: 12 additions & 2 deletions mscr-ui/src/common/components/history-table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ import TableCell from '@mui/material/TableCell';
import TableBody from '@mui/material/TableBody';
import { Revision } from '@app/common/interfaces/schema.interface';

export default function HistoryTable({ headers, revisions, ariaLabel }: { headers: Array<string>; revisions: Revision[]; ariaLabel: string }) {
export default function HistoryTable({
headers,
revisions,
ariaLabel,
}: {
headers: Array<string>;
revisions: Revision[];
ariaLabel: string;
}) {
return (
<TableContainer>
<Table aria-label={ariaLabel}>
<TableHead>
<TableRow>
{headers.map((header) => <TableCell key={header}>{header}</TableCell>)}
{headers.map((header) => (
<TableCell key={header}>{header}</TableCell>
))}
</TableRow>
</TableHead>
<TableBody>
Expand Down
1 change: 0 additions & 1 deletion mscr-ui/src/common/components/layout/layout.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const NavigationContainer = styled.div<{ $breakpoint: Breakpoint }>`

// content layout


export const ContentContainer = styled.div<{ $fullScreen?: boolean }>`
background-color: ${(props) =>
props.$fullScreen
Expand Down
25 changes: 14 additions & 11 deletions mscr-ui/src/common/components/layout/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState} from 'react';
import React, { useState } from 'react';
import { ThemeProvider } from 'styled-components';
import { lightTheme } from 'yti-common-ui/theme';
import {
Expand All @@ -13,10 +13,10 @@ import SkipLink from 'yti-common-ui/skip-link';
import { FakeableUser } from '../../interfaces/fakeable-user.interface';
import generateFakeableUsers from 'yti-common-ui/utils/generate-impersonate';
import SideNavigationPanel from '../side-navigation';
import {MscrUser} from '@app/common/interfaces/mscr-user.interface';
import {SearchContext} from '@app/common/components/search-context-provider';
import { MscrUser } from '@app/common/interfaces/mscr-user.interface';
import { SearchContext } from '@app/common/components/search-context-provider';
import SearchScreen from '@app/modules/search-screen';
import {Grid} from '@mui/material';
import { Grid } from '@mui/material';

export default function Layout({
children,
Expand All @@ -39,22 +39,24 @@ export default function Layout({
const { breakpoint } = useBreakpoints();
const [isSearchActive, setIsSearchActive] = useState(false);


return (
<ThemeProvider theme={lightTheme}>
<SearchContext.Provider
value={{
isSearchActive,
setIsSearchActive
setIsSearchActive,
}}
>
>
{matomo && matomo}
<SkipLink href="#main">{t('skip-link-main')}</SkipLink>
{fullScreenElements ? (
<SiteContainer>
<SmartHeader
user={user}
fakeableUsers={generateFakeableUsers(i18n.language, fakeableUsers)}
fakeableUsers={generateFakeableUsers(
i18n.language,
fakeableUsers
)}
fullScreenElements={fullScreenElements}
/>

Expand All @@ -68,10 +70,12 @@ export default function Layout({
<SiteContainer>
<SmartHeader
user={user}
fakeableUsers={generateFakeableUsers(i18n.language, fakeableUsers)}
fakeableUsers={generateFakeableUsers(
i18n.language,
fakeableUsers
)}
/>
<Grid container spacing={2}>

<Grid item xs={12}>
<ContentContainer>
{alerts && alerts}
Expand All @@ -85,7 +89,6 @@ export default function Layout({
</SiteContainer>
)}
</SearchContext.Provider>

</ThemeProvider>
);
}
32 changes: 16 additions & 16 deletions mscr-ui/src/common/components/mscr-search/mscr-search.slice.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {createApi} from '@reduxjs/toolkit/query/react';
import {getDatamodelApiBaseQuery} from '@app/store/api-base-query';
import {HYDRATE} from 'next-redux-wrapper';
import {MscrSearchResults} from '@app/common/interfaces/search.interface';
import {UrlState} from '@app/common/utils/hooks/use-url-state';
import { createApi } from '@reduxjs/toolkit/query/react';
import { getDatamodelApiBaseQuery } from '@app/store/api-base-query';
import { HYDRATE } from 'next-redux-wrapper';
import { MscrSearchResults } from '@app/common/interfaces/search.interface';
import { UrlState } from '@app/common/utils/hooks/use-url-state';

function createUrl(urlState: UrlState) {
let baseQuery = '/frontend/mscrSearch?';
Expand All @@ -22,10 +22,14 @@ function createUrl(urlState: UrlState) {
baseQuery = baseQuery.concat(`&format=${urlState.format.join(',')}`);
}
if (urlState.sourceType && urlState.sourceType.length > 0) {
baseQuery = baseQuery.concat(`&sourceType=${urlState.sourceType.join(',')}`);
baseQuery = baseQuery.concat(
`&sourceType=${urlState.sourceType.join(',')}`
);
}
if (urlState.organization && urlState.organization.length > 0) {
baseQuery = baseQuery.concat(`&organization=${urlState.organization.join(',')}`);
baseQuery = baseQuery.concat(
`&organization=${urlState.organization.join(',')}`
);
}

return baseQuery;
Expand All @@ -41,22 +45,18 @@ export const mscrSearchApi = createApi({
}
},
endpoints: (builder) => ({
getMscrSearchResults: builder.query<
MscrSearchResults,
UrlState
>({
getMscrSearchResults: builder.query<MscrSearchResults, UrlState>({
query: (urlState) => ({
url: createUrl(urlState),
method: 'GET',
})
})
})

}),
}),
}),
});

export const { getMscrSearchResults } = mscrSearchApi.endpoints;

export const {
useGetMscrSearchResultsQuery,
util: { getRunningQueriesThunk},
util: { getRunningQueriesThunk },
} = mscrSearchApi;
Loading

0 comments on commit b937c28

Please sign in to comment.