-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #450 from fractal-analytics-platform/task-v1v2-com…
…patibility Tasks V1/V2 compatibility
- Loading branch information
Showing
39 changed files
with
1,395 additions
and
799 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<script> | ||
/** | ||
* @type {any[]} | ||
*/ | ||
export let tasks; | ||
/** | ||
* @param {number} index | ||
*/ | ||
function isOldVersion(index) { | ||
if (index === 0) { | ||
return false; | ||
} | ||
const currentTask = tasks[index]; | ||
const previousTask = tasks[index - 1]; | ||
return previousTask.name === currentTask.name && previousTask.owner === currentTask.owner; | ||
} | ||
/** | ||
* @param {number} index | ||
*/ | ||
function isLastOldVersion(index) { | ||
if (!isOldVersion(index)) { | ||
return false; | ||
} | ||
if (index === tasks.length - 1) { | ||
return false; | ||
} | ||
const currentTask = tasks[index]; | ||
const nextTask = tasks[index + 1]; | ||
return nextTask.name !== currentTask.name || nextTask.owner !== currentTask.owner; | ||
} | ||
/** | ||
* @param {number} index | ||
*/ | ||
function isMainVersion(index) { | ||
if (isOldVersion(index)) { | ||
return false; | ||
} | ||
if (index === tasks.length - 1) { | ||
return false; | ||
} | ||
const currentTask = tasks[index]; | ||
const nextTask = tasks[index + 1]; | ||
return nextTask.name === currentTask.name && nextTask.owner === currentTask.owner; | ||
} | ||
/** | ||
* @param {Event} event | ||
*/ | ||
function handleToggleOldVersions(event) { | ||
const element = /** @type {HTMLElement} */ (event.target); | ||
/** @type {HTMLElement|null} */ | ||
let row = /** @type {HTMLElement} */ (element.closest('tr')); | ||
if (!row.classList.contains('expanded')) { | ||
closeAllOldVersions(/** @type {HTMLElement} */ (row.closest('table'))); | ||
} | ||
toggleOldVersions(row); | ||
} | ||
/** | ||
* @param {HTMLElement} table | ||
*/ | ||
function closeAllOldVersions(table) { | ||
const rows = table.querySelectorAll('tr'); | ||
for (const row of rows) { | ||
if (row.classList.contains('expanded')) { | ||
toggleOldVersions(row); | ||
} | ||
} | ||
} | ||
/** | ||
* @param {HTMLElement} mainRow | ||
*/ | ||
function toggleOldVersions(mainRow) { | ||
mainRow.classList.toggle('expanded'); | ||
/** @type {HTMLElement|null} */ | ||
let row = mainRow; | ||
while ((row = /** @type {HTMLElement|null} */ (row?.nextSibling))) { | ||
if (!row.classList) { | ||
continue; | ||
} | ||
if (row.classList.contains('old-version')) { | ||
row.classList.toggle('collapsed'); | ||
} else { | ||
break; | ||
} | ||
} | ||
} | ||
</script> | ||
<table class="table align-middle"> | ||
<slot name="thead" /> | ||
<tbody> | ||
{#key tasks} | ||
{#each tasks as task, i} | ||
<tr | ||
class:old-version={isOldVersion(i)} | ||
class:last-old-version={isLastOldVersion(i)} | ||
class:is-main-version={isMainVersion(i)} | ||
class:collapsed={isOldVersion(i)} | ||
> | ||
<slot name="custom-columns-left" {task} /> | ||
<td>{isOldVersion(i) ? '' : task.name}</td> | ||
<td> | ||
{task.version || '–'} | ||
{#if isMainVersion(i)} | ||
<button class="btn btn-link" on:click={handleToggleOldVersions} aria-label="Expand old versions"> | ||
<i class="bi bi-plus-circle" /> | ||
</button> | ||
{/if} | ||
</td> | ||
<slot name="custom-columns-right" {task} /> | ||
</tr> | ||
{/each} | ||
{/key} | ||
</tbody> | ||
</table> | ||
<style> | ||
:global(.is-main-version.expanded td) { | ||
border-bottom-style: dashed; | ||
} | ||
:global(.old-version.collapsed) { | ||
display: none; | ||
} | ||
:global(.old-version) { | ||
display: table-row; | ||
} | ||
:global(.old-version td) { | ||
border-bottom-style: dashed; | ||
} | ||
:global(.last-old-version td) { | ||
border-bottom-style: solid; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<script> | ||
import { formatMarkdown } from '$lib/common/component_utilities'; | ||
/** @type {import("$lib/types").Task} */ | ||
export let task; | ||
</script> | ||
|
||
<ul class="list-group"> | ||
<li class="list-group-item list-group-item-light fw-bold">Name</li> | ||
<li class="list-group-item">{task.name}</li> | ||
<li class="list-group-item list-group-item-light fw-bold">Version</li> | ||
<li class="list-group-item">{task.version || '–'}</li> | ||
<li class="list-group-item list-group-item-light fw-bold">Docs Link</li> | ||
<li class="list-group-item"> | ||
{#if task.docs_link} | ||
<a href={task.docs_link} target="_blank">{task.docs_link}</a> | ||
{:else} | ||
- | ||
{/if} | ||
</li> | ||
<li class="list-group-item list-group-item-light fw-bold">Docs Info</li> | ||
<li class="list-group-item"> | ||
{#if task.docs_info} | ||
{@html formatMarkdown(task.docs_info)} | ||
{:else} | ||
- | ||
{/if} | ||
</li> | ||
<li class="list-group-item list-group-item-light fw-bold">Owner</li> | ||
<li class="list-group-item">{task.owner || '–'}</li> | ||
<li class="list-group-item list-group-item-light fw-bold">Command</li> | ||
<li class="list-group-item"> | ||
<code>{task.command}</code> | ||
</li> | ||
<li class="list-group-item list-group-item-light fw-bold">Source</li> | ||
<li class="list-group-item"> | ||
<code>{task.source}</code> | ||
</li> | ||
<li class="list-group-item list-group-item-light fw-bold">Input Type</li> | ||
<li class="list-group-item"> | ||
<code>{task.input_type}</code> | ||
</li> | ||
<li class="list-group-item list-group-item-light fw-bold">Output Type</li> | ||
<li class="list-group-item"> | ||
<code>{task.output_type}</code> | ||
</li> | ||
<li class="list-group-item list-group-item-light fw-bold">Args Schema Version</li> | ||
<li class="list-group-item"> | ||
{task.args_schema_version || '–'} | ||
</li> | ||
<li class="list-group-item list-group-item-light fw-bold">Args Schema</li> | ||
<li class="list-group-item"> | ||
{#if task.args_schema} | ||
<code> | ||
<pre>{JSON.stringify(task.args_schema, null, 2)}</pre> | ||
</code> | ||
{:else} | ||
- | ||
{/if} | ||
</li> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.