-
-
Notifications
You must be signed in to change notification settings - Fork 835
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: convert
AlertManager
IndexPage
and UserPage
component…
…s to TS (#3536) * chore: convert `AlertManager` component to TypeScript * chore: `compat.js` to `compat.ts` * chore: convert `IndexPage` component to TypeScript * chore: convert `UserPage` component and inheritors to TypeScript * chore: `yarn format` * chore: import types instead
- Loading branch information
Showing
11 changed files
with
137 additions
and
143 deletions.
There are no files selected for viewing
File renamed without changes.
1 change: 1 addition & 0 deletions
1
framework/core/js/src/common/compat.js → framework/core/js/src/common/compat.ts
This file contains 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 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,42 @@ | ||
import Component, { ComponentAttrs } from '../Component'; | ||
import AlertManagerState from '../states/AlertManagerState'; | ||
import type Mithril from 'mithril'; | ||
|
||
export interface IAlertManagerAttrs extends ComponentAttrs { | ||
state: AlertManagerState; | ||
} | ||
|
||
/** | ||
* The `AlertManager` component provides an area in which `Alert` components can | ||
* be shown and dismissed. | ||
*/ | ||
export default class AlertManager<CustomAttrs extends IAlertManagerAttrs = IAlertManagerAttrs> extends Component<CustomAttrs, AlertManagerState> { | ||
oninit(vnode: Mithril.Vnode<CustomAttrs, this>) { | ||
super.oninit(vnode); | ||
|
||
this.state = this.attrs.state; | ||
} | ||
|
||
view() { | ||
const activeAlerts = this.state.getActiveAlerts(); | ||
|
||
return ( | ||
<div class="AlertManager"> | ||
{Object.keys(activeAlerts) | ||
.map(Number) | ||
.map((key) => { | ||
const alert = activeAlerts[key]; | ||
const urgent = alert.attrs.type === 'error'; | ||
|
||
return ( | ||
<div class="AlertManager-alert" role="alert" aria-live={urgent ? 'assertive' : 'polite'}> | ||
<alert.componentClass {...alert.attrs} ondismiss={this.state.dismiss.bind(this.state, key)}> | ||
{alert.children} | ||
</alert.componentClass> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
} | ||
} |
This file contains 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 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
File renamed without changes.
10 changes: 6 additions & 4 deletions
10
...c/forum/components/DiscussionsUserPage.js → .../forum/components/DiscussionsUserPage.tsx
This file contains 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 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
Oops, something went wrong.