TrialIdColumn.tsx 1.66 KB
Newer Older
1
import * as React from 'react';
2
import { Stack } from '@fluentui/react';
3
import { AllExperimentList } from '../../static/interface';
4
import CopyButton from '../public-child/CopyButton';
5
6

interface TrialIdColumnProps {
7
    item: AllExperimentList;
8
9
10
11
12
13
14
15
}

class TrialIdColumn extends React.Component<TrialIdColumnProps, {}> {
    constructor(props: TrialIdColumnProps) {
        super(props);
    }

    render(): React.ReactNode {
16
        const { item } = this.props;
17
18
        const hostname = window.location.hostname;
        const protocol = window.location.protocol;
19
20
21
22
        const webuiPortal =
            item.prefixUrl === null
                ? `${protocol}//${hostname}:${item.port}/oview`
                : `${protocol}//${hostname}:${item.port}/${this.formatPrefix(item.prefixUrl)}/oview`;
23
        return (
24
            <Stack horizontal className='ellipsis idCopy'>
25
26
                {item.status === 'STOPPED' ? (
                    <div className='idColor'>{item.id}</div>
27
                ) : (
28
29
30
31
32
33
                    <a
                        href={webuiPortal}
                        className='link toAnotherExp idColor'
                        target='_blank'
                        rel='noopener noreferrer'
                    >
34
                        {item.id}
35
36
                    </a>
                )}
37
                <CopyButton value={item.id} />
38
            </Stack>
39
40
        );
    }
41
42
43
44
45
46
47
48
49
50
51
52

    private formatPrefix(prefix): string {
        if (prefix.startsWith('/')) {
            prefix = prefix.slice(1);
        }

        if (prefix.endsWith('/')) {
            prefix = prefix.slice(0, prefix.length - 1);
        }

        return prefix;
    }
53
54
55
}

export default TrialIdColumn;