Skip to content

Commit

Permalink
fix: disable settings button while loading
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Oct 16, 2024
1 parent 4eff1b7 commit a031ebe
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
6 changes: 1 addition & 5 deletions lib/static/components/controls/report-info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ function ReportInfo(props) {
const onNewUiButtonClick = () => {
setUiMode(UiMode.New);

if (window.location.pathname.endsWith('.html')) {
window.location.href = '/new-ui.html';
} else {
window.location.href = '/new-ui';
}
window.location.pathname = window.location.pathname.replace(/\/(index\.html)?$/, (match, ending) => ending ? '/new-ui.html' : '/new-ui');
};

return (
Expand Down
5 changes: 5 additions & 0 deletions lib/static/new-ui/components/MainLayout/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
width: 100%;
}

:global(.gn-composite-bar-item):has(.footer-item:global(.disabled)) {
pointer-events: none;
opacity: .5;
}

.footer-item {
color: var(--gn-aside-header-item-icon-color) !important;
}
Expand Down
6 changes: 5 additions & 1 deletion lib/static/new-ui/components/MainLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ export function MainLayout(props: MainLayoutProps): JSX.Element {
current: isCurrent,
itemWrapper: (params, makeItem) => makeItem({
...params,
icon: <Icon className={classNames({[styles.footerItem]: !isCurrent, [styles['footer-item--active']]: isCurrent})} data={Gear} />
icon: <Icon className={classNames({
[styles.footerItem]: !isCurrent,
[styles['footer-item--active']]: isCurrent,
disabled: !isInitialized
})} data={Gear} />
})
}} />
</>;
Expand Down
6 changes: 1 addition & 5 deletions lib/static/new-ui/components/SettingsPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ export function SettingsPanel(): ReactNode {
const onOldUiButtonClick = (): void => {
setUiMode(UiMode.Old);

if (window.location.pathname.endsWith('.html')) {
window.location.href = '/index.html';
} else {
window.location.href = '/';
}
window.location.pathname = window.location.pathname.replace(/\/new-ui(\.html)?$/, (_match, ending) => ending ? '/index.html' : '/');
};

return <div className={styles.container}>
Expand Down
16 changes: 4 additions & 12 deletions lib/static/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,10 @@
uiMode = JSON.parse(localStorage.getItem('html-reporter:ui-mode'));
} catch {}

if (uiMode === 'old' && window.location.pathname.startsWith('/new-ui')) {
if (window.location.pathname.endsWith('.html')) {
window.location.href = '/index.html';
} else {
window.location.href = '/';
}
} else if ((!uiMode || uiMode === 'new') && !window.location.pathname.startsWith('/new-ui')) {
if (window.location.pathname.endsWith('.html')) {
window.location.href = '/new-ui.html';
} else {
window.location.href = '/new-ui';
}
if (uiMode === 'old' && /\/new-ui(?:\.html)?$/.test(window.location.pathname)) {
window.location.pathname = window.location.pathname.replace(/\/new-ui(\.html)?$/, (match, ending) => ending ? '/index.html' : '/');
} else if (uiMode === 'new' && !/\/new-ui(?:\.html)?$/.test(window.location.pathname)) {
window.location.pathname = window.location.pathname.replace(/\/(index\.html)?$/, (match, ending) => ending ? '/new-ui.html' : '/new-ui');
}
</script>
<body class="report">
Expand Down

0 comments on commit a031ebe

Please sign in to comment.