argo-cd

Форк
0
25 строк · 1016.0 Байт
1
import * as React from 'react';
2
import {useContext} from 'react';
3
import {Button} from '../../../shared/components/button';
4
import {Context} from '../../../shared/context';
5
import {NotificationType} from 'argo-ui/src/components/notifications/notifications';
6
import {LogEntry} from '../../../shared/models';
7

8
// CopyLogsButton is a button that copies the logs to the clipboard
9
export const CopyLogsButton = ({logs}: {logs: LogEntry[]}) => {
10
    const ctx = useContext(Context);
11
    return (
12
        <Button
13
            title='Copy logs to clipboard'
14
            icon='copy'
15
            onClick={async () => {
16
                try {
17
                    await navigator.clipboard.writeText(logs.map(item => item.content).join('\n'));
18
                    ctx.notifications.show({type: NotificationType.Success, content: 'Copied'}, 750);
19
                } catch (err) {
20
                    ctx.notifications.show({type: NotificationType.Error, content: err.message});
21
                }
22
            }}
23
        />
24
    );
25
};
26

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.