Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Convert modding profile component to typescript #10311

Merged
merged 19 commits into from
Jul 6, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
import ReviewEditorConfigJson from 'interfaces/review-editor-config-json';
import * as React from 'react';

export const ReviewEditorConfigContext = React.createContext({} as ReviewEditorConfigJson);
export const ReviewEditorConfigContext = React.createContext<ReviewEditorConfigJson>({ max_blocks: 0 });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this change doing here 🤔 although I guess it's simple enough so this can stay

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max_blocks isn't supposed to be undefined and this just makes the default 0 so pages that don't need editing can skip adding a provider without causing max_blocks to be undefined

2 changes: 1 addition & 1 deletion resources/js/components/lazy-load.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class LazyLoad extends React.Component<React.PropsWithChildren<Pr

// get the bounds and scroll position before update.
getSnapshotBeforeUpdate() {
return this.context?.getSnapshot(this.props.name);
return this.context?.getSnapshot(this.props.name) ?? null;
}

render() {
Expand Down
22 changes: 0 additions & 22 deletions resources/js/entrypoints/modding-profile.coffee

This file was deleted.

22 changes: 22 additions & 0 deletions resources/js/entrypoints/modding-profile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

import Main from 'modding-profile/main';
import core from 'osu-core-singleton';
import React from 'react';
import { parseJson } from 'utils/json';

core.reactTurbolinks.register('modding-profile', () => (
<Main
beatmaps={parseJson('json-beatmaps')}
beatmapsets={parseJson('json-beatmapsets')}
discussions={parseJson('json-discussions')}
events={parseJson('json-events')}
extras={parseJson('json-extras')}
perPage={parseJson('json-perPage')}
posts={parseJson('json-posts')}
user={parseJson('json-user')}
users={parseJson('json-users')}
votes={parseJson('json-votes')}
/>
));
10 changes: 10 additions & 0 deletions resources/js/interfaces/user-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ interface UserJsonDefaultAttributes {
username: string;
}

export type ProfileHeaderIncludes =
'active_tournament_banner'
| 'badges'
| 'comments_count'
| 'follower_count'
| 'groups'
| 'mapping_follower_count'
| 'previous_usernames'
| 'support_level';

type UserJson = UserJsonDefaultAttributes & Partial<UserJsonAvailableIncludes>;

export default UserJson;
Expand Down
17 changes: 17 additions & 0 deletions resources/js/interfaces/user-modding-profile-json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

import UserExtendedJson from './user-extended-json';
import { ProfileHeaderIncludes } from './user-json';

type ModdingProfileIncludes =
ProfileHeaderIncludes
| 'graveyard_beatmapset_count'
| 'loved_beatmapset_count'
| 'pending_beatmapset_count'
| 'ranked_beatmapset_count'
| 'statistics';

type UserModdingProfileJson = UserExtendedJson & Required<Pick<UserExtendedJson, ModdingProfileIncludes>>;

export default UserModdingProfileJson;
Loading