diff --git a/CHANGELOG.md b/CHANGELOG.md index f8f8e8a..b0af771 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v1.0.60] - 2026-01-27 + +### Fixed +- check user status in an organization before making api requests which may fail if the user didn't accept the invitation yet +- when showing the list of organizations, show the user status and disable the selection of organizations where the status is not active + ## [v1.0.59] - 2026-01-23 ### Added diff --git a/src/entity/org.go b/src/entity/org.go index cc2a69a..d6a9193 100644 --- a/src/entity/org.go +++ b/src/entity/org.go @@ -7,9 +7,10 @@ import ( ) type Org struct { - Id uuid.ClientId - Role enum.ClientUserRoleCodeEnum - Name types.String + Id uuid.ClientId + Role enum.ClientUserRoleCodeEnum + Name types.String + Status enum.ClientUserStatusEnum } var OrgFields = entityTemplateFields[Org]() diff --git a/src/entity/repository/org.go b/src/entity/repository/org.go index ba64ca1..ba209ae 100644 --- a/src/entity/repository/org.go +++ b/src/entity/repository/org.go @@ -53,8 +53,9 @@ func GetOrgById( func orgFromEsSearch(esClientUser output.ClientUserExtraWithClientLight) entity.Org { return entity.Org{ - Id: esClientUser.ClientId, - Name: esClientUser.Client.AccountName, - Role: esClientUser.RoleCode, + Id: esClientUser.ClientId, + Name: esClientUser.Client.AccountName, + Status: esClientUser.Status, + Role: esClientUser.RoleCode, } } diff --git a/src/entity/repository/project.go b/src/entity/repository/project.go index ac39bdd..905ac5d 100644 --- a/src/entity/repository/project.go +++ b/src/entity/repository/project.go @@ -42,6 +42,9 @@ func GetAllProjects( var projects []entity.Project for _, org := range orgs { + if !org.Status.IsActive() { + continue + } esFilter := body.EsFilter{ Search: []body.EsSearchItem{ { diff --git a/src/uxBlock/models/selector/model.go b/src/uxBlock/models/selector/model.go index 10ae70b..633f2d9 100644 --- a/src/uxBlock/models/selector/model.go +++ b/src/uxBlock/models/selector/model.go @@ -173,6 +173,9 @@ func (m *Model) Update(msg tea.Msg) (*Model, tea.Cmd) { case key.Matches(keyMsg, m.keyMap.End): m.End() case key.Matches(keyMsg, m.keyMap.Select): + if m.isCursorOnDisabled() { + return m, nil + } if !m.multi { m.Select() } @@ -226,6 +229,9 @@ func (m *Model) Select() { return } selectedRow := m.filteredBody.Rows()[m.cursor] + if selectedRow.IsDisabled() { + return + } if m.multi { if _, ok := m.selected[selectedRow.Index()]; ok { delete(m.selected, selectedRow.Index()) @@ -239,6 +245,9 @@ func (m *Model) Select() { func (m *Model) SelectAll(deselect bool) { for _, r := range m.filteredBody.Rows() { + if r.IsDisabled() { + continue + } if !deselect { m.selected[r.Index()] = struct{}{} } else { @@ -274,6 +283,23 @@ func (m *Model) isSelected(row int) bool { return selected } +func (m *Model) isRowDisabled(displayRow, maxRows int) bool { + page := m.cursor / maxRows + actualIndex := page*maxRows + displayRow + rows := m.filteredBody.Rows() + if actualIndex >= len(rows) { + return false + } + return rows[actualIndex].IsDisabled() +} + +func (m *Model) isCursorOnDisabled() bool { + if !m.hasResults() { + return true + } + return m.filteredBody.Rows()[m.cursor].IsDisabled() +} + func (m *Model) View() string { rows := m.filteredBody.Rows() totalRows := len(rows) @@ -304,7 +330,15 @@ func (m *Model) View() string { if row == ltable.HeaderRow { return styles.TableRow() } - if row == m.cursor%maxRows && !m.filterField.Focused() { + isActive := row == m.cursor%maxRows && !m.filterField.Focused() + isDisabled := m.isRowDisabled(row, maxRows) + if isDisabled && isActive { + return styles.TableRowDisabledActive() + } + if isDisabled { + return styles.TableRowDisabled() + } + if isActive { return styles.TableRowActive() } return styles.TableRow() diff --git a/src/uxBlock/models/table/components.go b/src/uxBlock/models/table/components.go index 6df148a..e74276e 100644 --- a/src/uxBlock/models/table/components.go +++ b/src/uxBlock/models/table/components.go @@ -69,8 +69,9 @@ func (b *Body) Rows() []*Row { } type Row struct { - index int - cells []Cell + index int + cells []Cell + disabled bool } func NewRow(cells ...Cell) *Row { @@ -127,6 +128,15 @@ func (r *Row) Cells() []Cell { return r.cells } +func (r *Row) SetDisabled(disabled bool) *Row { + r.disabled = disabled + return r +} + +func (r *Row) IsDisabled() bool { + return r.disabled +} + type Cell struct { text string style lipgloss.Style diff --git a/src/uxBlock/styles/styles.go b/src/uxBlock/styles/styles.go index f2b202d..c449d01 100644 --- a/src/uxBlock/styles/styles.go +++ b/src/uxBlock/styles/styles.go @@ -90,6 +90,21 @@ func TableRowActive() lipgloss.Style { PaddingRight(1) } +func TableRowDisabled() lipgloss.Style { + return DefaultStyle(). + Foreground(lipgloss.ANSIColor(245)). + PaddingLeft(1). + PaddingRight(1) +} + +func TableRowDisabledActive() lipgloss.Style { + return DefaultStyle(). + Foreground(lipgloss.ANSIColor(245)). + Background(lipgloss.ANSIColor(236)). + PaddingLeft(1). + PaddingRight(1) +} + var helpStyle = DefaultStyle(). Foreground(HelpColor) diff --git a/src/uxHelpers/org.go b/src/uxHelpers/org.go index f9bef5b..f5aa730 100644 --- a/src/uxHelpers/org.go +++ b/src/uxHelpers/org.go @@ -68,17 +68,21 @@ func PrintOrgSelector( return orgs[selected], nil } -func createOrgTableRows(projects []entity.Org) (*table.Row, *table.Body) { - header := table.NewRowFromStrings("ID", "Name", "Role") +func createOrgTableRows(orgs []entity.Org) (*table.Row, *table.Body) { + header := table.NewRowFromStrings("ID", "Name", "Role", "Status") body := table.NewBody() - for _, project := range projects { - body.AddStringsRow( - string(project.Id), - project.Name.String(), - project.Role.Native(), + for _, org := range orgs { + row := table.NewRowFromStrings( + string(org.Id), + org.Name.String(), + org.Role.Native(), + org.Status.String(), ) + if !org.Status.IsActive() { + row.SetDisabled(true) + } + body.AddRow(row) } - return header, body }