Revert "Do not display tabs with no content (#2468)" (#2487)

This reverts commit 0ee8930bdd.
This commit is contained in:
WithoutPants
2022-04-06 15:08:54 +10:00
committed by GitHub
parent 2ca457c5b2
commit 638b2b4a32
5 changed files with 184 additions and 259 deletions

View File

@@ -6,7 +6,6 @@
### 🎨 Improvements ### 🎨 Improvements
* Added support for Handy APIv2. ([#2193](https://github.com/stashapp/stash/pull/2193)) * Added support for Handy APIv2. ([#2193](https://github.com/stashapp/stash/pull/2193))
* Hide tabs with no content in Performer, Studio and Tag pages. ([#2468](https://github.com/stashapp/stash/pull/2468))
* Added support for bulk editing most performer fields. ([#2467](https://github.com/stashapp/stash/pull/2467)) * Added support for bulk editing most performer fields. ([#2467](https://github.com/stashapp/stash/pull/2467))
* Changed video player to videojs. ([#2100](https://github.com/stashapp/stash/pull/2100)) * Changed video player to videojs. ([#2100](https://github.com/stashapp/stash/pull/2100))
* Maintain lightbox settings and add lightbox settings to Interface settings page. ([#2406](https://github.com/stashapp/stash/pull/2406)) * Maintain lightbox settings and add lightbox settings to Interface settings page. ([#2406](https://github.com/stashapp/stash/pull/2406))

View File

@@ -30,7 +30,6 @@ import { PerformerImagesPanel } from "./PerformerImagesPanel";
import { PerformerEditPanel } from "./PerformerEditPanel"; import { PerformerEditPanel } from "./PerformerEditPanel";
import { PerformerSubmitButton } from "./PerformerSubmitButton"; import { PerformerSubmitButton } from "./PerformerSubmitButton";
import GenderIcon from "../GenderIcon"; import GenderIcon from "../GenderIcon";
import renderNonZero from "src/utils/render";
interface IProps { interface IProps {
performer: GQL.PerformerDataFragment; performer: GQL.PerformerDataFragment;
@@ -185,70 +184,58 @@ const PerformerPage: React.FC<IProps> = ({ performer }) => {
<Tab eventKey="details" title={intl.formatMessage({ id: "details" })}> <Tab eventKey="details" title={intl.formatMessage({ id: "details" })}>
<PerformerDetailsPanel performer={performer} /> <PerformerDetailsPanel performer={performer} />
</Tab> </Tab>
{renderNonZero( <Tab
performer.scene_count, eventKey="scenes"
<Tab title={
eventKey="scenes" <React.Fragment>
title={ {intl.formatMessage({ id: "scenes" })}
<React.Fragment> <Badge className="left-spacing" pill variant="secondary">
{intl.formatMessage({ id: "scenes" })} {intl.formatNumber(performer.scene_count ?? 0)}
<Badge className="left-spacing" pill variant="secondary"> </Badge>
{intl.formatNumber(performer.scene_count ?? 0)} </React.Fragment>
</Badge> }
</React.Fragment> >
} <PerformerScenesPanel performer={performer} />
> </Tab>
<PerformerScenesPanel performer={performer} /> <Tab
</Tab> eventKey="galleries"
)} title={
{renderNonZero( <React.Fragment>
performer.gallery_count, {intl.formatMessage({ id: "galleries" })}
<Tab <Badge className="left-spacing" pill variant="secondary">
eventKey="galleries" {intl.formatNumber(performer.gallery_count ?? 0)}
title={ </Badge>
<React.Fragment> </React.Fragment>
{intl.formatMessage({ id: "galleries" })} }
<Badge className="left-spacing" pill variant="secondary"> >
{intl.formatNumber(performer.gallery_count ?? 0)} <PerformerGalleriesPanel performer={performer} />
</Badge> </Tab>
</React.Fragment> <Tab
} eventKey="images"
> title={
<PerformerGalleriesPanel performer={performer} /> <React.Fragment>
</Tab> {intl.formatMessage({ id: "images" })}
)} <Badge className="left-spacing" pill variant="secondary">
{renderNonZero( {intl.formatNumber(performer.image_count ?? 0)}
performer.image_count, </Badge>
<Tab </React.Fragment>
eventKey="images" }
title={ >
<React.Fragment> <PerformerImagesPanel performer={performer} />
{intl.formatMessage({ id: "images" })} </Tab>
<Badge className="left-spacing" pill variant="secondary"> <Tab
{intl.formatNumber(performer.image_count ?? 0)} eventKey="movies"
</Badge> title={
</React.Fragment> <React.Fragment>
} {intl.formatMessage({ id: "movies" })}
> <Badge className="left-spacing" pill variant="secondary">
<PerformerImagesPanel performer={performer} /> {intl.formatNumber(performer.movie_count ?? 0)}
</Tab> </Badge>
)} </React.Fragment>
{renderNonZero( }
performer.movie_count, >
<Tab <PerformerMoviesPanel performer={performer} />
eventKey="movies" </Tab>
title={
<React.Fragment>
{intl.formatMessage({ id: "movies" })}
<Badge className="left-spacing" pill variant="secondary">
{intl.formatNumber(performer.movie_count ?? 0)}
</Badge>
</React.Fragment>
}
>
<PerformerMoviesPanel performer={performer} />
</Tab>
)}
</Tabs> </Tabs>
</React.Fragment> </React.Fragment>
); );

View File

@@ -28,7 +28,6 @@ import { StudioPerformersPanel } from "./StudioPerformersPanel";
import { StudioEditPanel } from "./StudioEditPanel"; import { StudioEditPanel } from "./StudioEditPanel";
import { StudioDetailsPanel } from "./StudioDetailsPanel"; import { StudioDetailsPanel } from "./StudioDetailsPanel";
import { StudioMoviesPanel } from "./StudioMoviesPanel"; import { StudioMoviesPanel } from "./StudioMoviesPanel";
import renderNonZero from "src/utils/render";
interface IProps { interface IProps {
studio: GQL.StudioDataFragment; studio: GQL.StudioDataFragment;
@@ -154,15 +153,6 @@ const StudioPage: React.FC<IProps> = ({ studio }) => {
} }
} }
const defaultTab =
studio?.scene_count ?? 0 > 0
? "scenes"
: studio?.gallery_count ?? 0 > 0
? "galleries"
: studio?.image_count ?? 0 > 0
? "images"
: "performers";
const activeTabKey = const activeTabKey =
tab === "childstudios" || tab === "childstudios" ||
tab === "images" || tab === "images" ||
@@ -170,7 +160,7 @@ const StudioPage: React.FC<IProps> = ({ studio }) => {
tab === "performers" || tab === "performers" ||
tab === "movies" tab === "movies"
? tab ? tab
: defaultTab; : "scenes";
const setActiveTabKey = (newTab: string | null) => { const setActiveTabKey = (newTab: string | null) => {
if (tab !== newTab) { if (tab !== newTab) {
const tabParam = newTab === "scenes" ? "" : `/${newTab}`; const tabParam = newTab === "scenes" ? "" : `/${newTab}`;
@@ -226,92 +216,77 @@ const StudioPage: React.FC<IProps> = ({ studio }) => {
activeKey={activeTabKey} activeKey={activeTabKey}
onSelect={setActiveTabKey} onSelect={setActiveTabKey}
> >
{renderNonZero( <Tab
studio.scene_count, eventKey="scenes"
<Tab title={
eventKey="scenes" <React.Fragment>
title={ {intl.formatMessage({ id: "scenes" })}
<React.Fragment> <Badge className="left-spacing" pill variant="secondary">
{intl.formatMessage({ id: "scenes" })} {intl.formatNumber(studio.scene_count ?? 0)}
<Badge className="left-spacing" pill variant="secondary"> </Badge>
{intl.formatNumber(studio.scene_count ?? 0)} </React.Fragment>
</Badge> }
</React.Fragment> >
} <StudioScenesPanel studio={studio} />
> </Tab>
<StudioScenesPanel studio={studio} /> <Tab
</Tab> eventKey="galleries"
)} title={
{renderNonZero( <React.Fragment>
studio.gallery_count, {intl.formatMessage({ id: "galleries" })}
<Tab <Badge className="left-spacing" pill variant="secondary">
eventKey="galleries" {intl.formatNumber(studio.gallery_count ?? 0)}
title={ </Badge>
<React.Fragment> </React.Fragment>
{intl.formatMessage({ id: "galleries" })} }
<Badge className="left-spacing" pill variant="secondary"> >
{intl.formatNumber(studio.gallery_count ?? 0)} <StudioGalleriesPanel studio={studio} />
</Badge> </Tab>
</React.Fragment> <Tab
} eventKey="images"
> title={
<StudioGalleriesPanel studio={studio} /> <React.Fragment>
</Tab> {intl.formatMessage({ id: "images" })}
)} <Badge className="left-spacing" pill variant="secondary">
{renderNonZero( {intl.formatNumber(studio.image_count ?? 0)}
studio.image_count, </Badge>
<Tab </React.Fragment>
eventKey="images" }
title={ >
<React.Fragment> <StudioImagesPanel studio={studio} />
{intl.formatMessage({ id: "images" })} </Tab>
<Badge className="left-spacing" pill variant="secondary">
{intl.formatNumber(studio.image_count ?? 0)}
</Badge>
</React.Fragment>
}
>
<StudioImagesPanel studio={studio} />
</Tab>
)}
<Tab <Tab
eventKey="performers" eventKey="performers"
title={intl.formatMessage({ id: "performers" })} title={intl.formatMessage({ id: "performers" })}
> >
<StudioPerformersPanel studio={studio} /> <StudioPerformersPanel studio={studio} />
</Tab> </Tab>
{renderNonZero( <Tab
studio.movie_count, eventKey="movies"
<Tab title={
eventKey="movies" <React.Fragment>
title={ {intl.formatMessage({ id: "movies" })}
<React.Fragment> <Badge className="left-spacing" pill variant="secondary">
{intl.formatMessage({ id: "movies" })} {intl.formatNumber(studio.movie_count ?? 0)}
<Badge className="left-spacing" pill variant="secondary"> </Badge>
{intl.formatNumber(studio.movie_count ?? 0)} </React.Fragment>
</Badge> }
</React.Fragment> >
} <StudioMoviesPanel studio={studio} />
> </Tab>
<StudioMoviesPanel studio={studio} /> <Tab
</Tab> eventKey="childstudios"
)} title={
{renderNonZero( <React.Fragment>
studio.child_studios?.length, {intl.formatMessage({ id: "subsidiary_studios" })}
<Tab <Badge className="left-spacing" pill variant="secondary">
eventKey="childstudios" {intl.formatNumber(studio.child_studios?.length)}
title={ </Badge>
<React.Fragment> </React.Fragment>
{intl.formatMessage({ id: "subsidiary_studios" })} }
<Badge className="left-spacing" pill variant="secondary"> >
{intl.formatNumber(studio.child_studios?.length)} <StudioChildrenPanel studio={studio} />
</Badge> </Tab>
</React.Fragment>
}
>
<StudioChildrenPanel studio={studio} />
</Tab>
)}
</Tabs> </Tabs>
</div> </div>
{renderDeleteAlert()} {renderDeleteAlert()}

View File

@@ -30,7 +30,6 @@ import { TagGalleriesPanel } from "./TagGalleriesPanel";
import { TagDetailsPanel } from "./TagDetailsPanel"; import { TagDetailsPanel } from "./TagDetailsPanel";
import { TagEditPanel } from "./TagEditPanel"; import { TagEditPanel } from "./TagEditPanel";
import { TagMergeModal } from "./TagMergeDialog"; import { TagMergeModal } from "./TagMergeDialog";
import renderNonZero from "src/utils/render";
interface IProps { interface IProps {
tag: GQL.TagDataFragment; tag: GQL.TagDataFragment;
@@ -57,24 +56,13 @@ const TagPage: React.FC<IProps> = ({ tag }) => {
const [updateTag] = useTagUpdate(); const [updateTag] = useTagUpdate();
const [deleteTag] = useTagDestroy({ id: tag.id }); const [deleteTag] = useTagDestroy({ id: tag.id });
const defaultTab =
tag?.scene_count ?? 0 > 0
? "scenes"
: tag?.image_count ?? 0 > 0
? "images"
: tag?.gallery_count ?? 0 > 0
? "galleries"
: tag?.scene_marker_count ?? 0 > 0
? "markers"
: "performers";
const activeTabKey = const activeTabKey =
tab === "markers" || tab === "markers" ||
tab === "images" || tab === "images" ||
tab === "performers" || tab === "performers" ||
tab === "galleries" tab === "galleries"
? tab ? tab
: defaultTab; : "scenes";
const setActiveTabKey = (newTab: string | null) => { const setActiveTabKey = (newTab: string | null) => {
if (tab !== newTab) { if (tab !== newTab) {
const tabParam = newTab === "scenes" ? "" : `/${newTab}`; const tabParam = newTab === "scenes" ? "" : `/${newTab}`;
@@ -310,86 +298,71 @@ const TagPage: React.FC<IProps> = ({ tag }) => {
activeKey={activeTabKey} activeKey={activeTabKey}
onSelect={setActiveTabKey} onSelect={setActiveTabKey}
> >
{renderNonZero( <Tab
tag.scene_count, eventKey="scenes"
<Tab title={
eventKey="scenes" <React.Fragment>
title={ {intl.formatMessage({ id: "scenes" })}
<React.Fragment> <Badge className="left-spacing" pill variant="secondary">
{intl.formatMessage({ id: "scenes" })} {intl.formatNumber(tag.scene_count ?? 0)}
<Badge className="left-spacing" pill variant="secondary"> </Badge>
{intl.formatNumber(tag.scene_count ?? 0)} </React.Fragment>
</Badge> }
</React.Fragment> >
} <TagScenesPanel tag={tag} />
> </Tab>
<TagScenesPanel tag={tag} /> <Tab
</Tab> eventKey="images"
)} title={
{renderNonZero( <React.Fragment>
tag.image_count, {intl.formatMessage({ id: "images" })}
<Tab <Badge className="left-spacing" pill variant="secondary">
eventKey="images" {intl.formatNumber(tag.image_count ?? 0)}
title={ </Badge>
<React.Fragment> </React.Fragment>
{intl.formatMessage({ id: "images" })} }
<Badge className="left-spacing" pill variant="secondary"> >
{intl.formatNumber(tag.image_count ?? 0)} <TagImagesPanel tag={tag} />
</Badge> </Tab>
</React.Fragment> <Tab
} eventKey="galleries"
> title={
<TagImagesPanel tag={tag} /> <React.Fragment>
</Tab> {intl.formatMessage({ id: "galleries" })}
)} <Badge className="left-spacing" pill variant="secondary">
{renderNonZero( {intl.formatNumber(tag.gallery_count ?? 0)}
tag.gallery_count, </Badge>
<Tab </React.Fragment>
eventKey="galleries" }
title={ >
<React.Fragment> <TagGalleriesPanel tag={tag} />
{intl.formatMessage({ id: "galleries" })} </Tab>
<Badge className="left-spacing" pill variant="secondary"> <Tab
{intl.formatNumber(tag.gallery_count ?? 0)} eventKey="markers"
</Badge> title={
</React.Fragment> <React.Fragment>
} {intl.formatMessage({ id: "markers" })}
> <Badge className="left-spacing" pill variant="secondary">
<TagGalleriesPanel tag={tag} /> {intl.formatNumber(tag.scene_marker_count ?? 0)}
</Tab> </Badge>
)} </React.Fragment>
{renderNonZero( }
tag.scene_marker_count, >
<Tab <TagMarkersPanel tag={tag} />
eventKey="markers" </Tab>
title={ <Tab
<React.Fragment> eventKey="performers"
{intl.formatMessage({ id: "markers" })} title={
<Badge className="left-spacing" pill variant="secondary"> <React.Fragment>
{intl.formatNumber(tag.scene_marker_count ?? 0)} {intl.formatMessage({ id: "performers" })}
</Badge> <Badge className="left-spacing" pill variant="secondary">
</React.Fragment> {intl.formatNumber(tag.performer_count ?? 0)}
} </Badge>
> </React.Fragment>
<TagMarkersPanel tag={tag} /> }
</Tab> >
)} <TagPerformersPanel tag={tag} />
{renderNonZero( </Tab>
tag.performer_count,
<Tab
eventKey="performers"
title={
<React.Fragment>
{intl.formatMessage({ id: "performers" })}
<Badge className="left-spacing" pill variant="secondary">
{intl.formatNumber(tag.performer_count ?? 0)}
</Badge>
</React.Fragment>
}
>
<TagPerformersPanel tag={tag} />
</Tab>
)}
</Tabs> </Tabs>
</div> </div>
{renderDeleteAlert()} {renderDeleteAlert()}

View File

@@ -1,9 +0,0 @@
function renderNonZero(count: number | undefined | null, element: JSX.Element) {
if (!count) {
return undefined;
}
return element;
}
export default renderNonZero;