Skip to content
New issue

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

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

Already on GitHub? # to your account

Feature/extension list show info when no repo is defined #556

Merged
merged 2 commits into from
Jan 15, 2024
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
5 changes: 3 additions & 2 deletions src/i18n/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
}
},
"label": {
"add_repository_info": "You have to add a extension repository to be able to install extensions",
"installation_failed": "Could not install the extension",
"installed_successfully": "Extension installed",
"installing_file": "Installing extension file…",
Expand All @@ -249,9 +250,9 @@
}
},
"label": {
"description": "Add custom repositories from which extensions can be installed",
"description": "Add repositories from which extensions can be installed",
"disclaimer": "<strong>Suwayomi does not provide any support for 3rd party repositories or extensions!</strong><br/>Use with caution as there could be malicious actors making those repositories.<br/>You as the user need to verify the security and that you trust any repository or extension.",
"title": "Custom repositories"
"title": "Extension repositories"
}
}
}
Expand Down
18 changes: 16 additions & 2 deletions src/screens/Extensions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import { fromEvent } from 'file-selector';
import IconButton from '@mui/material/IconButton';
import AddIcon from '@mui/icons-material/Add';
import { StringParam, useQueryParam } from 'use-query-params';
import { Tooltip, useMediaQuery } from '@mui/material';
import { Button, Stack, Tooltip, Typography, useMediaQuery } from '@mui/material';
import { useTranslation } from 'react-i18next';
import { useTheme } from '@mui/material/styles';
import { Link } from 'react-router-dom';
import { requestManager } from '@/lib/requests/RequestManager.ts';
import { extensionDefaultLangs, DefaultLanguage, langSortCmp } from '@/util/language';
import { useLocalStorage } from '@/util/useLocalStorage';
Expand Down Expand Up @@ -99,7 +100,8 @@ export function Extensions() {
const isMobileWidth = useMediaQuery(theme.breakpoints.down('sm'));

const { data: serverSettingsData } = requestManager.useGetServerSettings();
const areMultipleReposInUse = !!serverSettingsData?.settings.extensionRepos.length; // tachiyomi repo is used by default
const areReposDefined = !!serverSettingsData?.settings.extensionRepos.length;
const areMultipleReposInUse = (serverSettingsData?.settings.extensionRepos.length ?? 0) > 1;

const inputRef = useRef<HTMLInputElement>(null);
const { setTitle, setAction } = useContext(NavBarContext);
Expand Down Expand Up @@ -206,6 +208,18 @@ export function Extensions() {
return <LoadingPlaceholder />;
}

const showAddRepoInfo = !allExtensions?.length && !areReposDefined;
if (showAddRepoInfo) {
return (
<Stack sx={{ paddingTop: '20px' }} alignItems="center" justifyContent="center" rowGap="10px">
<Typography>{t('extension.label.add_repository_info')}</Typography>
<Button component={Link} variant="contained" to="/settings/server">
{t('settings.title')}
</Button>
</Stack>
);
}

return (
<>
{toasts}
Expand Down