UI updates

This commit is contained in:
oitsjustjose 2023-04-22 13:34:02 -05:00
commit a97e72abd7
9 changed files with 183 additions and 101 deletions

View file

@ -8,6 +8,7 @@
"react": "18.2.0",
"react-bootstrap": "^2.7.4",
"react-dom": "18.2.0",
"react-icons": "^4.8.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.0"
},

BIN
frontend/public/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

View file

@ -3,13 +3,13 @@
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/app-icon.png" />
<link rel="icon" href="%PUBLIC_URL%/favicon.png" />
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<meta name="theme-color" content="#17a2b8" />
<link rel="shortcut icon" href="./app-icon.png" type="image/x-icon" />
<link rel="shortcut icon" href="./favicon.png" type="image/x-icon" />
<meta name="description" content="A Migration Tool to Pull CF Files and Move Them to Modrinth!" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/app-icon.png" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/favicon.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>CTMMM</title>
</head>

View file

@ -7,3 +7,33 @@
.output-log {
margin-top: 2rem;
}
button.info {
/* position: absolute;
bottom: 0.5rem;
right: 0.5rem; */
position: relative;
right: -100%;
font-size: 24px;
aspect-ratio: 1;
border-radius: 100%;
padding: 0.5rem !important;
}
button.info svg {
vertical-align: top;
}
.ctm-root {
margin: auto;
max-width: 768px;
}
#root {
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

View file

@ -0,0 +1,41 @@
import React from 'react';
import { Modal } from 'react-bootstrap';
export default ({ show, onHide }) => (
<Modal
centered
show={show}
onHide={onHide}
>
<Modal.Body>
<div>
<p>
This is the splitter between parts of the filename. Many mods use the format
{' '}
<code>MODNAME-MCVER-MAJOR.MINOR.PATCH</code>
, where
{' '}
<code>-</code>
{' '}
is the delimiter.
</p>
<p>
Using this logic, it is assumed that the Minecraft version for this
{' '}
<code>.jar</code>
-file is between the first and second delimiter, and that the mod version is between
the second and the end of the file. Formatting aside from this is not supported,
unfortunately, as I&apos;ve got a bit of trauma
{' '}
<sup>(/s)</sup>
{' '}
from
{' '}
<a href="https://dv2ls.com/code?id=lUY-c4A2H" target="_blank" rel="noreferrer">
this Regular Expression I wrote.
</a>
</p>
</div>
</Modal.Body>
</Modal>
);

View file

@ -0,0 +1,75 @@
import React, { useState } from 'react';
import { Modal } from 'react-bootstrap';
export default ({ override, propagateOnHide }) => {
const [show, setShow] = useState(!window.localStorage.getItem('info-dismissed'));
const onHide = () => {
window.localStorage.setItem('info-dismissed', true);
setShow(false);
propagateOnHide();
};
return (
<Modal
centered
size="lg"
show={override || show}
onHide={onHide}
>
<Modal.Header closeButton>
<Modal.Title>CurseForge to Modrinth Mod Migrator (CTMMM)</Modal.Title>
</Modal.Header>
<Modal.Body>
<p>
<b>Welcome!</b>
{' '}
In order to use this tool you&apos;ll need to have already created (if it&apos;s
still &quot;Under Review&quot;, that&apos;s ok) your Modrinth Page, and a few
other things:
<ul>
<li>
A
{' '}
<a href="https://docs.github.com/en/enterprise-server@3.4/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token" target="_blank" rel="noreferrer">
GitHub Personal Access Token
</a>
{' '}
for the Account you used to log into Modrinth. No
permissions need to be granted to the PAT, this token will be encrypted from end
to end (even in storage), and it will only be used for requests to Modrinth
(feel encouraged to browse this source code to verify).
</li>
<li>
The CurseForge Slug for your Mod. This can be found in the General Settings for your
project page
</li>
<li>
The Modrinth Project ID. This can be found in the side panel of your Modrinth project
</li>
</ul>
This tool works on a queue-based system since I cannot afford enough computing for
everyone, so you&apos;ll be able to see your status and place in the queue down
below in the &quot;Status &amp; Output Log&quot;. You will not lose your place in
the queue if you close this tab or leave this page, as long as you do not clear
browser storage you will still be able to track progress here, or of course on
your Modrinth project page!
</p>
<p>
I want to make this process go faster, so if you liked it and want to support it you can:
<ul>
<li>
Support me
{' '}
<a href="https://dv2ls.com/don8" target="_blank" rel="noreferrer">with a Donation</a>
</li>
<li>Share this tool!</li>
</ul>
</p>
</Modal.Body>
</Modal>
);
};

View file

