Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions ui/src/views/SkillsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { computed, onMounted, ref } from 'vue';
import { api, paths } from '@/api';
import type { PoolSkillsState, SkillSetState, SkillState } from '@/api/types';
import { act } from '@/lib/actions';
import { persist } from '@/lib/persist';
import { ago, useNow } from '@/lib/format';
import { counts, filtered, groupOf, groups, NO_FILTER, rows, setKey, STATUS_LABEL, type SkillFilter, type SkillRow, type SkillStatus } from '@/lib/skills';
import { useHub } from '@/stores/hub';
Expand Down Expand Up @@ -100,6 +101,21 @@ function expand(key: string) {
else s.add(key);
expanded.value = s;
}
// A group folds away with a click on its heading; which ones are folded is
// remembered in this browser. While a filter is on, every group with a match
// shows, folded or not.
const COLLAPSED = 'skills.collapsed';
const collapsed = ref<Set<string>>(new Set(persist.get<string[]>(COLLAPSED) ?? []));
const groupKey = (s: SkillSetState, g: string) => `${setKey(s)}#${g}`;
const isCollapsed = (s: SkillSetState, g: string) => !filterOn.value && collapsed.value.has(groupKey(s, g));
function toggleGroup(s: SkillSetState, g: string) {
const c = new Set(collapsed.value);
const k = groupKey(s, g);
if (c.has(k)) c.delete(k);
else c.add(k);
collapsed.value = c;
persist.set(COLLAPSED, [...c]);
}
/** A set's shown rows by group, in the groups' order, those without one last. */
function groupsOf(s: SkillSetState) {
const mine = shown.value.filter((r) => r.set === s);
Expand Down Expand Up @@ -266,8 +282,18 @@ const conflictOf = (k: SkillState) => state.value?.conflicts.find((c) => c.name

<div v-for="g in groupsOf(s)" :key="g.group || '-'" class="group" data-testid="skills-group" :data-group="g.group">
<div v-if="grouped(s)" class="group-head">
<span class="group-name">{{ g.group || 'No group' }}</span>
<span class="faint small">{{ g.rows.length }}</span>
<button
type="button"
class="group-toggle"
:aria-expanded="!isCollapsed(s, g.group)"
:title="isCollapsed(s, g.group) ? 'Show the skills of the group' : 'Fold the group away'"
data-testid="skills-group-toggle"
@click="toggleGroup(s, g.group)"
>
<Icon :name="isCollapsed(s, g.group) ? 'chevronRight' : 'chevronDown'" :size="12" class="faint" />
<span class="group-name">{{ g.group || 'No group' }}</span>
<span class="faint small">{{ g.rows.length }}</span>
</button>
<label v-if="s.state === 'accepted'" class="toggle small" :title="`Switch every skill of ${g.group || 'no group'} on or off`">
<input
type="checkbox"
Expand All @@ -279,7 +305,7 @@ const conflictOf = (k: SkillState) => state.value?.conflicts.find((c) => c.name
all on
</label>
</div>
<ul class="skill-list">
<ul v-if="!grouped(s) || !isCollapsed(s, g.group)" class="skill-list">
<li v-for="r in g.rows" :key="r.key" class="skill" :class="{ off: r.status === 'off' || r.status === 'not-accepted' }" data-testid="skills-skill" :data-name="r.skill.name">
<div class="skill-row">
<input
Expand Down Expand Up @@ -454,6 +480,16 @@ const conflictOf = (k: SkillState) => state.value?.conflicts.find((c) => c.name
border-radius: 6px;
background: var(--surface-hover);
}
.group-toggle {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 0;
border: 0;
background: transparent;
color: inherit;
cursor: pointer;
}
.group-name {
font-size: 12px;
font-weight: 600;
Expand Down
Loading