-
-
Notifications
You must be signed in to change notification settings - Fork 352
feat: migrate views/components/ship to TypeScript #2642
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
Open
chiba-bot
wants to merge
9
commits into
master
Choose a base branch
from
feat/ship-ts-migration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
85ef3db
feat: migrate views/components/ship to TypeScript
chiba-bot a2ebb02
fix: address Copilot review comments from PR #2642
chiba-bot 1928a44
fix: resolve ESLint errors
chiba-bot 020cf58
fix: remove unreachable code in ExtraDebugger.getLogFunc
chiba-bot 4283334
chore: remove unrelated debug.ts changes from this PR
chiba-bot 373998c
fix: address Copilot review feedback
chiba-bot 9a3ed14
fix: address Kimi review findings - null safety and bounds checks
chiba-bot 8063a5f
fix: address Copilot review - unused vars and optional chaining
chiba-bot 424595c
refactor: remove unused shipId from component props types
chiba-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import { Tag, Intent, Position, Tooltip } from '@blueprintjs/core' | ||
| import { compact, isFinite, memoize } from 'lodash' | ||
| import React from 'react' | ||
| import { useTranslation } from 'react-i18next' | ||
| import { connect } from 'react-redux' | ||
| import { createSelector } from 'reselect' | ||
| import { ShipLabel } from 'views/components/ship-parts/styled-components' | ||
| import { getShipAAPB } from 'views/utils/aapb' | ||
| import { shipDataSelectorFactory, shipEquipDataSelectorFactory } from 'views/utils/selectors' | ||
|
|
||
| interface ShipInfo { | ||
| [key: string]: unknown | ||
| } | ||
|
|
||
| interface EquipInfo { | ||
| [key: string]: unknown | ||
| } | ||
|
|
||
| interface AAPBSelectorProps { | ||
| shipId: number | ||
| } | ||
|
|
||
| interface AAPBStateProps { | ||
| AAPB: number | ||
| } | ||
|
|
||
| interface AAPBIndicatorProps extends AAPBSelectorProps, AAPBStateProps {} | ||
|
|
||
| const AAPBSelectorFactory = memoize((shipId: number) => | ||
| createSelector( | ||
| [shipDataSelectorFactory(shipId), shipEquipDataSelectorFactory(shipId)], | ||
| (shipInfo: [ShipInfo, ShipInfo] | undefined, equipsInfo: (EquipInfo[] | undefined)[]) => { | ||
| if (!shipInfo || !equipsInfo) return 0 | ||
| /* | ||
| equipment position is irrelevant with regard to AAPB trigger rate, | ||
| so we might as well remove all `undefined` for getShipAAPB to | ||
| have a uniform structure to work with. | ||
| */ | ||
| return getShipAAPB(shipInfo, compact(equipsInfo)) | ||
| }, | ||
| ), | ||
| ) | ||
|
|
||
| const AAPBIndicatorComponent: React.FC<AAPBIndicatorProps> = ({ AAPB }) => { | ||
| const { t } = useTranslation(['main']) | ||
|
|
||
| if (!isFinite(AAPB) || AAPB <= 0) { | ||
| return null | ||
| } | ||
|
|
||
| return ( | ||
| <ShipLabel className="ship-skill-indicator ship-aapb" isTag> | ||
| <Tooltip position={Position.TOP} content={<span>{`${AAPB.toFixed(2)}%`}</span>}> | ||
| <Tag minimal intent={Intent.WARNING}> | ||
| {t('main:AAPB')} | ||
| </Tag> | ||
| </Tooltip> | ||
| </ShipLabel> | ||
| ) | ||
| } | ||
|
|
||
| const mapStateToProps = (state: unknown, ownProps: AAPBSelectorProps): AAPBStateProps => ({ | ||
| AAPB: AAPBSelectorFactory(ownProps.shipId)(state) || 0, | ||
| }) | ||
|
|
||
| export const AAPBIndicator = connect(mapStateToProps)(AAPBIndicatorComponent) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.