@ -1,52 +0,0 @@
import React, { useState } from 'react';
export default () => {
const [render, setRender] = useState(true);
const hide = () => {
window.localStorage.setItem('info-dismissed', true);
setRender(false);
};
return render && (
<div>
<p>
<b>Welcome!</b>
{' '}
In order to use this tool you&apos;ll need to have already created (if it&apos;s
still &quot;Under Review&quot;, that&apos;s ok) your Modrinth Page, and a few other things:
<ul>
<li>
A
{' '}
<a href="https://docs.github.com/en/enterprise-server@3.4/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token" target="_blank" rel="noreferrer">
GitHub Personal Access Token
</a>
{' '}
for the Account you used to log into Modrinth. No
permissions need to be granted to the PAT, this token will be encrypted from end
to end (even in storage), and it will only be used for requests to Modrinth
(feel encouraged to browse this source code to verify).
</li>
<li>
The CurseForge Slug for your Mod. This can be found in the General Settings for your
project page
</li>
<li>
The Modrinth Project ID. This can be found in the side panel of your Modrinth project
</li>
</ul>
This tool works on a queue-based system since I cannot afford enough computing for everyone,
so you&apos;ll be able to see your status and place in the queue down below in the
&quot;Status &amp; Output Log&quot;. You will not lose your place in the queue if you close
this tab or leave this page, as long as you do not clear browser storage you will still be
able to track progress here, or of course on your Modrinth project page!
</p>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a style={{ float: 'right', marginTop: '-2rem' }} href="#" role="button" onClick={hide}><sup>[Hide]</sup></a>
</div>
);
};

BIN
frontend/src/img/ctm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View file

@ -1,12 +1,16 @@
/* eslint-disable import/no-extraneous-dependencies */
import React, { useState } from 'react';
import {
Form, Button, Container, Accordion, Modal,
Form, Button, Container, Accordion, Image,
} from 'react-bootstrap';
import { TbInfoHexagon, TbHelp } from 'react-icons/tb';
import OutputLog from '../components/OutputLog';
import Info from '../components/Info';
import Info from '../components/Help/Info';
import Delimiter from '../components/Help/Delimiter';
import HeaderImg from '../img/ctm.png';
export default () => {
const [help, setHelp] = useState(null);
const [modals, setModals] = useState({ info: false, delim: false });
const [jobId, setJobId] = useState(window.localStorage.getItem('last-jobid'));
const [formData, setFormData] = useState({
githubPat: '',
@ -16,39 +20,6 @@ export default () => {
// eslint-disable-next-line max-len
const isValidState = () => !!formData.githubPat.length && !!formData.slug.length && !!formData.projId.length;
const delimHelp = (evt) => {
evt.preventDefault();
setHelp((
<div>
<p>
This is the splitter between parts of the filename. Geolosys uses format
{' '}
<code>MODNAME-MCVER-MAJOR.MINOR.PATCH</code>
, where
{' '}
<code>-</code>
{' '}
is the delimiter.
</p>
<p>
Using this logic, it is assumed that the Minecraft version for this
{' '}
<code>.jar</code>
-file is between the first and second delimiter, and that the mod version is between
the second and the end of the file. Formatting aside from this is not supported,
unfortunately, as I&apos;ve got a bit of trauma
{' '}
<sup>(/s)</sup>
{' '}
from
{' '}
<a href="https://dv2ls.com/code?id=lUY-c4A2H" target="_blank" rel="noreferrer">
this Regular Expression I wrote.
</a>
</p>
</div>
));
};
const makeJob = async (evt) => {
evt.preventDefault();
@ -68,14 +39,12 @@ export default () => {
};
return (
<div style={{ margin: 'auto', maxWidth: '768px' }}>
<h2 className="mb-4 text-center">
CurseForge to Modrinth Mod Migrator (CTMMM)
</h2>
{!window.localStorage.getItem('info-dismissed') && (<Info />)}
<div className="ctm-root">
<Info override={modals.info} propagateOnHide={() => setModals({ ...modals, info: false })} />
<Delimiter show={modals.delim} onHide={() => setModals({ ...modals, delim: false })} />
<Container style={{ margin: '1rem auto', maxWidth: '512px' }}>
<Image className="d-block mb-3 mx-auto w-50 " src={HeaderImg} />
<Form onSubmit={makeJob} className="juse-form">
<Form.Group className="mb-3" controlId="githubPat">
<Form.Label>GitHub Personal Access Token</Form.Label>
@ -127,7 +96,14 @@ export default () => {
Delimiter (Optional)
{' '}
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a onClick={delimHelp} style={{ textDecoration: 'none' }} href="#">❔</a>
<a
onClick={() => setModals({ ...modals, delim: true })}
style={{ textDecoration: 'none', fontSize: '16px' }}
href="#"
label="delimiter_help"
>
<TbHelp />
</a>
</Form.Label>
<Form.Control
placeholder="Defaults to Hyphen (-)"
@ -141,7 +117,7 @@ export default () => {
</Form.Group>
<Button
variant="success"
variant="dark"
type="submit"
disabled={!isValidState()}
>
@ -165,9 +141,20 @@ export default () => {
)}
</Container>
<Modal centered show={!!help} onHide={() => setHelp(null)}>
<Button
onClick={() => setModals({ ...modals, info: true })}
className="info"
variant="dark"
>
<TbInfoHexagon ce />
</Button>
{/* <Modal centered show={!!help} onHide={() => setHelp(null)}>
<Modal.Header closeButton>
<Modal.Title>Help</Modal.Title>
</Modal.Header>
<Modal.Body>{help}</Modal.Body>
</Modal>
</Modal> */}
</div>
);
};