Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions src/AppContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { RootState } from './state/rootReducer';
import { LMSParametersName } from './types/LMSParameters';
import { getPackedUrlCurrentPathForFeideLogin } from './utils/rewriteSearchParams';
import BackButton from './components/BackButton';
import { Alert } from '@mui/material';

const StyledApp = styled.div`
min-height: 100vh;
Expand Down Expand Up @@ -52,6 +53,8 @@ const AppContent: FC<LMSServiceProps> = ({ mainContentRef, userError }) => {
{navbar ? <Header /> : <BackButton />}
{userError && <ErrorBanner error={userError} />}
<StyledContent tabIndex={-1} ref={mainContentRef} role="main" id="content">
<br />
<Alert severity="info">DLR er stengt for opplastning av nytt innhold da tjenesten skal legges ned.</Alert>
<AppRoutes />
</StyledContent>
{footer && <Footer />}
Expand Down
49 changes: 33 additions & 16 deletions src/layout/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import LoginButton from './LoginButton';
import Logo from './Logo';
import styled from 'styled-components';
import { Button, IconButton, Typography, useMediaQuery } from '@mui/material';
import { Button, IconButton, Tooltip, Typography, useMediaQuery } from '@mui/material';
import { Link, Link as RouterLink } from 'react-router-dom';
import MenuIcon from '@mui/icons-material/Menu';
import { useSelector } from 'react-redux';
Expand Down Expand Up @@ -50,6 +50,13 @@ const StyledLanguageButtonUserIsNotLoggedInVariant = styled.div`
justify-content: flex-end;
`;

const StyledDisabledButton = styled.div`
cursor: not-allowed;
opacity: 0.5;
`;

const TooltipDisabledButtonText = 'DLR er stengt for opplastning av nytt innhold da tjenesten skal legges ned.';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd think about replacing the use of const here with a referenced string in translations/…(EN|NO).json

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good observation!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I'll move the string and send in a change soon:)


const Header = () => {
const user = useSelector((state: RootState) => state.user);
const { t } = useTranslation();
Expand Down Expand Up @@ -83,13 +90,18 @@ const Header = () => {
open={Boolean(anchorEl)}
onClose={handleBurgerMenuClose}>
{user.id && (
<MenuItem
onClick={handleBurgerMenuClose}
component={Link}
to={generateNewUrlAndRetainLMSParams('/registration')}>
<AddIcon />
<Typography variant="button">{t('resource.new_registration')}</Typography>
</MenuItem>
<Tooltip title={TooltipDisabledButtonText} placement="right">
<StyledDisabledButton>
<MenuItem
onClick={handleBurgerMenuClose}
component={Link}
to={generateNewUrlAndRetainLMSParams('/registration')}
disabled>
<AddIcon />
<Typography variant="button">{t('resource.new_registration')}</Typography>
</MenuItem>
</StyledDisabledButton>
</Tooltip>
)}
{user.id && (
<MenuItem
Expand Down Expand Up @@ -133,14 +145,19 @@ const Header = () => {

{!isMediumOrSmallerScreen && user.id && (
<>
<Button
color="neutral"
component={RouterLink}
data-testid="new-registration-link"
to={generateNewUrlAndRetainLMSParams('/registration')}
startIcon={<AddIcon />}>
<Typography variant="button">{t('resource.new_registration')}</Typography>
</Button>
<Tooltip title={TooltipDisabledButtonText}>
<StyledDisabledButton>
<Button
color="neutral"
component={RouterLink}
data-testid="new-registration-link"
to={generateNewUrlAndRetainLMSParams('/registration')}
startIcon={<AddIcon />}
disabled>
<Typography variant="button">{t('resource.new_registration')}</Typography>
</Button>
</StyledDisabledButton>
</Tooltip>

<Button
color="neutral"
Expand Down