Skip to content

Commit

Permalink
support users styling
Browse files Browse the repository at this point in the history
  • Loading branch information
rpiaggio committed Sep 19, 2024
1 parent d0bcbe9 commit 9cff99d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,9 @@ object ExploreStyles:
// Program Tab
val ProgramDetailsTile: Css = Css("program-details-tile")
val ProgramDetailsInfoArea: Css = Css("program-details-info-area")
val ProgramDetailsLeft: Css = Css("program-details-left")
val ProgramTabTable: Css = Css("program-tab-table")
val ProgramDetailsUsers: Css = Css("program-details-users")

val FocusedInfo: Css = Css("explore-focused-info")

Expand Down
21 changes: 17 additions & 4 deletions common/src/main/webapp/sass/explore.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3245,17 +3245,30 @@ a.explore-upgrade-link {
justify-content: space-between;

.program-details-info-area {
display: grid;
grid-template-columns: [label] auto [value] 1fr;
gap: 0.25em 1em;
grid-auto-rows: max-content;
flex: 1 1 0;
padding: 1em;

&.program-details-left {
display: grid;
grid-template-columns: [label] auto [value] 1fr;
gap: 0.25em 1em;
grid-auto-rows: max-content;
}

label {
text-align: right;
font-weight: bold;
}

.program-details-users {
margin-bottom: 1em;

label {
display: flex;
gap: 1em;
align-items: center;
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object ProgramDetailsTile:
val readonly: Boolean = !EditSupportAccesses.contains_(props.currentUserAccess)

<.div(ExploreStyles.ProgramDetailsTile)(
<.div(ExploreStyles.ProgramDetailsInfoArea)(
<.div(ExploreStyles.ProgramDetailsInfoArea, ExploreStyles.ProgramDetailsLeft)(
FormInfo(details.reference.map(_.label).getOrElse("---"), "Reference"),
FormInfo(Constants.GppDateFormatter.format(props.semester.start.localDate), "Start"),
FormInfo(Constants.GppDateFormatter.format(props.semester.end.localDate), "End"),
Expand Down
3 changes: 2 additions & 1 deletion explore/src/main/scala/explore/programs/SupportUsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package explore.programs

import cats.data.NonEmptySet
import crystal.react.View
import explore.components.ui.ExploreStyles
import explore.model.ProgramUserWithRole
import explore.model.UserInvitation
import explore.users.InviteUserButton
Expand Down Expand Up @@ -32,7 +33,7 @@ object SupportUsers:
case Secondary extends SupportRole(ProgramUserRole.SupportSecondary)

private val component = ScalaFnComponent[Props]: props =>
<.div(
<.div(ExploreStyles.ProgramDetailsUsers)(
<.label(
props.title,
InviteUserButton(props.programId, props.supportRole.role, props.invitations)
Expand Down
42 changes: 0 additions & 42 deletions explore/src/main/scala/explore/proposal/InvestigatorUsers.scala

This file was deleted.

30 changes: 13 additions & 17 deletions explore/src/main/scala/explore/users/ProgramUserInvitations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,42 +48,38 @@ object ProgramUserInvitations:

private val ColDef = ColumnDef.WithTableMeta[UserInvitation, TableMeta]

private val KeyId: ColumnId = ColumnId("id")
private val EmailId: ColumnId = ColumnId("email")
private val EmailStatusId: ColumnId = ColumnId("emailStatus")
private val RevokeId: ColumnId = ColumnId("revoke")
private enum Column(val tag: String, val header: String):
val id: ColumnId = ColumnId(tag)

private val columnNames: Map[ColumnId, String] = Map(
KeyId -> "ID",
EmailId -> "email",
EmailStatusId -> "",
RevokeId -> ""
)
case Key extends Column("id", "Id")
case Email extends Column("email", "Email")
case EmailStatus extends Column("emailStatus", "")
case Revoke extends Column("revoke", "")

private def column[V](
id: ColumnId,
column: Column,
accessor: UserInvitation => V
): ColumnDef.Single.WithTableMeta[UserInvitation, V, TableMeta] =
ColDef(id, accessor, columnNames(id))
ColDef(column.id, accessor, column.header)

private def columns(
ctx: AppContext[IO]
): List[ColumnDef.WithTableMeta[UserInvitation, ?, TableMeta]] =
import ctx.given

List(
column(KeyId, _.id),
column(EmailId, _.email),
column(Column.Key, _.id),
column(Column.Email, _.email),
ColDef(
EmailStatusId,
Column.EmailStatus.id,
_.emailStatus,
"Email Status",
cell = _.value
.map(es => <.span(es.tag.toUpperCase).withTooltip(es.description))
.getOrElse(<.span())
),
ColDef(
RevokeId,
Column.Revoke.id,
identity,
"Revoke",
cell = cell =>
Expand Down Expand Up @@ -141,7 +137,7 @@ object ProgramUserInvitations:
readOnly = props.readonly
),
state = PartialTableState(columnVisibility =
ColumnVisibility(RevokeId -> Visibility.fromVisible(!props.readonly))
ColumnVisibility(Column.Revoke.id -> Visibility.fromVisible(!props.readonly))
)
)
.render: (props, _, _, _, _, table) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object ProgramUsersTable:
enum Column(
protected[ProgramUsersTable] val tag: String,
protected[ProgramUsersTable] val header: String
) derives Enumerated:
):
val id: ColumnId = ColumnId(tag)

case Name extends Column("name", "Name")
Expand Down

0 comments on commit 9cff99d

Please sign in to comment.