mue/src/components/modals/main/settings/sections/About.jsx

102 lines
4.0 KiB
React
Raw Normal View History

import React from 'react';
import Tooltip from '@material-ui/core/Tooltip';
2021-03-20 12:55:20 +00:00
const other_contributors = require('../../../../../modules/other_contributors.json');
2021-02-28 16:18:17 +00:00
export default class About extends React.PureComponent {
2021-03-23 13:10:34 +00:00
constructor() {
super();
this.state = {
contributors: [],
sponsors: [],
other_contributors: [],
photographers: [],
update: window.language.modals.main.settings.sections.about.version.checking_update,
loading: window.language.modals.main.loading
}
this.language = window.language.modals.main.settings.sections.about;
}
async getGitHubData() {
let contributors, sponsors, photographers, versionData;
try {
contributors = await (await fetch(window.constants.GITHUB_URL + '/repos/mue/mue/contributors')).json();
sponsors = (await (await fetch(window.constants.SPONSORS_URL + '/list')).json()).sponsors;
photographers = await (await fetch(window.constants.API_URL + '/getPhotographers')).json();
versionData = await (await fetch(window.constants.GITHUB_URL + '/repos/mue/mue/releases')).json();
} catch (e) {
return this.setState({
update: 'Failed to get update information',
loading: 'An error occurred'
});
}
const newVersion = versionData[0].tag_name;
2021-03-18 15:37:58 +00:00
let updateMsg = this.language.version.no_update;
if (Number(window.constants.VERSION) < newVersion) {
updateMsg = `${this.language.version.update_available}: ${newVersion}`;
}
this.setState({
contributors: contributors.filter((contributor) => !contributor.login.includes('bot')),
sponsors: sponsors,
update: updateMsg,
other_contributors: other_contributors,
photographers: photographers.sort().join(', '),
loading: null
});
}
componentDidMount() {
if (localStorage.getItem('offlineMode') === 'true') {
this.setState({
update: this.language.version.offline_mode
});
return;
}
this.getGitHubData();
}
render() {
return (
<>
<h2>{this.language.title}</h2>
<img draggable='false' style={{'height': '100px', 'width': 'auto'}} src='./././icons/logo_horizontal.png' alt='Mue logo'></img>
<p>{this.language.copyright} 2018-{new Date().getFullYear()} Mue Tab (BSD-3 License)</p>
<p>{this.language.version.title} {window.constants.VERSION} ({this.state.update})</p>
<h3>{this.language.resources_used.title}</h3>
<p>Pexels ({this.language.resources_used.bg_images})</p>
<p>Google ({this.language.resources_used.pin_icon})</p>
<p>Undraw ({this.language.resources_used.welcome_img})</p>
<h3>{this.language.contributors}</h3>
{this.state.loading}
{this.state.contributors.map((item) => (
<Tooltip title={item.login} placement='top' key={item.login}>
<a href={'https://github.com/' + item.login} target='_blank' rel='noopener noreferrer'><img draggable='false' className='abouticon' src={item.avatar_url + '&size=128'} alt={item.login}/></a>
</Tooltip>
))}
{ // for those who contributed without opening a pull request
this.state.other_contributors.map((item) => (
<Tooltip title={item.login} placement='top' key={item.login}>
<a href={'https://github.com/' + item.login} target='_blank' rel='noopener noreferrer'><img draggable='false' className='abouticon' src={item.avatar_url + '&size=128'} alt={item.login}/></a>
</Tooltip>
))}
<h3>{this.language.supporters}</h3>
{this.state.loading}
{this.state.sponsors.map((item) => (
<Tooltip title={item.handle} placement='top' key={item.handle}>
<a href={item.profile} target='_blank' rel='noopener noreferrer'><img draggable='false' className='abouticon' src={item.avatar + '&size=128'} alt={item.handle}></img></a>
</Tooltip>
))}
<h3>{this.language.photographers}</h3>
{this.state.loading}
<p>{this.state.photographers}</p>
</>
);
}
}