Skip to content
Open
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
23 changes: 23 additions & 0 deletions frontend/js/src/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ToastMsg } from "../notifications/Notifications";
import GlobalAppContext from "../utils/GlobalAppContext";
import Username from "../common/Username";
import FlairsSettings from "./flairs/FlairsSettings";
import Switch from "../components/Switch";

export default function Settings() {
const globalContext = React.useContext(GlobalAppContext);
Expand All @@ -18,6 +19,13 @@ export default function Settings() {

const [showToken, setShowToken] = React.useState(false);
const [copied, setCopied] = React.useState(false);
const [isBetaState, setIsBetaState] = React.useState(
window.location.hostname.includes("beta")
);
const handleBetaToggle = () => {
const returnTo = encodeURIComponent(window.location.pathname);
window.location.href = `/settings/set-beta-preference/?returnto=${returnTo}`;
};

const copyToken = () => {
if (!navigator.clipboard) {
Expand Down Expand Up @@ -87,6 +95,21 @@ export default function Settings() {
</div>

<FlairsSettings />
<h3>Beta Preferences</h3>

<Switch
id="enable-beta-site"
value="beta-site"
checked={isBetaState}
onChange={handleBetaToggle}
switchLabel={
<span className={`text-brand ${!isBetaState ? "text-muted" : ""}`}>
<span>
{isBetaState ? "Stop using Beta Site" : "Use Beta Site"}
</span>
</span>
}
/>

<h3>User token</h3>
<p>
Expand Down
11 changes: 11 additions & 0 deletions listenbrainz/webserver/views/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ def validate_funkwhale_url(url: str) -> str:

settings_bp = Blueprint("settings", __name__)

@settings_bp.get("/set-beta-preference/")
@login_required
def set_beta_preference():
use_beta = request.cookies.get("use_beta", "false")
nv = "false" if use_beta == "true" else "true"
return_to = request.args.get("returnto", "/")
response = redirect(return_to)
response.set_cookie("use_beta", nv)

return response


@settings_bp.post("/resettoken/")
@api_login_required
Expand Down
Loading