mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Add check version functionality (#296)
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Table, Spinner } from "react-bootstrap";
|
import { Button, Table, Spinner } from "react-bootstrap";
|
||||||
import { StashService } from "src/core/StashService";
|
import { StashService } from "src/core/StashService";
|
||||||
|
|
||||||
export const SettingsAboutPanel: React.FC = () => {
|
export const SettingsAboutPanel: React.FC = () => {
|
||||||
const { data, error, loading } = StashService.useVersion();
|
const { data, error, loading } = StashService.useVersion();
|
||||||
|
const { data: dataLatest, error: errorLatest, loading: loadingLatest, refetch, networkStatus } = StashService.useLatestVersion();
|
||||||
|
|
||||||
function maybeRenderTag() {
|
function maybeRenderTag() {
|
||||||
if (!data || !data.version || !data.version.version) {
|
if (!data || !data.version || !data.version.version) {
|
||||||
@@ -17,6 +18,44 @@ export const SettingsAboutPanel: React.FC = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function maybeRenderLatestVersion() {
|
||||||
|
if (!dataLatest || !dataLatest.latestversion || !dataLatest.latestversion.shorthash || !dataLatest.latestversion.url) { return; }
|
||||||
|
if (!data || !data.version || !data.version.hash) {
|
||||||
|
return (
|
||||||
|
<>{dataLatest.latestversion.shorthash}</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.version.hash !== dataLatest.latestversion.shorthash) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<strong>{dataLatest.latestversion.shorthash} [NEW] </strong><a href={dataLatest.latestversion.url}>Download</a>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>{dataLatest.latestversion.shorthash}</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderLatestVersion() {
|
||||||
|
if (!data || !data.version || !data.version.version) { return; } //if there is no "version" latest version check is obviously not supported
|
||||||
|
return (
|
||||||
|
<Table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Latest Version Build Hash: </td>
|
||||||
|
<td>{maybeRenderLatestVersion()} </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><Button onClick={() => refetch()}>Check for new version</Button></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</Table>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function renderVersion() {
|
function renderVersion() {
|
||||||
if (!data || !data.version) {
|
if (!data || !data.version) {
|
||||||
return;
|
return;
|
||||||
@@ -43,8 +82,10 @@ export const SettingsAboutPanel: React.FC = () => {
|
|||||||
<>
|
<>
|
||||||
<h4>About</h4>
|
<h4>About</h4>
|
||||||
{!data || loading ? <Spinner animation="border" variant="light" /> : ""}
|
{!data || loading ? <Spinner animation="border" variant="light" /> : ""}
|
||||||
{error ? <span>error.message</span> : ""}
|
{!!error ? <span>{error.message}</span> : undefined}
|
||||||
|
{!!errorLatest ? <span>{errorLatest.message}</span> : undefined}
|
||||||
{renderVersion()}
|
{renderVersion()}
|
||||||
|
{!dataLatest || loadingLatest || networkStatus === 4 ? <Spinner animation="border" variant="light" /> : <>{renderLatestVersion()}</>}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -275,6 +275,8 @@ export class StashService {
|
|||||||
public static useVersion() {
|
public static useVersion() {
|
||||||
return GQL.useVersionQuery();
|
return GQL.useVersionQuery();
|
||||||
}
|
}
|
||||||
|
public static useLatestVersion() { return GQL.useLatestVersionQuery({ notifyOnNetworkStatusChange: true, errorPolicy: 'ignore' }); }
|
||||||
|
|
||||||
|
|
||||||
public static useConfiguration() {
|
public static useConfiguration() {
|
||||||
return GQL.useConfigurationQuery();
|
return GQL.useConfigurationQuery();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import * as ApolloReactHooks from '@apollo/react-hooks';
|
|||||||
export type Maybe<T> = T | null;
|
export type Maybe<T> = T | null;
|
||||||
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||||
|
|
||||||
// Generated in 2020-01-21T19:57:40+01:00
|
// Generated in 2020-01-23T14:20:33+01:00
|
||||||
|
|
||||||
/** All built-in and custom scalars, mapped to their actual values */
|
/** All built-in and custom scalars, mapped to their actual values */
|
||||||
export type Scalars = {
|
export type Scalars = {
|
||||||
@@ -548,6 +548,8 @@ export type Query = {
|
|||||||
allTags: Array<Tag>,
|
allTags: Array<Tag>,
|
||||||
/** Version */
|
/** Version */
|
||||||
version: Version,
|
version: Version,
|
||||||
|
/** LatestVersion */
|
||||||
|
latestversion: ShortVersion,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -788,6 +790,8 @@ export type SceneFilterType = {
|
|||||||
rating?: Maybe<IntCriterionInput>,
|
rating?: Maybe<IntCriterionInput>,
|
||||||
/** Filter by resolution */
|
/** Filter by resolution */
|
||||||
resolution?: Maybe<ResolutionEnum>,
|
resolution?: Maybe<ResolutionEnum>,
|
||||||
|
/** Filter by duration (in seconds) */
|
||||||
|
duration?: Maybe<IntCriterionInput>,
|
||||||
/** Filter to only include scenes which have markers. `true` or `false` */
|
/** Filter to only include scenes which have markers. `true` or `false` */
|
||||||
has_markers?: Maybe<Scalars['String']>,
|
has_markers?: Maybe<Scalars['String']>,
|
||||||
/** Filter to only include scenes missing this property */
|
/** Filter to only include scenes missing this property */
|
||||||
@@ -1012,6 +1016,12 @@ export enum ScrapeType {
|
|||||||
Url = 'URL'
|
Url = 'URL'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ShortVersion = {
|
||||||
|
__typename?: 'ShortVersion',
|
||||||
|
shorthash: Scalars['String'],
|
||||||
|
url: Scalars['String'],
|
||||||
|
};
|
||||||
|
|
||||||
export enum SortDirectionEnum {
|
export enum SortDirectionEnum {
|
||||||
Asc = 'ASC',
|
Asc = 'ASC',
|
||||||
Desc = 'DESC'
|
Desc = 'DESC'
|
||||||
@@ -1739,6 +1749,17 @@ export type VersionQuery = (
|
|||||||
) }
|
) }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export type LatestVersionQueryVariables = {};
|
||||||
|
|
||||||
|
|
||||||
|
export type LatestVersionQuery = (
|
||||||
|
{ __typename?: 'Query' }
|
||||||
|
& { latestversion: (
|
||||||
|
{ __typename?: 'ShortVersion' }
|
||||||
|
& Pick<ShortVersion, 'shorthash' | 'url'>
|
||||||
|
) }
|
||||||
|
);
|
||||||
|
|
||||||
export type FindPerformersQueryVariables = {
|
export type FindPerformersQueryVariables = {
|
||||||
filter?: Maybe<FindFilterType>,
|
filter?: Maybe<FindFilterType>,
|
||||||
performer_filter?: Maybe<PerformerFilterType>
|
performer_filter?: Maybe<PerformerFilterType>
|
||||||
@@ -3750,6 +3771,45 @@ export function useVersionLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHook
|
|||||||
export type VersionQueryHookResult = ReturnType<typeof useVersionQuery>;
|
export type VersionQueryHookResult = ReturnType<typeof useVersionQuery>;
|
||||||
export type VersionLazyQueryHookResult = ReturnType<typeof useVersionLazyQuery>;
|
export type VersionLazyQueryHookResult = ReturnType<typeof useVersionLazyQuery>;
|
||||||
export type VersionQueryResult = ApolloReactCommon.QueryResult<VersionQuery, VersionQueryVariables>;
|
export type VersionQueryResult = ApolloReactCommon.QueryResult<VersionQuery, VersionQueryVariables>;
|
||||||
|
export const LatestVersionDocument = gql`
|
||||||
|
query LatestVersion {
|
||||||
|
latestversion {
|
||||||
|
shorthash
|
||||||
|
url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
export type LatestVersionComponentProps = Omit<ApolloReactComponents.QueryComponentOptions<LatestVersionQuery, LatestVersionQueryVariables>, 'query'>;
|
||||||
|
|
||||||
|
export const LatestVersionComponent = (props: LatestVersionComponentProps) => (
|
||||||
|
<ApolloReactComponents.Query<LatestVersionQuery, LatestVersionQueryVariables> query={LatestVersionDocument} {...props} />
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __useLatestVersionQuery__
|
||||||
|
*
|
||||||
|
* To run a query within a React component, call `useLatestVersionQuery` and pass it any options that fit your needs.
|
||||||
|
* When your component renders, `useLatestVersionQuery` returns an object from Apollo Client that contains loading, error, and data properties
|
||||||
|
* you can use to render your UI.
|
||||||
|
*
|
||||||
|
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { data, loading, error } = useLatestVersionQuery({
|
||||||
|
* variables: {
|
||||||
|
* },
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
export function useLatestVersionQuery(baseOptions?: ApolloReactHooks.QueryHookOptions<LatestVersionQuery, LatestVersionQueryVariables>) {
|
||||||
|
return ApolloReactHooks.useQuery<LatestVersionQuery, LatestVersionQueryVariables>(LatestVersionDocument, baseOptions);
|
||||||
|
}
|
||||||
|
export function useLatestVersionLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions<LatestVersionQuery, LatestVersionQueryVariables>) {
|
||||||
|
return ApolloReactHooks.useLazyQuery<LatestVersionQuery, LatestVersionQueryVariables>(LatestVersionDocument, baseOptions);
|
||||||
|
}
|
||||||
|
export type LatestVersionQueryHookResult = ReturnType<typeof useLatestVersionQuery>;
|
||||||
|
export type LatestVersionLazyQueryHookResult = ReturnType<typeof useLatestVersionLazyQuery>;
|
||||||
|
export type LatestVersionQueryResult = ApolloReactCommon.QueryResult<LatestVersionQuery, LatestVersionQueryVariables>;
|
||||||
export const FindPerformersDocument = gql`
|
export const FindPerformersDocument = gql`
|
||||||
query FindPerformers($filter: FindFilterType, $performer_filter: PerformerFilterType) {
|
query FindPerformers($filter: FindFilterType, $performer_filter: PerformerFilterType) {
|
||||||
findPerformers(filter: $filter, performer_filter: $performer_filter) {
|
findPerformers(filter: $filter, performer_filter: $performer_filter) {
|
||||||
|
|||||||
Reference in New Issue
Block a user