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
Sebastian Malton b1ff34879a cleanup Lens repo with tighter linting
Signed-off-by: Sebastian Malton <smalton@mirantis.com>
2020-07-09 17:00:23 -04:00

55 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 = (): void => {
if (copyToClipboard(this.logsElem)) {
Notifications.ok(_i18n._(t`Logs copied to clipboard.`));
}
}
render(): JSX.Element {
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): void => {
this.logsElem = e;
}}>
{logs || <Trans>There are no logs available.</Trans>}
</code>
</WizardStep>
</Wizard>
</Dialog>
);
}
}