Skip to content
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
5 changes: 5 additions & 0 deletions functions/_middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ const STATIC_META = {
description: 'Your MistWarp credits and purchases.',
noindex: true
},
'/purchases': {
title: 'Purchases - MistWarp',
description: 'What you have bought on MistWarp.',
noindex: true
},
'/notifications': {
title: 'Notifications - MistWarp',
description: 'Your MistWarp notifications.',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"scratch-paint": "https://codeload.github.com/MistWarp/scratch-paint/tar.gz/52db8c8ede05ab2f925148ec1e783ea39b9dfca0",
"scratch-render": "https://codeload.github.com/MistWarp/scratch-render/tar.gz/ce8e30cb75fcba486d20a453bd51127f5a145a1a",
"scratch-render-fonts": "https://codeload.github.com/PenguinMod/penguinmod-render-fonts/tar.gz/4dda62c707f64505266aa62f7a6cc84f0e5812fd",
"scratch-vm": "https://codeload.github.com/MistWarp/scratch-vm/tar.gz/4e8113e2546ff406644f4099f99ef5a7e85aa4c5",
"scratch-vm": "https://codeload.github.com/MistWarp/scratch-vm/tar.gz/c775381a55c13029d15ae7fe87fdae24a6998cf9",
"scratchblocks": "3.7.1",
"sha.js": "^2.4.12",
"to-style": "1.3.3",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/community/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import tokenStyles from './styles/tokens.module.css';
import React, {Suspense, useEffect} from 'react';
import {lazyWithReload as lazy} from '../lib/lazy-with-retry.js';
import ErrorBoundary from '../containers/error-boundary.jsx';
import {Routes, Route, useLocation} from 'react-router-dom';
import {Navigate, Routes, Route, useLocation} from 'react-router-dom';
import {UserProvider} from './UserContext.jsx';
import setPageMeta from './page-meta.js';
import {initSiteErrorReporting} from '../lib/error-reporter.js';
Expand Down Expand Up @@ -32,7 +32,7 @@ const Followers = lazy(() => import('./pages/Followers.jsx'));
const Settings = lazy(() => import('./pages/Settings.jsx'));
const MyStuff = lazy(() => import('./pages/MyStuff.jsx'));
const ManageProject = lazy(() => import('./pages/ManageProject.jsx'));
const Wallet = lazy(() => import('./pages/Wallet.jsx'));
const Purchases = lazy(() => import('./pages/Purchases.jsx'));
const Notifications = lazy(() => import('./pages/Notifications.jsx'));
const Post = lazy(() => import('./pages/Post.jsx'));
const News = lazy(() => import('./pages/News.jsx'));
Expand Down Expand Up @@ -67,7 +67,7 @@ const ROUTE_TITLES = [
['/perks', 'Memberships'],
['/mystuff/project/', 'Manage project'],
['/mystuff', 'My Stuff'],
['/wallet', 'Wallet'],
['/purchases', 'Purchases'],
['/notifications', 'Notifications'],
['/posts/', 'Post'],
['/news', 'News'],
Expand Down Expand Up @@ -151,7 +151,8 @@ const App = () => {
<Route path="/settings" element={<Settings />} />
<Route path="/mystuff" element={<MyStuff />} />
<Route path="/mystuff/project/:id" element={<ManageProject />} />
<Route path="/wallet" element={<Wallet />} />
<Route path="/purchases" element={<Purchases />} />
<Route path="/wallet" element={<Navigate to="/purchases" replace />} />
<Route path="/notifications" element={<Notifications />} />
<Route path="/posts/:id" element={<Post />} />
<Route path="/news" element={<News />} />
Expand Down
25 changes: 8 additions & 17 deletions src/community/components/RoturConsentModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const groupScopes = scopes => {
// it can request an action but never approve one on the user's behalf.
const RoturConsentModal = ({type, data, onAllow, onBlock, onDeny, onShareThis, onShareAll, onShareNo}) => {
const {text: communityText} = useCommunityText();
const payment = type === 'confirm' && data.confirmation && data.confirmation.type === 'payment';
const projectName = data.name || communityText('This project');
if (type === 'share') {
return (
Expand Down Expand Up @@ -52,11 +51,7 @@ const RoturConsentModal = ({type, data, onAllow, onBlock, onDeny, onShareThis, o
}
const groups = groupScopes(data.scopes);
let confirmLead = null;
if (payment) {
confirmLead = communityText('Allow payment of {value1} credits to @{value2}?', {
value1: data.confirmation.amount, value2: data.confirmation.recipient
});
} else if (type === 'confirm') {
if (type === 'confirm') {
confirmLead = data.username ?
communityText('Allow this project to {value1} as @{value2}?', {value1: data.label, value2: data.username}) :
communityText('Allow this project to {value1}?', {value1: data.label});
Expand All @@ -65,7 +60,7 @@ const RoturConsentModal = ({type, data, onAllow, onBlock, onDeny, onShareThis, o
<Modal
icon={ShieldCheck}
title={type === 'confirm' ?
(payment ? communityText('Confirm payment') : communityText('Confirm account action')) :
communityText('Confirm account action') :
communityText('Connect to Rotur')}
onDismiss={onDeny}
actions={
Expand All @@ -78,23 +73,19 @@ const RoturConsentModal = ({type, data, onAllow, onBlock, onDeny, onShareThis, o
variant="primary"
onClick={onAllow}
>
{payment ?
communityText('Allow payment') :
(type === 'confirm' ? communityText('Allow once') : communityText('Connect'))}
{type === 'confirm' ? communityText('Allow once') : communityText('Connect')}
</Button>
</React.Fragment>
}
>
{type === 'confirm' ? (
<React.Fragment>
<p className={styles.lead}>{confirmLead}</p>
{payment ? null : (
<p className={styles.lead}>
{communityText(
'This action will happen once. It does not give the project ongoing approval.'
)}
</p>
)}
<p className={styles.lead}>
{communityText(
'This action will happen once. It does not give the project ongoing approval.'
)}
</p>
</React.Fragment>
) : (
<React.Fragment>
Expand Down
13 changes: 4 additions & 9 deletions src/community/credits.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ const randomIdempotencyKey = prefix => {
};

const commerceRequest = async (path, init = {}) => {
const scope = init.scope || ['credits:view'];
// Spending is asked for when someone pays, from their click.
// Every call says which permission it needs. Spending is asked for when
// someone pays, from their click.
const {scope} = init;
await ensureScopes(scope, {prompt: scope.some(name => !name.endsWith(':view'))});
const next = {...init};
delete next.scope;
Expand All @@ -76,15 +77,10 @@ const sendCommercePayment = ({to, amount, source = 'mistwarp', kind, resourceTyp
})
});

const getCommerceEarnings = async () => {
await ensureScopes(['credits:view']);
return billingRequest('/me/earnings');
};

const listCommerceBounties = async (filters = {}) => {
const query = new URLSearchParams(filters);
const path = `/bounties?${query.toString()}`;
if (await getAccessToken()) return commerceRequest(path);
// Anyone can list bounties, so no token or credits permission is needed.
const response = await fetch(`${ROTUR_API}/commerce${path}`);
const data = await response.json().catch(() => null);
if (!response.ok) throw new Error((data && data.error) || `Billing request failed (${response.status})`);
Expand Down Expand Up @@ -112,7 +108,6 @@ export {
isInsufficientFunds,
randomIdempotencyKey,
sendCommercePayment,
getCommerceEarnings,
listCommerceBounties,
createCommerceBounty,
cancelCommerceBounty
Expand Down
54 changes: 13 additions & 41 deletions src/community/pages/MyStuff.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import React, {useEffect, useState, useCallback, useRef} from 'react';
import {Link, useSearchParams} from 'react-router-dom';
import {
Plus, Trash2, Heart, ThumbsDown, Play, Upload, Star, MoreHorizontal, Pencil, ExternalLink, HardDrive,
SlidersHorizontal, Coins, Eye, TrendingUp, Wallet, HeartHandshake, FolderOpen, LayoutDashboard,
SlidersHorizontal, Coins, Eye, TrendingUp, ShoppingBag, HeartHandshake, FolderOpen, LayoutDashboard,
AlertTriangle, Library, Layers3, RotateCcw, Package, Image, Palette, Bookmark
} from 'lucide-react';
import api, {editorUrl, projectUrl} from '../api';
import {formatBytes, formatDate} from '../format';
import {getAccountSummary} from '../../lib/rotur/client.js';
import {useUser} from '../UserContext.jsx';
import Button from '../components/ui/Button.jsx';
import CardGrid from '../components/ui/CardGrid.jsx';
Expand Down Expand Up @@ -76,7 +75,7 @@ const visibilityLabel = project => {
return 'Draft';
};

const Overview = ({stats, account, quota, username, onNavigate}) => {
const Overview = ({stats, quota, username, onNavigate}) => {
const {text: communityText} = useCommunityText();
const [recent, setRecent] = useState(null);
const [recentFailed, setRecentFailed] = useState(false);
Expand Down Expand Up @@ -210,37 +209,24 @@ const Overview = ({stats, account, quota, username, onNavigate}) => {
</div>
<div className={styles.ovSide}>
<div className={styles.ovCard}>
<SectionHeading icon={Wallet} title={communityText('Wallet')} className={styles.cardHeading} />
{account && account.balance !== null ? (
<div className={styles.ovWalletTop}>
<span className={styles.ovWalletBalance}>
<Wallet size={16} aria-hidden="true" />
{fmtCredits(account.balance)}
</span>
<span className={styles.ovStatLabel}>{communityText('Balance')}</span>
<Button as={Link} to="/wallet"><Coins size={14} />{communityText('Open wallet')}</Button>
</div>
) : null}
<SectionHeading icon={Coins} title={communityText('Earnings')} className={styles.cardHeading} />
<div className={styles.ovWalletRows}>
{stats.totalRevenue > 0 ? (
<div className={styles.ovWalletRow}>
<span><Coins size={15} aria-hidden="true" />{communityText('Credits earned')}</span>
<strong>{fmtCredits(stats.totalRevenue)}</strong>
</div>
) : null}
{account && account.donationsReceived > 0 ? (
<div className={styles.ovWalletRow}>
<span><HeartHandshake size={15} aria-hidden="true" />{communityText('Donations received')}</span>
<strong>{fmtCredits(account.donationsReceived)}</strong>
</div>
) : null}
{!(stats.totalRevenue > 0) &&
!(account && account.donationsReceived > 0) &&
!(account && account.balance !== null) ? (
<EmptyState compact icon={Coins} title={communityText('No earnings yet')}>
{communityText('Offer a project for purchase so people can support your work.')}
</EmptyState>
) : null}
{stats.totalRevenue > 0 ? null : (
<EmptyState compact icon={Coins} title={communityText('No earnings yet')}>
{communityText('Offer a project for purchase so people can support your work.')}
</EmptyState>
)}
</div>
<div className={styles.ovCardActions}>
<Button as={Link} to="/purchases"><ShoppingBag size={14} />{communityText('Purchases')}</Button>
<Button as="a" href="https://rotur.dev/me" target="_blank" rel="noopener noreferrer">
<ExternalLink size={14} />{communityText('Balance on Rotur')}</Button>
</div>
</div>
{quota ? (
Expand Down Expand Up @@ -545,7 +531,6 @@ const MyStuff = () => {
const [perks, setPerks] = useState(null);
const [stats, setStats] = useState(null);
const [statsFailed, setStatsFailed] = useState(false);
const [account, setAccount] = useState(null);
const [inventoryItems, setInventoryItems] = useState(null);
const [inventoryFailed, setInventoryFailed] = useState(false);
const [pendingUploadFile, setPendingUploadFile] = useState(null);
Expand Down Expand Up @@ -667,7 +652,6 @@ const MyStuff = () => {
if (!username) {
setStats(null);
setStatsFailed(false);
setAccount(null);
return;
}
const context = accountContextRef.current;
Expand All @@ -689,17 +673,6 @@ const MyStuff = () => {
loadStats();
}, [loadStats]);

useEffect(() => {
if (!user) return;
let stale = false;
getAccountSummary()
.then(data => !stale && setAccount(data))
.catch(() => {});
return () => {
stale = true;
};
}, [user]);

const load = useCallback(() => {
const fresh = beginProjectLoad();
if (!user || tab !== 'projects') {
Expand Down Expand Up @@ -1349,7 +1322,6 @@ const MyStuff = () => {
stats ? (
<Overview
stats={stats}
account={account}
quota={quota}
username={username}
onNavigate={setTab}
Expand Down
21 changes: 1 addition & 20 deletions src/community/pages/MyStuff.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@

.ovCardActions {
display: flex;
flex-wrap: wrap;
gap: 8px;
}

Expand All @@ -382,26 +383,6 @@
gap: 6px;
}

.ovWalletTop {
display: flex;
flex-direction: column;
gap: 4px;
align-items: flex-start;
}

.ovWalletBalance {
display: inline-flex;
align-items: center;
gap: 8px;
font-size: var(--fs-3xl);
font-weight: 700;
color: var(--mw-text);
}

.ovWalletBalance svg {
color: var(--accent-strong);
}

.ovWalletRows {
display: flex;
flex-direction: column;
Expand Down
4 changes: 2 additions & 2 deletions src/community/pages/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1115,8 +1115,8 @@ export const DonateModal = ({recipient, onClose}) => {
{status ? <Notice variant="error">{status}</Notice> : null}
{insufficient ? (
<Notice variant="warning">
{communityText('Not enough credits in your balance. Claim your daily credits in your wallet, then send again.')}{' '}
<Link to="/wallet">{communityText('Open wallet')}</Link>
{communityText('Not enough credits in your balance. Claim your daily credits on Rotur, then send again.')}{' '}
<a href="https://rotur.dev/me" target="_blank" rel="noopener noreferrer">{communityText('Open Rotur')}</a>
</Notice>
) : null}
<Button
Expand Down
Loading
Loading