-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathtable-header-row.svelte
More file actions
68 lines (60 loc) · 1.89 KB
/
table-header-row.svelte
File metadata and controls
68 lines (60 loc) · 1.89 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<script lang="ts">
import { getContext } from 'svelte';
import Checkbox from '$lib/holocene/checkbox.svelte';
import { translate } from '$lib/i18n/translate';
import {
BATCH_OPERATION_CONTEXT,
type BatchOperationContext,
} from '$lib/pages/workflows-with-new-search.svelte';
import { supportsBulkActions } from '$lib/stores/bulk-actions';
import type { WorkflowExecution } from '$lib/types/workflows';
import BatchActions from './batch-actions.svelte';
export let workflows: WorkflowExecution[];
export let empty: boolean;
export let columnsCount: number;
export let pageSelectionStatus: 'checked' | 'unchecked' | 'partial' =
'unchecked';
export let onSelectPage: (
selected: boolean,
workflows: WorkflowExecution[],
) => void;
const { batchActionsVisible } = getContext<BatchOperationContext>(
BATCH_OPERATION_CONTEXT,
);
const handleCheckboxChange = (event: CustomEvent<{ checked: boolean }>) => {
const { checked } = event.detail;
onSelectPage(checked, workflows);
};
const label = translate('workflows.select-all-workflows');
</script>
<tr>
{#if !empty && $supportsBulkActions}
<th class="batch-actions-checkbox-table-cell">
<Checkbox
{label}
labelHidden
id="select-visible-workflows"
data-testid="batch-actions-checkbox"
checked={pageSelectionStatus === 'checked'}
indeterminate={pageSelectionStatus === 'partial'}
on:change={handleCheckboxChange}
/>
</th>
{/if}
<th class="w-6"></th>
{#if $supportsBulkActions && $batchActionsVisible}
<th class="batch-actions-table-cell" colspan={columnsCount}>
<BatchActions {workflows} />
</th>
{:else}
<slot />
{/if}
</tr>
<style lang="postcss">
.batch-actions-checkbox-table-cell {
@apply w-10;
}
.batch-actions-table-cell {
@apply overflow-visible whitespace-nowrap font-medium;
}
</style>