{#if loaded}
{$i18n.t('Skills')}
{total ?? ''}
{ if (importFiles && importFiles.length > 0) { const reader = new FileReader(); reader.onload = (event) => { const mdContent = event.target?.result; if (typeof mdContent === 'string') { const fm = parseFrontmatter(mdContent); const fileName = importFiles[0].name.replace(/\.md$/, ''); const rawName = fm.name || fileName; const displayName = formatSkillName(rawName); sessionStorage.skill = JSON.stringify({ name: displayName, id: fm.name || '', // Use raw frontmatter name as ID if available description: fm.description || '', content: mdContent, is_active: true, access_grants: [] }); goto('/workspace/skills/create'); } }; reader.readAsText(importFiles[0]); } }} /> {#if $user?.role === 'admin' || $user?.permissions?.workspace?.skills}
{ importInputElement.click(); }} >
{$i18n.t('Import')}
{/if} {#if total && ($user?.role === 'admin' || $user?.permissions?.workspace?.skills)}
{ const _skills = await exportSkills(localStorage.token).catch((error) => { toast.error(`${error}`); return null; }); if (_skills) { let blob = new Blob([JSON.stringify(_skills)], { type: 'application/json' }); saveAs(blob, `skills-export-${Date.now()}.json`); } }} >
{$i18n.t('Export')}
{/if} {#if $user?.role === 'admin' || $user?.permissions?.workspace?.skills}
{$i18n.t('New Skill')}
{/if}
{#if query}
{ query = ''; }} >
{/if}
{ if (e.deltaY !== 0) { e.preventDefault(); e.currentTarget.scrollLeft += e.deltaY; } }} >
{ localStorage.workspaceViewOption = value; page = 1; await tick(); }} />
{#if filteredItems === null || loading}
{:else if (filteredItems ?? []).length !== 0}
{#each filteredItems as skill}
{#if skill.write_access}
{skill.name}
{#if !skill.is_active}
{/if}
{$i18n.t('By {{name}}', { name: capitalizeFirstLetter( skill?.user?.name ?? skill?.user?.email ?? $i18n.t('Deleted User') ) })}
{:else}
{skill.name}
{#if !skill.is_active}
{/if}
{$i18n.t('By {{name}}', { name: capitalizeFirstLetter( skill?.user?.name ?? skill?.user?.email ?? $i18n.t('Deleted User') ) })}
{/if} {#if skill.write_access}
{#if shiftKey}
{ deleteHandler(skill); }} >
{:else}
{ goto(`/workspace/skills/edit?id=${encodeURIComponent(skill.id)}`); }} cloneHandler={() => { cloneHandler(skill); }} exportHandler={() => { exportHandler(skill); }} deleteHandler={async () => { selectedSkill = skill; showDeleteConfirm = true; }} onClose={() => {}} >
{/if}
{ toggleSkillById(localStorage.token, skill.id); }} />
{/if}
{/each}
{#if total > 30}
{/if} {:else}
📝
{$i18n.t('No skills found')}
{$i18n.t('Try adjusting your search or filter to find what you are looking for.')}
{/if}
{ deleteHandler(selectedSkill); }} >
{$i18n.t('This will delete')}
{selectedSkill.name}
.
{:else}
{/if}