wip: workgroup description
This commit is contained in:
parent
4ee3de773c
commit
523fcee03b
|
@ -14,6 +14,7 @@ export function InfoForm({ workgroup, onChange }: InfoFormProps) {
|
|||
workgroup: {
|
||||
id: workgroup && workgroup.id ? workgroup.id : '',
|
||||
name: workgroup && workgroup.name ? workgroup.name : '',
|
||||
description: workgroup && workgroup.description ? workgroup.description : '',
|
||||
createdAt: workgroup && workgroup.createdAt ? workgroup.createdAt : null,
|
||||
closedAt: workgroup && workgroup.closedAt ? workgroup.closedAt : null,
|
||||
}
|
||||
|
@ -34,6 +35,7 @@ export function InfoForm({ workgroup, onChange }: InfoFormProps) {
|
|||
workgroup: {
|
||||
id: workgroup && workgroup.id ? workgroup.id : '',
|
||||
name: workgroup && workgroup.name ? workgroup.name : '',
|
||||
description: workgroup && workgroup.description ? workgroup.description : '',
|
||||
createdAt: workgroup && workgroup.createdAt ? workgroup.createdAt : null,
|
||||
closedAt: workgroup && workgroup.closedAt ? workgroup.closedAt : null,
|
||||
}
|
||||
|
@ -76,6 +78,14 @@ export function InfoForm({ workgroup, onChange }: InfoFormProps) {
|
|||
onChange={onWorkgroupAttrChange.bind(null, "name")} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label className="label">Nom du groupe</label>
|
||||
<div className="control">
|
||||
<textarea className="input" value={state.workgroup.description}
|
||||
disabled={!isAuthorized}
|
||||
onChange={onWorkgroupAttrChange.bind(null, "description")}></textarea>
|
||||
</div>
|
||||
</div>
|
||||
{
|
||||
state.workgroup.createdAt ?
|
||||
<div className="field">
|
||||
|
|
|
@ -7,6 +7,7 @@ mutation updateWorkgroup($workgroupId: ID!, $changes: WorkgroupChanges!) {
|
|||
updateWorkgroup(workgroupId: $workgroupId, changes: $changes) {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
createdAt,
|
||||
closedAt,
|
||||
members {
|
||||
|
@ -26,6 +27,7 @@ mutation createWorkgroup($changes: WorkgroupChanges!) {
|
|||
createWorkgroup(changes: $changes) {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
createdAt,
|
||||
closedAt,
|
||||
members {
|
||||
|
@ -47,6 +49,7 @@ mutation joinWorkgroup($workgroupId: ID!) {
|
|||
joinWorkgroup(workgroupId: $workgroupId) {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
createdAt,
|
||||
closedAt,
|
||||
members {
|
||||
|
@ -78,6 +81,7 @@ mutation leaveWorkgroup($workgroupId: ID!) {
|
|||
leaveWorkgroup(workgroupId: $workgroupId) {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
createdAt,
|
||||
closedAt,
|
||||
members {
|
||||
|
@ -117,6 +121,7 @@ mutation closeWorkgroup($workgroupId: ID!) {
|
|||
closeWorkgroup(workgroupId: $workgroupId) {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
createdAt,
|
||||
closedAt,
|
||||
members {
|
||||
|
|
|
@ -7,6 +7,7 @@ export const QUERY_WORKGROUP = gql`
|
|||
workgroups(filter: $filter) {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
createdAt,
|
||||
closedAt,
|
||||
members {
|
||||
|
|
|
@ -2,6 +2,7 @@ import { User } from "./user";
|
|||
export interface Workgroup {
|
||||
id: string
|
||||
name: string
|
||||
description: string
|
||||
createdAt: Date
|
||||
closedAt: Date
|
||||
members: User[]
|
||||
|
|
|
@ -27,7 +27,8 @@ func applyMigration(ctx context.Context, ctn *service.Container) error {
|
|||
|
||||
// Register available migrations
|
||||
migr.Register(
|
||||
m000initialSchema(),
|
||||
m000InitialSchema(),
|
||||
m001WorkgroupDescription(),
|
||||
)
|
||||
|
||||
currentVersion, err := migr.CurrentVersion(ctx)
|
||||
|
@ -84,7 +85,7 @@ var initialModels = []interface{}{
|
|||
&model.Event{},
|
||||
}
|
||||
|
||||
func m000initialSchema() orm.Migration {
|
||||
func m000InitialSchema() orm.Migration {
|
||||
return orm.NewDBMigration(
|
||||
"00_initial_schema",
|
||||
func(ctx context.Context, tx *gorm.DB) error {
|
||||
|
@ -107,3 +108,23 @@ func m000initialSchema() orm.Migration {
|
|||
},
|
||||
)
|
||||
}
|
||||
|
||||
func m001WorkgroupDescription() orm.Migration {
|
||||
return orm.NewDBMigration(
|
||||
"01_workgroup_description",
|
||||
func(ctx context.Context, tx *gorm.DB) error {
|
||||
if err := tx.AutoMigrate(&model.Workgroup{}).Error; err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
func(ctx context.Context, tx *gorm.DB) error {
|
||||
if err := tx.Model(&model.Workgroup{}).DropColumn("description").Error; err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ const ObjectTypeWorkgroup = "workgroup"
|
|||
type Workgroup struct {
|
||||
gorm.Model
|
||||
Name *string `json:"name"`
|
||||
Workgroup *string `json:"workgroup"`
|
||||
ClosedAt time.Time `json:"closedAt"`
|
||||
Members []*User `gorm:"many2many:users_workgroups;association_autoupdate:false"`
|
||||
}
|
||||
|
|
|
@ -68,9 +68,8 @@ func handleLoginCallback(w http.ResponseWriter, r *http.Request) {
|
|||
db := orm.Must(ctn).DB()
|
||||
repo := model.NewUserRepository(db)
|
||||
|
||||
user, err := repo.CreateOrConnectUser(ctx, claims.Email)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "could not upsert user"))
|
||||
user := &model.User{
|
||||
Email: claims.Email,
|
||||
}
|
||||
|
||||
authorized, err := auth.Authorize(user)
|
||||
|
@ -85,6 +84,11 @@ func handleLoginCallback(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
user, err = repo.CreateOrConnectUser(ctx, claims.Email)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "could not upsert user"))
|
||||
}
|
||||
|
||||
if err := session.SaveUserEmail(w, r, claims.Email); err != nil {
|
||||
panic(errors.WithStack(err))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue