Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: customize nav bar background color #7387

Merged
merged 6 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions api/jsonschema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5454,6 +5454,9 @@
},
"title": "which modals to show",
"type": "object"
},
"navColor": {
"type": "string"
}
},
"type": "object"
Expand Down
3 changes: 3 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -9717,6 +9717,9 @@
"additionalProperties": {
"type": "boolean"
}
},
"navColor": {
"type": "string"
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ type Config struct {
Images map[string]Image `json:"images,omitempty"`

RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"`

// NavColor is an ui navigation bar background color
NavColor string `json:"navColor,omitempty"`
}

func (c Config) GetContainerRuntimeExecutor(labels labels.Labels) (string, error) {
Expand Down
5 changes: 4 additions & 1 deletion docs/workflow-controller-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ data:
nodeEvents: |
enabled: true

# uncomment flowing lines if workflow controller runs in a different k8s cluster with the
# uncomment following lines if workflow controller runs in a different k8s cluster with the
# workflow workloads, or needs to communicate with the k8s apiserver using an out-of-cluster
# kubeconfig secret
# kubeConfig:
Expand Down Expand Up @@ -74,6 +74,9 @@ data:
scope: chat
url: http://my-chat

# uncomment following lines if you want to change navigation bar background color
# navColor: red

# artifactRepository defines the default location to be used as the artifact repository for
# container artifacts.
artifactRepository: |
Expand Down
126 changes: 89 additions & 37 deletions pkg/apiclient/info/info.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/apiclient/info/info.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ message InfoResponse {
repeated github.com.argoproj.argo_workflows.v3.pkg.apis.workflow.v1alpha1.Link links = 2;
// which modals to show
map<string,bool> modals = 3;
string navColor = 4;
}

message GetVersionRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Name | Type | Description | Notes
**links** | [**List&lt;IoArgoprojWorkflowV1alpha1Link&gt;**](IoArgoprojWorkflowV1alpha1Link.md) | | [optional]
**managedNamespace** | **String** | | [optional]
**modals** | **Map&lt;String, Boolean&gt;** | | [optional]
**navColor** | **String** | | [optional]



Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions server/apiserver/argoserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (as *argoServer) Run(ctx context.Context, port int, browserOpenFunc func(st
artifactRepositories := artifactrepositories.New(as.clients.Kubernetes, as.managedNamespace, &config.ArtifactRepository)
artifactServer := artifacts.NewArtifactServer(as.gatekeeper, hydrator.New(offloadRepo), wfArchive, instanceIDService, artifactRepositories)
eventServer := event.NewController(instanceIDService, eventRecorderManager, as.eventQueueSize, as.eventWorkerCount, as.eventAsyncDispatch)
grpcServer := as.newGRPCServer(instanceIDService, offloadRepo, wfArchive, eventServer, config.Links)
grpcServer := as.newGRPCServer(instanceIDService, offloadRepo, wfArchive, eventServer, config.Links, config.NavColor)
httpServer := as.newHTTPServer(ctx, port, artifactServer)

// Start listener
Expand Down Expand Up @@ -247,7 +247,7 @@ func (as *argoServer) Run(ctx context.Context, port int, browserOpenFunc func(st
<-as.stopCh
}

func (as *argoServer) newGRPCServer(instanceIDService instanceid.Service, offloadNodeStatusRepo sqldb.OffloadNodeStatusRepo, wfArchive sqldb.WorkflowArchive, eventServer *event.Controller, links []*v1alpha1.Link) *grpc.Server {
func (as *argoServer) newGRPCServer(instanceIDService instanceid.Service, offloadNodeStatusRepo sqldb.OffloadNodeStatusRepo, wfArchive sqldb.WorkflowArchive, eventServer *event.Controller, links []*v1alpha1.Link, navColor string) *grpc.Server {
serverLog := log.NewEntry(log.StandardLogger())

// "Prometheus histograms are a great way to measure latency distributions of your RPCs. However, since it is bad practice to have metrics of high cardinality the latency monitoring metrics are disabled by default. To enable them please call the following in your server initialization code:"
Expand Down Expand Up @@ -278,7 +278,7 @@ func (as *argoServer) newGRPCServer(instanceIDService instanceid.Service, offloa

grpcServer := grpc.NewServer(sOpts...)

infopkg.RegisterInfoServiceServer(grpcServer, info.NewInfoServer(as.managedNamespace, links))
infopkg.RegisterInfoServiceServer(grpcServer, info.NewInfoServer(as.managedNamespace, links, navColor))
eventpkg.RegisterEventServiceServer(grpcServer, eventServer)
eventsourcepkg.RegisterEventSourceServiceServer(grpcServer, eventsource.NewEventSourceServer())
pipelinepkg.RegisterPipelineServiceServer(grpcServer, pipeline.NewPipelineServer())
Expand Down
6 changes: 4 additions & 2 deletions server/info/info_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
type infoServer struct {
managedNamespace string
links []*wfv1.Link
navColor string
}

func (i *infoServer) GetUserInfo(ctx context.Context, _ *infopkg.GetUserInfoRequest) (*infopkg.GetUserInfoResponse, error) {
Expand Down Expand Up @@ -40,6 +41,7 @@ func (i *infoServer) GetInfo(context.Context, *infopkg.GetInfoRequest) (*infopkg
ManagedNamespace: i.managedNamespace,
Links: i.links,
Modals: modals,
NavColor: i.navColor,
}, nil
}

Expand All @@ -48,6 +50,6 @@ func (i *infoServer) GetVersion(context.Context, *infopkg.GetVersionRequest) (*w
return &version, nil
}

func NewInfoServer(managedNamespace string, links []*wfv1.Link) infopkg.InfoServiceServer {
return &infoServer{managedNamespace, links}
func NewInfoServer(managedNamespace string, links []*wfv1.Link, navColor string) infopkg.InfoServiceServer {
return &infoServer{managedNamespace, links, navColor}
}
29 changes: 29 additions & 0 deletions server/info/info_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/assert"
"gopkg.in/square/go-jose.v2/jwt"

wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo-workflows/v3/server/auth"
"github.com/argoproj/argo-workflows/v3/server/auth/types"
)
Expand All @@ -24,3 +25,31 @@ func Test_infoServer_GetUserInfo(t *testing.T) {
assert.Equal(t, "my-sa", info.ServiceAccountName)
}
}

func Test_infoServer_GetInfo(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

t.Run("Ful Fields", func(t *testing.T) {
i := &infoServer{
managedNamespace: "argo",
links: []*wfv1.Link{
{Name: "link-name", Scope: "scope", URL: "https://example.com"},
},
navColor: "red",
}
info, err := i.GetInfo(context.TODO(), nil)
if assert.NoError(t, err) {
assert.Equal(t, "argo", info.ManagedNamespace)
assert.Equal(t, "link-name", info.Links[0].Name)
assert.Equal(t, "red", info.NavColor)
}
})

t.Run("Min Fields", func(t *testing.T) {
i := &infoServer{}
info, err := i.GetInfo(context.TODO(), nil)
if assert.NoError(t, err) {
assert.Equal(t, "", info.ManagedNamespace)
assert.Equal(t, 0, len(info.Links))
assert.Equal(t, "", info.NavColor)
}
})
}
3 changes: 3 additions & 0 deletions ui/src/app/app-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const AppRouter = ({popupManager, history, notificationsManager}: {popupM
const [modals, setModals] = useState<{string: boolean}>();
const [version, setVersion] = useState<Version>();
const [namespace, setNamespace] = useState<string>();
const [navBarBackgroundColor, setNavBarBackgroundColor] = useState<string>();
const setError = (error: Error) => {
notificationsManager.show({
content: 'Failed to load version/info ' + error,
Expand All @@ -68,6 +69,7 @@ export const AppRouter = ({popupManager, history, notificationsManager}: {popupM
Utils.managedNamespace = info.managedNamespace;
setNamespace(Utils.currentNamespace);
setModals(info.modals);
setNavBarBackgroundColor(info.navColor);
})
.then(() => services.info.getVersion())
.then(setVersion)
Expand All @@ -82,6 +84,7 @@ export const AppRouter = ({popupManager, history, notificationsManager}: {popupM
<Switch>
<Route path={uiUrl('widgets')} component={Widgets} />
<Layout
navBarStyle={{backgroundColor: navBarBackgroundColor}}
navItems={[
{
title: 'Workflows',
Expand Down
1 change: 1 addition & 0 deletions ui/src/models/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface Info {
modals: {string: boolean};
managedNamespace?: string;
links?: Link[];
navColor?: string;
}

export interface Version {
Expand Down