From 99929513cafc78827d5bcc896a6f325f869a510e Mon Sep 17 00:00:00 2001 From: Vetyst Date: Thu, 3 Oct 2024 22:56:36 +0100 Subject: [PATCH 1/3] feature(TTW-7104): Individual character Log Header (#7105) * feature(TTW-7104): Individual character Log Header * handle hidden response type in wcl parses --------- Co-authored-by: emallson --- src/CHANGELOG.tsx | 1 + src/common/WCL_TYPES.ts | 6 ++- src/game/CLASSES.ts | 16 +++++++ src/interface/CharacterParses.tsx | 44 +++++++++++++++----- src/interface/GuildReports.tsx | 11 +++-- src/interface/report/Results/Header.scss | 2 + src/interface/report/Results/PlayerInfo.scss | 4 +- src/interface/report/Results/PlayerInfo.tsx | 30 +++++++++---- 8 files changed, 89 insertions(+), 25 deletions(-) diff --git a/src/CHANGELOG.tsx b/src/CHANGELOG.tsx index 2abeb776d65..6ddd32a5774 100644 --- a/src/CHANGELOG.tsx +++ b/src/CHANGELOG.tsx @@ -38,6 +38,7 @@ import SpellLink from 'interface/SpellLink'; // prettier-ignore export default [ + change(date(2024, 10, 3), 'Fixed rendering of the Header on the character log browser.', Vetyst), change(date(2024, 9, 30), 'Add Classic Cata Firelands raid zone, headshots, and placeholder image', jazminite), change(date(2024, 9, 30), 'Enchant checker now detects Spellthreads', Sref), change(date(2024, 9, 26), "Add support for Warlock Hero Talents", Gazh), diff --git a/src/common/WCL_TYPES.ts b/src/common/WCL_TYPES.ts index 295db2eecbf..7e11823e231 100644 --- a/src/common/WCL_TYPES.ts +++ b/src/common/WCL_TYPES.ts @@ -188,7 +188,11 @@ export interface WCLParse { estimated: boolean; } -export type WCLParsesResponse = WCLParse[]; +export type WCLParsesResponse = WCLParse[] | { hidden: true }; + +export function isHiddenParsesResponse(data: WCLParsesResponse): data is { hidden: true } { + return !Array.isArray(data); +} export type WCLResponseJSON = | WCLGuildReportsResponse diff --git a/src/game/CLASSES.ts b/src/game/CLASSES.ts index 516b51e0b4a..5d726c97530 100644 --- a/src/game/CLASSES.ts +++ b/src/game/CLASSES.ts @@ -30,6 +30,22 @@ export enum CLASSES { WARRIOR, } +export const CLASS_NAMES: { [classId: number]: { name: string } } = { + 1: { name: 'Warrior' }, + 2: { name: 'Paladin' }, + 3: { name: 'Hunter' }, + 4: { name: 'Rogue' }, + 5: { name: 'Priest' }, + 6: { name: 'Death Knight' }, + 7: { name: 'Shaman' }, + 8: { name: 'Mage' }, + 9: { name: 'Warlock' }, + 10: { name: 'Monk' }, + 11: { name: 'Druid' }, + 12: { name: 'Demon Hunter' }, + 13: { name: 'Evoker' }, +}; + export function getClassBySpecId(specId: number) { if (DEATH_KNIGHT_SPECS.find((spec) => spec.id === specId)) { return CLASSES.DEATH_KNIGHT; diff --git a/src/interface/CharacterParses.tsx b/src/interface/CharacterParses.tsx index beadc474fcc..c382f909402 100644 --- a/src/interface/CharacterParses.tsx +++ b/src/interface/CharacterParses.tsx @@ -19,12 +19,18 @@ import REPORT_HISTORY_TYPES from 'interface/REPORT_HISTORY_TYPES'; import { Component } from 'react'; import { connect } from 'react-redux'; import { Link } from 'react-router-dom'; -import { WCLParse, WCLParsesResponse } from 'common/WCL_TYPES'; +import { isHiddenParsesResponse, WCLParse, WCLParsesResponse } from 'common/WCL_TYPES'; import { isSupportedRegion } from 'common/regions'; +import './report/Results/Header.scss'; import './CharacterParses.scss'; import ParsesList, { Parse } from './CharacterParsesList'; import { appendReportHistory } from './reducers/reportHistory'; +import { CLASS_NAMES } from 'game/CLASSES'; +import { + classBackgroundImage, + characterBackgroundImage, +} from 'interface/report/Results/PlayerInfo'; const loadRealms = (classic: boolean) => retryingPromise(() => @@ -100,7 +106,8 @@ interface CharacterParsesState { activeEncounter: number; sortBy: number; metric: string; - image: string | null; + characterImage: string | null; + classImage: string | null; avatarImage: string | null; parses: Parse[]; isLoading: boolean; @@ -123,7 +130,8 @@ class CharacterParses extends Component { this.load(); @@ -281,7 +289,7 @@ class CharacterParses extends Component { this.load(); @@ -312,18 +320,19 @@ class CharacterParses extends Component { + if (isHiddenParsesResponse(rawParses)) { + // WCL responds with {hidden:true} when the logs are hidden. + this.setState({ + parses: [], + isLoading: false, + error: ERRORS.CHARACTER_HIDDEN, + }); + return; + } if (rawParses.length === 0) { this.setState({ parses: [], @@ -397,7 +415,6 @@ class CharacterParses extends Component