From 243e123f1b9f048a4518e49ea42fb7664718b64b Mon Sep 17 00:00:00 2001 From: Saranya Jena Date: Fri, 15 Sep 2023 17:22:40 +0530 Subject: [PATCH 1/9] Fixed issue with updating audit fields in recent experiment runs (#4172) * fixed mongo schema decode issue Signed-off-by: Saranya-jena * updated the same in other fields Signed-off-by: Saranya-jena * fixed css Signed-off-by: Saranya-jena --------- Signed-off-by: Saranya-jena Signed-off-by: Tanishq Jain --- .../server/pkg/chaos_experiment/ops/service.go | 12 +++++++++--- .../pkg/chaos_experiment_run/handler/handler.go | 6 ++++-- .../server/pkg/chaos_experiment_run/service.go | 6 +++++- .../server/pkg/chaos_infrastructure/service.go | 4 +++- chaoscenter/graphql/server/pkg/chaoshub/service.go | 8 ++++++-- .../server/pkg/database/mongodb/probe/schema.go | 14 +++++++------- .../server/pkg/environment/handler/handler.go | 8 ++++++-- .../graphql/server/pkg/probe/respository.go | 6 ++++-- chaoscenter/web/src/views/Gitops/Gitops.tsx | 2 +- .../web/src/views/ImageRegistry/ImageRegistry.tsx | 2 +- 10 files changed, 46 insertions(+), 22 deletions(-) diff --git a/chaoscenter/graphql/server/pkg/chaos_experiment/ops/service.go b/chaoscenter/graphql/server/pkg/chaos_experiment/ops/service.go index 8ace51f40b2..e8131a7d3ab 100644 --- a/chaoscenter/graphql/server/pkg/chaos_experiment/ops/service.go +++ b/chaoscenter/graphql/server/pkg/chaos_experiment/ops/service.go @@ -251,7 +251,9 @@ func (c *chaosExperimentService) ProcessExperimentUpdate(workflow *model.ChaosEx {"description", workflow.ExperimentDescription}, {"is_custom_experiment", workflow.IsCustomExperiment}, {"updated_at", time.Now().UnixMilli()}, - {"updated_by", username}, + {"updated_by", mongodb.UserDetailResponse{ + Username: username, + }}, }}, {"$push", bson.D{ {"revision", workflowRevision}, @@ -267,7 +269,9 @@ func (c *chaosExperimentService) ProcessExperimentUpdate(workflow *model.ChaosEx update = bson.D{ {"$set", bson.D{ {"updated_at", time.Now().UnixMilli()}, - {"updated_by", username}, + {"updated_by", mongodb.UserDetailResponse{ + Username: username, + }}, {"revision.$.updated_at", time.Now().UnixMilli()}, {"revision.$.experiment_manifest", workflow.ExperimentManifest}, }}, @@ -313,7 +317,9 @@ func (c *chaosExperimentService) ProcessExperimentDelete(query bson.D, workflow update := bson.D{ {"$set", bson.D{ {"is_removed", true}, - {"updated_by", username}, + {"updated_by", mongodb.UserDetailResponse{ + Username: username, + }}, {"updated_at", time.Now().UnixMilli()}, }}, } diff --git a/chaoscenter/graphql/server/pkg/chaos_experiment_run/handler/handler.go b/chaoscenter/graphql/server/pkg/chaos_experiment_run/handler/handler.go index cd8ccb07aaf..50a7bf3c916 100644 --- a/chaoscenter/graphql/server/pkg/chaos_experiment_run/handler/handler.go +++ b/chaoscenter/graphql/server/pkg/chaos_experiment_run/handler/handler.go @@ -1225,7 +1225,9 @@ func (c *ChaosExperimentRunHandler) ChaosExperimentRunEvent(event model.Experime {"recent_experiment_run_details.notify_id", event.NotifyID}, } } - + updatedByModel := mongodb.UserDetailResponse{ + Username: string(updatedBy), + } update := bson.D{ { "$set", bson.D{ @@ -1235,7 +1237,7 @@ func (c *ChaosExperimentRunHandler) ChaosExperimentRunEvent(event model.Experime {"recent_experiment_run_details.$.probes", probes}, {"recent_experiment_run_details.$.resiliency_score", workflowRunMetrics.ResiliencyScore}, {"recent_experiment_run_details.$.updated_at", currentTime.UnixMilli()}, - {"recent_experiment_run_details.$.updated_by", string(updatedBy)}, + {"recent_experiment_run_details.$.updated_by", updatedByModel}, }, }, } diff --git a/chaoscenter/graphql/server/pkg/chaos_experiment_run/service.go b/chaoscenter/graphql/server/pkg/chaos_experiment_run/service.go index 5cb6976b003..cd4a72b4ca3 100644 --- a/chaoscenter/graphql/server/pkg/chaos_experiment_run/service.go +++ b/chaoscenter/graphql/server/pkg/chaos_experiment_run/service.go @@ -7,6 +7,8 @@ import ( "strings" "time" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb" + "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/chaos_infrastructure" dbChaosExperimentRun "github.com/litmuschaos/litmus/chaoscenter/graphql/server/pkg/database/mongodb/chaos_experiment_run" @@ -49,7 +51,9 @@ func (c *chaosExperimentRunService) ProcessExperimentRunDelete(ctx context.Conte {"$set", bson.D{ {"is_removed", experimentRun.IsRemoved}, {"updated_at", time.Now().UnixMilli()}, - {"updated_by", username}, + {"updated_by", mongodb.UserDetailResponse{ + Username: username, + }}, }}, } diff --git a/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go b/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go index 7441c7ce563..ff26764c161 100644 --- a/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go +++ b/chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go @@ -215,7 +215,9 @@ func (in *infraService) DeleteInfra(ctx context.Context, projectID string, infra {"$set", bson.D{ {"is_removed", true}, {"updated_at", time.Now().UnixMilli()}, - {"updated_by", username}, + {"updated_by", mongodb.UserDetailResponse{ + Username: username, + }}, }}, } err = in.infraOperator.UpdateInfra(context.TODO(), query, update) diff --git a/chaoscenter/graphql/server/pkg/chaoshub/service.go b/chaoscenter/graphql/server/pkg/chaoshub/service.go index d26aeafbd15..62239175d8f 100644 --- a/chaoscenter/graphql/server/pkg/chaoshub/service.go +++ b/chaoscenter/graphql/server/pkg/chaoshub/service.go @@ -383,7 +383,9 @@ func (c *chaosHubService) UpdateChaosHub(ctx context.Context, chaosHub model.Upd {"ssh_private_key", chaosHub.SSHPrivateKey}, {"ssh_public_key", chaosHub.SSHPublicKey}, {"updated_at", time}, - {"updated_by", username}, + {"updated_by", mongodb.UserDetailResponse{ + Username: username, + }}, }, }, } @@ -419,7 +421,9 @@ func (c *chaosHubService) DeleteChaosHub(ctx context.Context, hubID string, proj {"$set", bson.D{ {"is_removed", true}, {"updated_at", time.Now().UnixMilli()}, - {"updated_by", username}, + {"updated_by", mongodb.UserDetailResponse{ + Username: username, + }}, }, }, } diff --git a/chaoscenter/graphql/server/pkg/database/mongodb/probe/schema.go b/chaoscenter/graphql/server/pkg/database/mongodb/probe/schema.go index 2aa9e5dc25e..61cdb9bb084 100644 --- a/chaoscenter/graphql/server/pkg/database/mongodb/probe/schema.go +++ b/chaoscenter/graphql/server/pkg/database/mongodb/probe/schema.go @@ -37,13 +37,13 @@ type Probes struct { } type ExecutionHistory struct { - ExperimentID string `bson:"experiment_id"` - ExperimentName string `bson:"experiment_name"` - UpdatedBy string `bson:"updated_by"` - ExecutionData string `bson:"execution_data"` - UpdatedAt int `bson:"updated_at"` - Probes []Probes `bson:"probes"` - Phase model.ExperimentRunStatus `bson:"phase"` + ExperimentID string `bson:"experiment_id"` + ExperimentName string `bson:"experiment_name"` + UpdatedBy mongodb.UserDetailResponse `bson:"updated_by"` + ExecutionData string `bson:"execution_data"` + UpdatedAt int `bson:"updated_at"` + Probes []Probes `bson:"probes"` + Phase model.ExperimentRunStatus `bson:"phase"` } type ProbeWithExecutionHistory struct { diff --git a/chaoscenter/graphql/server/pkg/environment/handler/handler.go b/chaoscenter/graphql/server/pkg/environment/handler/handler.go index 27d50ddc06b..3ae2ee9368f 100644 --- a/chaoscenter/graphql/server/pkg/environment/handler/handler.go +++ b/chaoscenter/graphql/server/pkg/environment/handler/handler.go @@ -114,7 +114,9 @@ func (e *EnvironmentService) UpdateEnvironment(ctx context.Context, projectID st updateQuery = append(updateQuery, bson.E{ Key: "$set", Value: bson.D{ {"updated_at", time.Now().UnixMilli()}, - {"updated_by", username}, + {"updated_by", mongodb.UserDetailResponse{ + Username: username, + }}, }, }) if request.Name != nil { @@ -176,7 +178,9 @@ func (e *EnvironmentService) DeleteEnvironment(ctx context.Context, projectID st {"$set", bson.D{ {"is_removed", true}, {"updated_at", currTime}, - {"updated_by", username}, + {"updated_by", mongodb.UserDetailResponse{ + Username: username, + }}, }}, } err = e.EnvironmentOperator.UpdateEnvironment(context.TODO(), query, update) diff --git a/chaoscenter/graphql/server/pkg/probe/respository.go b/chaoscenter/graphql/server/pkg/probe/respository.go index 1a149269464..bce537605d4 100644 --- a/chaoscenter/graphql/server/pkg/probe/respository.go +++ b/chaoscenter/graphql/server/pkg/probe/respository.go @@ -741,7 +741,9 @@ func (p *probe) DeleteProbe(ctx context.Context, probeName string) (bool, error) {"$set", bson.D{ {"is_removed", true}, {"updated_at", Time}, - {"updated_by", username}, + {"updated_by", mongodb.UserDetailResponse{ + Username: username, + }}, }}, } @@ -884,7 +886,7 @@ func (p *probe) GetProbeReference(ctx context.Context, probeName string) (*model ExperimentName: runs.ExperimentName, UpdatedAt: runs.UpdatedAt, UpdatedBy: &model.UserDetails{ - Username: runs.UpdatedBy, + Username: runs.UpdatedBy.Username, }, }, }) diff --git a/chaoscenter/web/src/views/Gitops/Gitops.tsx b/chaoscenter/web/src/views/Gitops/Gitops.tsx index 928d9f0a4b7..7be5be1f010 100644 --- a/chaoscenter/web/src/views/Gitops/Gitops.tsx +++ b/chaoscenter/web/src/views/Gitops/Gitops.tsx @@ -132,7 +132,7 @@ export default function GitopsView({ return ( + + Date: Fri, 15 Sep 2023 18:35:46 +0530 Subject: [PATCH 2/9] fix: Fixed teaming page UI Issues (#4173) Signed-off-by: Hrishav Signed-off-by: Tanishq Jain --- chaoscenter/web/src/strings/strings.en.yaml | 4 ++ chaoscenter/web/src/strings/types.ts | 4 ++ .../InviteNewMemberListColumns.tsx | 18 +++---- .../InviteNewMemberTable.module.scss | 30 ++++++++++++ .../InviteNewMemberTable.module.scss.d.ts | 1 + .../InviteNewMembers/InviteNewMembers.tsx | 24 +++++---- .../InviteNewMembers/InviteUsersTable.tsx | 49 +++++++++++-------- .../ProjectMembers/PendingMembersTable.tsx | 48 +++++++++++------- .../ProjectMembers/ProjectMember.module.scss | 31 ++++++++++++ .../ProjectMember.module.scss.d.ts | 1 + 10 files changed, 152 insertions(+), 58 deletions(-) diff --git a/chaoscenter/web/src/strings/strings.en.yaml b/chaoscenter/web/src/strings/strings.en.yaml index c9fdc0299b4..77586cacbc5 100644 --- a/chaoscenter/web/src/strings/strings.en.yaml +++ b/chaoscenter/web/src/strings/strings.en.yaml @@ -124,6 +124,7 @@ checkStatus: Check the status of your Chaos Infrastructure on your cluster chooseAccessType: Choose Access Type chooseAuthenticationType: Choose Authentication Type chooseHubAccess: Choose Hub Access +chooseMembersAddTheProject: Choose members to add to the project chooseProbeMode: Choose Mode for probe to be executed clickDownload: >- Click on the “Download” button below to download the YML file to a machine @@ -294,6 +295,7 @@ editSameExperimentDescription: >- editSameExperimentTitle: Edit on the existing Experiment editYaml: Edit Yaml editingChaosHub: Editing ChaosHub +editor: Editor effect: Effect email: Email emailIsRequired: Email is a required field @@ -1064,6 +1066,7 @@ totalChaosInfrastructures: Total Infrastructures totalEnvironments: Total Environments totalExp: Total Experiments totalExperiments: Total Faults in Execution +totalPendingInvitations: Total Pending Invitations totalRuns: Total Runs totalUsers: Total Users triggeredBy: Triggered by @@ -1121,6 +1124,7 @@ viewManifest: View YAML Manifest viewProbeDetails: View Probe Details viewProbeProperties: View Probe Properties viewRun: View Run +viewer: Viewer warning: Warning weekly: Weekly weeklyMessage: Your chaos experiment will run weekly at your chosen day and time. diff --git a/chaoscenter/web/src/strings/types.ts b/chaoscenter/web/src/strings/types.ts index bd45af1161b..b921ca172a2 100644 --- a/chaoscenter/web/src/strings/types.ts +++ b/chaoscenter/web/src/strings/types.ts @@ -119,6 +119,7 @@ export interface StringsMap { 'chooseAccessType': unknown 'chooseAuthenticationType': unknown 'chooseHubAccess': unknown + 'chooseMembersAddTheProject': unknown 'chooseProbeMode': unknown 'clickDownload': unknown 'clone': unknown @@ -247,6 +248,7 @@ export interface StringsMap { 'editSameExperimentTitle': unknown 'editYaml': unknown 'editingChaosHub': unknown + 'editor': unknown 'effect': unknown 'email': unknown 'emailIsRequired': unknown @@ -896,6 +898,7 @@ export interface StringsMap { 'totalEnvironments': unknown 'totalExp': unknown 'totalExperiments': unknown + 'totalPendingInvitations': unknown 'totalRuns': unknown 'totalUsers': unknown 'triggeredBy': unknown @@ -951,6 +954,7 @@ export interface StringsMap { 'viewProbeDetails': unknown 'viewProbeProperties': unknown 'viewRun': unknown + 'viewer': unknown 'warning': unknown 'weekly': unknown 'weeklyMessage': unknown diff --git a/chaoscenter/web/src/views/InviteNewMembers/InviteNewMemberListColumns.tsx b/chaoscenter/web/src/views/InviteNewMembers/InviteNewMemberListColumns.tsx index a10d8ef7121..61eedf99935 100644 --- a/chaoscenter/web/src/views/InviteNewMembers/InviteNewMemberListColumns.tsx +++ b/chaoscenter/web/src/views/InviteNewMembers/InviteNewMemberListColumns.tsx @@ -1,7 +1,7 @@ import { Layout, Text } from '@harnessio/uicore'; import type { Row } from 'react-table'; import React from 'react'; -import { Color } from '@harnessio/design-system'; +import { Color, FontVariation } from '@harnessio/design-system'; import { useStrings } from '@strings'; import type { InviteUserDetails } from '@controllers/InviteNewMembers/types'; @@ -13,13 +13,15 @@ const UserName = ({ row: { original: data } }: MemberRow): React.ReactElement => const { username, userID, name } = data; const { getString } = useStrings(); return ( - - {name ?? username} + + + {name ?? username} + {getString('id')}: - + {userID} @@ -30,11 +32,9 @@ const UserName = ({ row: { original: data } }: MemberRow): React.ReactElement => const UserEmail = ({ row: { original: data } }: MemberRow): React.ReactElement => { const { email } = data; return ( - - - {email} - - + + {email} + ); }; diff --git a/chaoscenter/web/src/views/InviteNewMembers/InviteNewMemberTable.module.scss b/chaoscenter/web/src/views/InviteNewMembers/InviteNewMemberTable.module.scss index 1d138e6adbb..704058cfa22 100644 --- a/chaoscenter/web/src/views/InviteNewMembers/InviteNewMemberTable.module.scss +++ b/chaoscenter/web/src/views/InviteNewMembers/InviteNewMemberTable.module.scss @@ -1,3 +1,33 @@ .inviteTable { width: 100%; } + +.tableContainer { + width: 100%; + [role='cell'], + [role='columnheader'] { + width: auto !important; + } + div[class*='TableV2--body'] { + overflow-y: scroll; + height: 400px; + display: flex; + flex-direction: column; + gap: 1rem; + } + div[class*='TableV2--row TableV2--card'] { + margin-bottom: 0 !important; + } + div[class*='TableV2--row TableV2--card'] { + border-radius: 6px !important; + &:hover { + background-color: white !important; + } + } + div[class*='TableV2--header'], + div[class*='TableV2--cells'] { + display: grid !important; + grid-template-columns: 1.5fr 1fr 200px; + gap: 1rem; + } +} diff --git a/chaoscenter/web/src/views/InviteNewMembers/InviteNewMemberTable.module.scss.d.ts b/chaoscenter/web/src/views/InviteNewMembers/InviteNewMemberTable.module.scss.d.ts index fe5265b4a76..8040b520a9d 100644 --- a/chaoscenter/web/src/views/InviteNewMembers/InviteNewMemberTable.module.scss.d.ts +++ b/chaoscenter/web/src/views/InviteNewMembers/InviteNewMemberTable.module.scss.d.ts @@ -1,6 +1,7 @@ declare namespace InviteNewMemberTableModuleScssNamespace { export interface IInviteNewMemberTableModuleScss { inviteTable: string; + tableContainer: string; } } diff --git a/chaoscenter/web/src/views/InviteNewMembers/InviteNewMembers.tsx b/chaoscenter/web/src/views/InviteNewMembers/InviteNewMembers.tsx index a6de91a1c07..e76b043dec1 100644 --- a/chaoscenter/web/src/views/InviteNewMembers/InviteNewMembers.tsx +++ b/chaoscenter/web/src/views/InviteNewMembers/InviteNewMembers.tsx @@ -21,14 +21,18 @@ interface InviteNewMembersViewProps { export default function InviteNewMembersView(props: InviteNewMembersViewProps): React.ReactElement { const { isLoading, data, handleClose, getUsers, searchInput } = props; const { getString } = useStrings(); + return ( - Choose members to add to the project + {getString('chooseMembersAddTheProject')} handleClose()} /> {searchInput} - + - -