-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Expand file tree
/
Copy pathRenderQueueProgressMessage.tsx
More file actions
47 lines (40 loc) · 1.17 KB
/
RenderQueueProgressMessage.tsx
File metadata and controls
47 lines (40 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import React, {useCallback, useContext} from 'react';
import {ModalsContext} from '../../state/modals';
import {useZIndex} from '../../state/z-index';
import {getClientRenderProgressMessage} from './client-render-progress';
import type {AnyRenderJob} from './context';
import {isClientRenderJob} from './context';
import {renderQueueItemSubtitleStyle} from './item-style';
const outputLocation: React.CSSProperties = {
...renderQueueItemSubtitleStyle,
};
export const RenderQueueProgressMessage: React.FC<{
readonly job: AnyRenderJob;
}> = ({job}) => {
if (job.status !== 'running') {
throw new Error('should not have rendered this component');
}
const {setSelectedModal} = useContext(ModalsContext);
const {tabIndex} = useZIndex();
const isClientJob = isClientRenderJob(job);
const onClick = useCallback(() => {
setSelectedModal({
type: 'render-progress',
jobId: job.id,
});
}, [job.id, setSelectedModal]);
const message = isClientJob
? getClientRenderProgressMessage(job.progress)
: job.progress.message;
return (
<button
onClick={onClick}
type="button"
style={outputLocation}
tabIndex={tabIndex}
title={message}
>
{message}
</button>
);
};