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

Fix version indicator issues 2 #809

Merged
merged 3 commits into from
Jan 28, 2024
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
6 changes: 3 additions & 3 deletions server/src/app/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable, Logger } from '@nestjs/common';
import { ExternalApiService } from 'src/modules/api/external-api/external-api.service';
import { ExternalApiService } from '../modules/api/external-api/external-api.service';

interface VersionResponse {
status: 1 | 0;
Expand Down Expand Up @@ -27,9 +27,9 @@ export class AppService {
const calculatedVersion =
versionTag !== 'stable'
? process.env.GIT_SHA
? `${versionTag}-${process.env.GIT_SHA}`
? `${versionTag}-${process.env.GIT_SHA.substring(0, 7)}`
: `${versionTag}-`
: `${versionTag}-${packageVersion}`;
: `${packageVersion}`;

const local = process.env.NODE_ENV !== 'production';

Expand Down
82 changes: 44 additions & 38 deletions ui/src/components/VersionStatus/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@ interface VersionStatusProps {
}

const VersionStatus = ({ onClick }: VersionStatusProps) => {
const [version, setVersion] = useState<string>('1.7.1')
const [version, setVersion] = useState<string>('0.0.1')
const [commitTag, setCommitTag] = useState<string>('')
const [updateAvailable, setUpdateAvailable] = useState<boolean>(false)
const [loading, setLoading] = useState<boolean>(true)

useEffect(() => {
GetApiHandler('/app/status').then((resp: VersionResponse) => {
if (resp.status) {
setVersion(resp.version)
setCommitTag(resp.commitTag)
setUpdateAvailable(resp.updateAvailable)
setLoading(false)
}
})
}, [])
Expand All @@ -48,46 +50,50 @@ const VersionStatus = ({ onClick }: VersionStatusProps) => {
: messages.STABLE

return (
<Link
href="https://github.com/jorenn92/Maintainerr/releases"
target="_blank"
onClick={onClick}
onKeyDown={(e) => {
if (e.key === 'Enter' && onClick) {
onClick()
}
}}
role="button"
tabIndex={0}
className={`mx-2 flex items-center rounded-lg p-2 text-xs ring-1 ring-zinc-700 transition duration-300 ${
updateAvailable
? 'bg-amber-800 text-white hover:bg-amber-600'
: 'bg-zinc-900 text-zinc-300 hover:bg-zinc-800'
}`}
>
{commitTag === 'local' ? (
<CodeIcon className="h-6 w-6" />
) : version.startsWith('develop-') ? (
<BeakerIcon className="h-6 w-6" />
) : (
<ServerIcon className="h-6 w-6" />
)}
<div className="flex min-w-0 flex-1 flex-col truncate px-2 last:pr-0">
<span className="font-bold">{versionStream}</span>
<span className="truncate">
<>
{!loading ? (
<Link
href="https://github.com/jorenn92/Maintainerr/releases"
target="_blank"
onClick={onClick}
onKeyDown={(e) => {
if (e.key === 'Enter' && onClick) {
onClick()
}
}}
role="button"
tabIndex={0}
className={`mx-2 flex items-center rounded-lg p-2 text-xs ring-1 ring-zinc-700 transition duration-300 ${
updateAvailable
? 'bg-amber-800 text-white hover:bg-amber-600'
: 'bg-zinc-900 text-zinc-300 hover:bg-zinc-800'
}`}
>
{commitTag === 'local' ? (
''
) : updateAvailable ? (
messages.OUT_OF_DATE
<CodeIcon className="h-6 w-6" />
) : version.startsWith('develop-') ? (
<BeakerIcon className="h-6 w-6" />
) : (
<code className="bg-transparent p-0">
{version.replace('develop-', '')}
</code>
<ServerIcon className="h-6 w-6" />
)}
</span>
</div>
{updateAvailable && <ArrowCircleUpIcon className="h-6 w-6" />}
</Link>
<div className="flex min-w-0 flex-1 flex-col truncate px-2 last:pr-0">
<span className="font-bold">{versionStream}</span>
<span className="truncate">
{commitTag === 'local' ? (
''
) : updateAvailable ? (
messages.OUT_OF_DATE
) : (
<code className="bg-transparent p-0">
{version.replace('develop-', '')}
</code>
)}
</span>
</div>
{updateAvailable && <ArrowCircleUpIcon className="h-6 w-6" />}
</Link>
) : undefined}
</>
)
}

Expand Down
Loading