Merge pull request #121 from notfakie/develop

Hide Overseerr settings when running in Jellyfin/Emby mode
This commit is contained in:
Fallenbagel
2022-06-02 14:42:49 +05:00
committed by GitHub
3 changed files with 48 additions and 64 deletions

View File

@@ -188,35 +188,6 @@ const SettingsAbout: React.FC = () => {
</List.Item> </List.Item>
</List> </List>
</div> </div>
<div className="section">
<List title={intl.formatMessage(messages.supportoverseerr)}>
<List.Item
title={`${intl.formatMessage(messages.helppaycoffee)} ☕️`}
>
<a
href="https://github.com/sponsors/sct"
target="_blank"
rel="noreferrer"
className="text-indigo-500 transition duration-300 hover:underline"
>
https://github.com/sponsors/sct
</a>
<Badge className="ml-2">
{intl.formatMessage(messages.preferredmethod)}
</Badge>
</List.Item>
<List.Item title="">
<a
href="https://patreon.com/overseerr"
target="_blank"
rel="noreferrer"
className="text-indigo-500 transition duration-300 hover:underline"
>
https://patreon.com/overseerr
</a>
</List.Item>
</List>
</div>
<div className="section"> <div className="section">
<Releases currentVersion={data.version} /> <Releases currentVersion={data.version} />
</div> </div>

View File

@@ -10,9 +10,11 @@ import {
} from 'react-intl'; } from 'react-intl';
import { useToasts } from 'react-toast-notifications'; import { useToasts } from 'react-toast-notifications';
import useSWR from 'swr'; import useSWR from 'swr';
import { MediaServerType } from '../../../../server/constants/server';
import { CacheItem } from '../../../../server/interfaces/api/settingsInterfaces'; import { CacheItem } from '../../../../server/interfaces/api/settingsInterfaces';
import { JobId } from '../../../../server/lib/settings'; import { JobId } from '../../../../server/lib/settings';
import Spinner from '../../../assets/spinner.svg'; import Spinner from '../../../assets/spinner.svg';
import useSettings from '../../../hooks/useSettings';
import globalMessages from '../../../i18n/globalMessages'; import globalMessages from '../../../i18n/globalMessages';
import { formatBytes } from '../../../utils/numberHelpers'; import { formatBytes } from '../../../utils/numberHelpers';
import Badge from '../../Common/Badge'; import Badge from '../../Common/Badge';
@@ -102,6 +104,7 @@ const SettingsJobs: React.FC = () => {
const [isSaving, setIsSaving] = useState(false); const [isSaving, setIsSaving] = useState(false);
const [jobScheduleMinutes, setJobScheduleMinutes] = useState(5); const [jobScheduleMinutes, setJobScheduleMinutes] = useState(5);
const [jobScheduleHours, setJobScheduleHours] = useState(1); const [jobScheduleHours, setJobScheduleHours] = useState(1);
const settings = useSettings();
if (!data && !error) { if (!data && !error) {
return <LoadingSpinner />; return <LoadingSpinner />;
@@ -369,22 +372,33 @@ const SettingsJobs: React.FC = () => {
</tr> </tr>
</thead> </thead>
<Table.TBody> <Table.TBody>
{cacheData?.map((cache) => ( {cacheData
<tr key={`cache-list-${cache.id}`}> ?.filter(
<Table.TD>{cache.name}</Table.TD> (cache) =>
<Table.TD>{intl.formatNumber(cache.stats.hits)}</Table.TD> !(
<Table.TD>{intl.formatNumber(cache.stats.misses)}</Table.TD> settings.currentSettings.mediaServerType !==
<Table.TD>{intl.formatNumber(cache.stats.keys)}</Table.TD> MediaServerType.PLEX && cache.id === 'plexguid'
<Table.TD>{formatBytes(cache.stats.ksize)}</Table.TD> )
<Table.TD>{formatBytes(cache.stats.vsize)}</Table.TD> )
<Table.TD alignText="right"> .map((cache) => (
<Button buttonType="danger" onClick={() => flushCache(cache)}> <tr key={`cache-list-${cache.id}`}>
<TrashIcon /> <Table.TD>{cache.name}</Table.TD>
<span>{intl.formatMessage(messages.flushcache)}</span> <Table.TD>{intl.formatNumber(cache.stats.hits)}</Table.TD>
</Button> <Table.TD>{intl.formatNumber(cache.stats.misses)}</Table.TD>
</Table.TD> <Table.TD>{intl.formatNumber(cache.stats.keys)}</Table.TD>
</tr> <Table.TD>{formatBytes(cache.stats.ksize)}</Table.TD>
))} <Table.TD>{formatBytes(cache.stats.vsize)}</Table.TD>
<Table.TD alignText="right">
<Button
buttonType="danger"
onClick={() => flushCache(cache)}
>
<TrashIcon />
<span>{intl.formatMessage(messages.flushcache)}</span>
</Button>
</Table.TD>
</tr>
))}
</Table.TBody> </Table.TBody>
</Table> </Table>
</div> </div>

View File

@@ -1,9 +1,11 @@
import getConfig from 'next/config';
import React from 'react'; import React from 'react';
import { defineMessages, useIntl } from 'react-intl'; import { defineMessages, useIntl } from 'react-intl';
import { MediaServerType } from '../../../server/constants/server';
import useSettings from '../../hooks/useSettings';
import globalMessages from '../../i18n/globalMessages'; import globalMessages from '../../i18n/globalMessages';
import PageTitle from '../Common/PageTitle'; import PageTitle from '../Common/PageTitle';
import SettingsTabs, { SettingsRoute } from '../Common/SettingsTabs'; import SettingsTabs, { SettingsRoute } from '../Common/SettingsTabs';
import getConfig from 'next/config';
const messages = defineMessages({ const messages = defineMessages({
menuGeneralSettings: 'General', menuGeneralSettings: 'General',
@@ -20,6 +22,7 @@ const messages = defineMessages({
const SettingsLayout: React.FC = ({ children }) => { const SettingsLayout: React.FC = ({ children }) => {
const intl = useIntl(); const intl = useIntl();
const { publicRuntimeConfig } = getConfig(); const { publicRuntimeConfig } = getConfig();
const settings = useSettings();
const settingsRoutes: SettingsRoute[] = [ const settingsRoutes: SettingsRoute[] = [
{ {
text: intl.formatMessage(messages.menuGeneralSettings), text: intl.formatMessage(messages.menuGeneralSettings),
@@ -31,16 +34,17 @@ const SettingsLayout: React.FC = ({ children }) => {
route: '/settings/users', route: '/settings/users',
regex: /^\/settings\/users/, regex: /^\/settings\/users/,
}, },
{ settings.currentSettings.mediaServerType === MediaServerType.PLEX
text: intl.formatMessage(messages.menuPlexSettings), ? {
route: '/settings/plex', text: intl.formatMessage(messages.menuPlexSettings),
regex: /^\/settings\/plex/, route: '/settings/plex',
}, regex: /^\/settings\/plex/,
{ }
text: getAvalaibleMediaServerName(), : {
route: '/settings/jellyfin', text: getAvailableMediaServerName(),
regex: /^\/settings\/jellyfin/, route: '/settings/jellyfin',
}, regex: /^\/settings\/jellyfin/,
},
{ {
text: intl.formatMessage(messages.menuServices), text: intl.formatMessage(messages.menuServices),
route: '/settings/services', route: '/settings/services',
@@ -77,15 +81,10 @@ const SettingsLayout: React.FC = ({ children }) => {
<div className="mt-10 text-white">{children}</div> <div className="mt-10 text-white">{children}</div>
</> </>
); );
function getAvalaibleMediaServerName() { function getAvailableMediaServerName() {
if (publicRuntimeConfig.JELLYFIN_TYPE === 'emby') {
return intl.formatMessage(messages.menuJellyfinSettings, {
mediaServerName: 'Emby',
});
}
return intl.formatMessage(messages.menuJellyfinSettings, { return intl.formatMessage(messages.menuJellyfinSettings, {
mediaServerName: 'Jellyfin', mediaServerName:
publicRuntimeConfig.JELLYFIN_TYPE === 'emby' ? 'Emby' : 'Jellyfin',
}); });
} }
}; };