Skip to content

Commit

Permalink
Merge pull request #903 from traPtitech/display-version
Browse files Browse the repository at this point in the history
Display version from UI
  • Loading branch information
motoki317 committed Apr 24, 2024
2 parents 20ae031 + 9de0e89 commit 783c802
Show file tree
Hide file tree
Showing 9 changed files with 900 additions and 843 deletions.
4 changes: 4 additions & 0 deletions api/proto/neoshowcase/protobuf/gateway.proto
Expand Up @@ -40,6 +40,10 @@ message SystemInfo {
repeated AvailablePort ports = 4;
// adminer_url ユーザー用DB管理画面URL
string adminer_url = 5;
// version NeoShowcase version
string version = 6;
// revision NeoShowcase version
string revision = 7;
}

// -- User
Expand Down
18 changes: 17 additions & 1 deletion dashboard/src/api/neoshowcase/protobuf/gateway_pb.ts
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts"
// @generated from file neoshowcase/protobuf/gateway.proto (package neoshowcase.protobuf, syntax proto3)
/* eslint-disable */
// @ts-nocheck
Expand Down Expand Up @@ -305,6 +305,20 @@ export class SystemInfo extends Message<SystemInfo> {
*/
adminerUrl = "";

/**
* version NeoShowcase version
*
* @generated from field: string version = 6;
*/
version = "";

/**
* revision NeoShowcase version
*
* @generated from field: string revision = 7;
*/
revision = "";

constructor(data?: PartialMessage<SystemInfo>) {
super();
proto3.util.initPartial(data, this);
Expand All @@ -318,6 +332,8 @@ export class SystemInfo extends Message<SystemInfo> {
{ no: 3, name: "domains", kind: "message", T: AvailableDomain, repeated: true },
{ no: 4, name: "ports", kind: "message", T: AvailablePort, repeated: true },
{ no: 5, name: "adminer_url", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 6, name: "version", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 7, name: "revision", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): SystemInfo {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/api/neoshowcase/protobuf/null_pb.ts
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts"
// @generated from file neoshowcase/protobuf/null.proto (package neoshowcase.protobuf, syntax proto3)
/* eslint-disable */
// @ts-nocheck
Expand Down
48 changes: 25 additions & 23 deletions dashboard/src/components/UI/UserMenuButton.tsx
Expand Up @@ -4,6 +4,7 @@ import { styled } from '@macaron-css/solid'
import { A } from '@solidjs/router'
import type { Component } from 'solid-js'
import type { User } from '/@/api/neoshowcase/protobuf/gateway_pb'
import { systemInfo } from '/@/libs/api'
import { colorVars, media, textVars } from '/@/theme'
import { Button } from './Button'
import { MaterialSymbols } from './MaterialSymbols'
Expand Down Expand Up @@ -32,6 +33,7 @@ const triggerStyle = style({
},
},
})

const UserName = styled('span', {
base: {
color: colorVars.semantic.text.black,
Expand All @@ -44,6 +46,7 @@ const UserName = styled('span', {
},
},
})

const iconStyle = style({
width: '24px',
height: '24px',
Expand All @@ -54,14 +57,17 @@ const iconStyle = style({
},
},
})

const contentShowKeyframes = keyframes({
from: { opacity: 0, transform: 'translateY(-8px)' },
to: { opacity: 1, transform: 'translateY(0)' },
})

const contentHideKeyframes = keyframes({
from: { opacity: 1, transform: 'translateY(0)' },
to: { opacity: 0, transform: 'translateY(-8px)' },
})

const contentStyle = style({
padding: '6px',
display: 'flex',
Expand All @@ -81,6 +87,17 @@ const contentStyle = style({
},
})

const VersionContainer = styled('div', {
base: {
display: 'flex',
flexDirection: 'column',
padding: '4px 16px',

color: colorVars.semantic.text.grey,
...textVars.caption.regular,
},
})

export const UserMenuButton: Component<{
user: User
}> = (props) => {
Expand Down Expand Up @@ -109,31 +126,16 @@ export const UserMenuButton: Component<{
</Button>
</a>
</DropdownMenu.Item>
<DropdownMenu.Item>
<VersionContainer>
<span>NeoShowcase</span>
<span>
{systemInfo()?.version} ({systemInfo()?.revision})
</span>
</VersionContainer>
</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu.Portal>
</DropdownMenu.Root>
)
// <Trigger onClick={() => setShowOptions((s) => !s)}>
// <UserAvatar user={props.user} size={32} />
// <UserName>{props.user.name}</UserName>
// <MaterialSymbols>arrow_drop_down</MaterialSymbols>
// <Show when={showOptions()}>
// <div
// use:clickInside={() => setShowOptions(true)}
// use:clickOutside={() => setShowOptions(false)}
// class={optionsContainerClass}
// >
// <A href="/settings">
// <Button variants="text" size="medium" leftIcon={<MaterialSymbols>settings</MaterialSymbols>} full>
// Settings
// </Button>
// </A>
// <a href="https://wiki.trap.jp/services/NeoShowcase" target="_blank" rel="noopener noreferrer">
// <Button variants="text" size="medium" leftIcon={<MaterialSymbols>help</MaterialSymbols>} full>
// Help
// </Button>
// </a>
// </div>
// </Show>
// </Trigger>
}
3 changes: 3 additions & 0 deletions dashboard/src/components/templates/Header.tsx
Expand Up @@ -23,6 +23,7 @@ const Container = styled('div', {
borderBottom: `1px solid ${colorVars.semantic.ui.border}`,
},
})

const NavigationContainer = styled('div', {
base: {
display: 'flex',
Expand All @@ -36,6 +37,7 @@ const NavigationContainer = styled('div', {
},
},
})

const MobileNavigationContainer = styled('div', {
base: {
display: 'none',
Expand All @@ -48,6 +50,7 @@ const MobileNavigationContainer = styled('div', {
},
},
})

const UserMenuButtonContainer = styled('div', {
base: {
marginLeft: 'auto',
Expand Down
2 changes: 2 additions & 0 deletions pkg/domain/component.go
Expand Up @@ -20,6 +20,8 @@ type SystemInfo struct {
AvailableDomains AvailableDomainSlice
AvailablePorts AvailablePortSlice
AdminerURL string
Version string
Revision string
}

type ControllerServiceClient interface {
Expand Down
4 changes: 4 additions & 0 deletions pkg/infrastructure/grpc/controller_service.go
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/traPtitech/neoshowcase/pkg/usecase/cdservice"
"github.com/traPtitech/neoshowcase/pkg/usecase/logstream"
"github.com/traPtitech/neoshowcase/pkg/usecase/repofetcher"
"github.com/traPtitech/neoshowcase/pkg/util/cli"
"github.com/traPtitech/neoshowcase/pkg/util/ds"
)

Expand Down Expand Up @@ -65,6 +66,7 @@ func (s *ControllerService) GetSystemInfo(_ context.Context, _ *connect.Request[
}

ports := s.backend.AvailablePorts()
ver, rev := cli.GetVersion()

res := connect.NewResponse(&pb.SystemInfo{
PublicKey: domain.Base64EncodedPublicKey(s.pubKey.Signer.PublicKey()) + " neoshowcase",
Expand All @@ -75,6 +77,8 @@ func (s *ControllerService) GetSystemInfo(_ context.Context, _ *connect.Request[
Domains: ds.Map(domains, pbconvert.ToPBAvailableDomain),
Ports: ds.Map(ports, pbconvert.ToPBAvailablePort),
AdminerUrl: s.adminerURL,
Version: ver,
Revision: rev,
})
return res, nil
}
Expand Down

0 comments on commit 783c802

Please sign in to comment.