1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/dashboard/client/components/dialog/logs-dialog.tsx
Jari Kolehmainen 1d0815abd2
Lens app source code (#119)
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
2020-03-15 09:52:02 +02:00

53 lines
1.6 KiB
TypeScript

import "./logs-dialog.scss";
import * as React from "react";
import { t, Trans } from "@lingui/macro";
import { Dialog, DialogProps } from "../dialog";
import { Wizard, WizardStep } from "../wizard";
import { copyToClipboard } from "../../utils";
import { Notifications } from "../notifications";
import { Button } from "../button";
import { Icon } from "../icon";
import { _i18n } from "../../i18n";
interface Props extends DialogProps {
title: string;
logs: string;
}
export class LogsDialog extends React.Component<Props> {
public logsElem: HTMLElement;
copyToClipboard = () => {
if (copyToClipboard(this.logsElem)) {
Notifications.ok(_i18n._(t`Logs copied to clipboard.`))
}
}
render() {
const { title, logs, ...dialogProps } = this.props;
const header = <h5>{title}</h5>
const customButtons = (
<div className="buttons flex gaps align-center justify-space-between">
<Button plain onClick={this.copyToClipboard}>
<Icon material="assignment"/> <Trans>Copy to clipboard</Trans>
</Button>
<Button plain onClick={dialogProps.close}>
<Trans>Close</Trans>
</Button>
</div>
)
return (
<Dialog {...dialogProps} className="LogsDialog">
<Wizard header={header} done={dialogProps.close}>
<WizardStep scrollable={false} customButtons={customButtons}>
<code ref={e => this.logsElem = e}>
{logs || <Trans>There are no logs available.</Trans>}
</code>
</WizardStep>
</Wizard>
</Dialog>
)
}
}