mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-08-03 09:31:52 +00:00
Added non-standalone mode that hides 'open file' menus.
This commit is contained in:
15
src/app.tsx
15
src/app.tsx
@@ -61,10 +61,12 @@ interface State {
|
|||||||
showSidePanel?: boolean;
|
showSidePanel?: boolean;
|
||||||
/** Whether the app is in embedded mode, i.e. embedded in an iframe. */
|
/** Whether the app is in embedded mode, i.e. embedded in an iframe. */
|
||||||
embedded: boolean;
|
embedded: boolean;
|
||||||
|
/** Whether the app is in standalone mode, i.e. showing 'open file' menus */
|
||||||
|
standalone: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class App extends React.Component<RouteComponentProps, {}> {
|
export class App extends React.Component<RouteComponentProps, {}> {
|
||||||
state: State = {loading: false, embedded: false};
|
state: State = {loading: false, embedded: false, standalone: true};
|
||||||
chartRef: Chart | null = null;
|
chartRef: Chart | null = null;
|
||||||
|
|
||||||
private isNewData(
|
private isNewData(
|
||||||
@@ -155,7 +157,11 @@ export class App extends React.Component<RouteComponentProps, {}> {
|
|||||||
|
|
||||||
if (embedded && !this.state.embedded) {
|
if (embedded && !this.state.embedded) {
|
||||||
this.setState(
|
this.setState(
|
||||||
Object.assign({}, this.state, {embedded: true, showSidePanel}),
|
Object.assign({}, this.state, {
|
||||||
|
embedded: true,
|
||||||
|
standalone: false,
|
||||||
|
showSidePanel,
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
// Notify the parent window that we are ready.
|
// Notify the parent window that we are ready.
|
||||||
window.parent.postMessage('ready', '*');
|
window.parent.postMessage('ready', '*');
|
||||||
@@ -172,6 +178,7 @@ export class App extends React.Component<RouteComponentProps, {}> {
|
|||||||
const generation = !isNaN(parsedGen) ? parsedGen : undefined;
|
const generation = !isNaN(parsedGen) ? parsedGen : undefined;
|
||||||
const hash = getParam('file');
|
const hash = getParam('file');
|
||||||
const handleCors = getParam('handleCors') !== 'false'; // True by default.
|
const handleCors = getParam('handleCors') !== 'false'; // True by default.
|
||||||
|
const standalone = getParam('standalone') !== 'false'; // True by default.
|
||||||
|
|
||||||
const gedcom = this.props.location.state && this.props.location.state.data;
|
const gedcom = this.props.location.state && this.props.location.state.data;
|
||||||
const images =
|
const images =
|
||||||
@@ -190,6 +197,7 @@ export class App extends React.Component<RouteComponentProps, {}> {
|
|||||||
error: undefined,
|
error: undefined,
|
||||||
loading: true,
|
loading: true,
|
||||||
url,
|
url,
|
||||||
|
standalone,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
const data = hash
|
const data = hash
|
||||||
@@ -212,6 +220,7 @@ export class App extends React.Component<RouteComponentProps, {}> {
|
|||||||
loading: false,
|
loading: false,
|
||||||
url,
|
url,
|
||||||
showSidePanel,
|
showSidePanel,
|
||||||
|
standalone,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -290,7 +299,7 @@ export class App extends React.Component<RouteComponentProps, {}> {
|
|||||||
this.state.selection
|
this.state.selection
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
embedded={this.state.embedded}
|
standalone={this.state.standalone}
|
||||||
onSelection={this.onSelection}
|
onSelection={this.onSelection}
|
||||||
onPrint={() => {
|
onPrint={() => {
|
||||||
analyticsEvent('print');
|
analyticsEvent('print');
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ interface State {
|
|||||||
interface Props {
|
interface Props {
|
||||||
showingChart: boolean;
|
showingChart: boolean;
|
||||||
gedcom?: GedcomData;
|
gedcom?: GedcomData;
|
||||||
embedded: boolean;
|
standalone: boolean;
|
||||||
onSelection: (indiInfo: IndiInfo) => void;
|
onSelection: (indiInfo: IndiInfo) => void;
|
||||||
onPrint: () => void;
|
onPrint: () => void;
|
||||||
onDownloadPdf: () => void;
|
onDownloadPdf: () => void;
|
||||||
@@ -306,7 +306,7 @@ export class TopBar extends React.Component<
|
|||||||
</>
|
</>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
const fileMenus = this.props.embedded ? null : (
|
const fileMenus = this.props.standalone ? (
|
||||||
<>
|
<>
|
||||||
<Link to="/">
|
<Link to="/">
|
||||||
<Menu.Item>
|
<Menu.Item>
|
||||||
@@ -338,23 +338,9 @@ export class TopBar extends React.Component<
|
|||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</label>
|
</label>
|
||||||
</>
|
</>
|
||||||
);
|
) : null;
|
||||||
|
|
||||||
const sourceLink = this.props.embedded ? (
|
const sourceLink = this.props.standalone ? (
|
||||||
<>
|
|
||||||
<Menu.Item
|
|
||||||
as="a"
|
|
||||||
href="https://pewu.github.com/topola-viewer"
|
|
||||||
position="right"
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
<FormattedMessage
|
|
||||||
id="menu.powered_by"
|
|
||||||
defaultMessage="Powered by Topola"
|
|
||||||
/>
|
|
||||||
</Menu.Item>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
<>
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
as="a"
|
as="a"
|
||||||
@@ -368,6 +354,20 @@ export class TopBar extends React.Component<
|
|||||||
/>
|
/>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</>
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Menu.Item
|
||||||
|
as="a"
|
||||||
|
href="https://pewu.github.com/topola-viewer"
|
||||||
|
position="right"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
<FormattedMessage
|
||||||
|
id="menu.powered_by"
|
||||||
|
defaultMessage="Powered by Topola"
|
||||||
|
/>
|
||||||
|
</Menu.Item>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user