Skip to content

Commit

Permalink
Do not display tabs with no content (stashapp#2468)
Browse files Browse the repository at this point in the history
  • Loading branch information
WithoutPants authored Apr 2, 2022
1 parent f9cf77e commit 0ee8930
Show file tree
Hide file tree
Showing 5 changed files with 259 additions and 184 deletions.
1 change: 1 addition & 0 deletions ui/v2.5/src/components/Changelog/versions/v0140.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Add python location in System Settings for script scrapers and plugins. ([#2409](https://github.com/stashapp/stash/pull/2409))

### 🎨 Improvements
* 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))
* 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))
Expand Down
117 changes: 65 additions & 52 deletions ui/v2.5/src/components/Performers/PerformerDetails/Performer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { PerformerImagesPanel } from "./PerformerImagesPanel";
import { PerformerEditPanel } from "./PerformerEditPanel";
import { PerformerSubmitButton } from "./PerformerSubmitButton";
import GenderIcon from "../GenderIcon";
import renderNonZero from "src/utils/render";

interface IProps {
performer: GQL.PerformerDataFragment;
Expand Down Expand Up @@ -184,58 +185,70 @@ const PerformerPage: React.FC<IProps> = ({ performer }) => {
<Tab eventKey="details" title={intl.formatMessage({ id: "details" })}>
<PerformerDetailsPanel performer={performer} />
</Tab>
<Tab
eventKey="scenes"
title={
<React.Fragment>
{intl.formatMessage({ id: "scenes" })}
<Badge className="left-spacing" pill variant="secondary">
{intl.formatNumber(performer.scene_count ?? 0)}
</Badge>
</React.Fragment>
}
>
<PerformerScenesPanel performer={performer} />
</Tab>
<Tab
eventKey="galleries"
title={
<React.Fragment>
{intl.formatMessage({ id: "galleries" })}
<Badge className="left-spacing" pill variant="secondary">
{intl.formatNumber(performer.gallery_count ?? 0)}
</Badge>
</React.Fragment>
}
>
<PerformerGalleriesPanel performer={performer} />
</Tab>
<Tab
eventKey="images"
title={
<React.Fragment>
{intl.formatMessage({ id: "images" })}
<Badge className="left-spacing" pill variant="secondary">
{intl.formatNumber(performer.image_count ?? 0)}
</Badge>
</React.Fragment>
}
>
<PerformerImagesPanel performer={performer} />
</Tab>
<Tab
eventKey="movies"
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>
{renderNonZero(
performer.scene_count,
<Tab
eventKey="scenes"
title={
<React.Fragment>
{intl.formatMessage({ id: "scenes" })}
<Badge className="left-spacing" pill variant="secondary">
{intl.formatNumber(performer.scene_count ?? 0)}
</Badge>
</React.Fragment>
}
>
<PerformerScenesPanel performer={performer} />
</Tab>
)}
{renderNonZero(
performer.gallery_count,
<Tab
eventKey="galleries"
title={
<React.Fragment>
{intl.formatMessage({ id: "galleries" })}
<Badge className="left-spacing" pill variant="secondary">
{intl.formatNumber(performer.gallery_count ?? 0)}
</Badge>
</React.Fragment>
}
>
<PerformerGalleriesPanel performer={performer} />
</Tab>
)}
{renderNonZero(
performer.image_count,
<Tab
eventKey="images"
title={
<React.Fragment>
{intl.formatMessage({ id: "images" })}
<Badge className="left-spacing" pill variant="secondary">
{intl.formatNumber(performer.image_count ?? 0)}
</Badge>
</React.Fragment>
}
>
<PerformerImagesPanel performer={performer} />
</Tab>
)}
{renderNonZero(
performer.movie_count,
<Tab
eventKey="movies"
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>
</React.Fragment>
);
Expand Down
157 changes: 91 additions & 66 deletions ui/v2.5/src/components/Studios/StudioDetails/Studio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { StudioPerformersPanel } from "./StudioPerformersPanel";
import { StudioEditPanel } from "./StudioEditPanel";
import { StudioDetailsPanel } from "./StudioDetailsPanel";
import { StudioMoviesPanel } from "./StudioMoviesPanel";
import renderNonZero from "src/utils/render";

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

0 comments on commit 0ee8930

Please sign in to comment.