show only installed apps on Dashboard, fix status message on Apps screen
This commit is contained in:
parent
9e70ef7bf8
commit
bb1adc8d76
5 changed files with 28 additions and 29 deletions
|
@ -5,7 +5,7 @@ import { SearchIcon } from '@heroicons/react/solid';
|
||||||
import { showToast, ToastType } from 'src/common/util/show-toast';
|
import { showToast, ToastType } from 'src/common/util/show-toast';
|
||||||
import _, { debounce } from 'lodash';
|
import _, { debounce } from 'lodash';
|
||||||
import { Table } from 'src/components';
|
import { Table } from 'src/components';
|
||||||
import { App, AppStatus, useApps } from 'src/services/apps';
|
import { App, AppStatusEnum, useApps } from 'src/services/apps';
|
||||||
import { AppInstallModal } from './components';
|
import { AppInstallModal } from './components';
|
||||||
import { getConstForStatus } from './consts';
|
import { getConstForStatus } from './consts';
|
||||||
|
|
||||||
|
@ -56,11 +56,11 @@ export const Apps: React.FC = () => {
|
||||||
Header: 'Status',
|
Header: 'Status',
|
||||||
accessor: 'status',
|
accessor: 'status',
|
||||||
Cell: (e: any) => {
|
Cell: (e: any) => {
|
||||||
const status = e.cell.row.original.status as AppStatus;
|
const status = e.cell.row.original.status as AppStatusEnum;
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<div className={`flex-shrink-0 h-4 w-4 rounded-full bg-${getConstForStatus(status, 'colorClass')}`} />
|
<div className={`flex-shrink-0 h-4 w-4 rounded-full bg-${getConstForStatus(status, 'colorClass')}`} />
|
||||||
{status === AppStatus.Installing ? (
|
{status === AppStatusEnum.Installing ? (
|
||||||
<div
|
<div
|
||||||
className={`ml-2 cursor-pointer text-sm text-${getConstForStatus(status, 'colorClass')}`}
|
className={`ml-2 cursor-pointer text-sm text-${getConstForStatus(status, 'colorClass')}`}
|
||||||
onClick={() => showToast('Installing an app can take up to 10 minutes.', ToastType.Success)}
|
onClick={() => showToast('Installing an app can take up to 10 minutes.', ToastType.Success)}
|
||||||
|
@ -79,13 +79,13 @@ export const Apps: React.FC = () => {
|
||||||
Header: ' ',
|
Header: ' ',
|
||||||
Cell: (e: any) => {
|
Cell: (e: any) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const appStatus = e.cell.row.original.status as AppStatus;
|
const appStatus = e.cell.row.original.status as AppStatusEnum;
|
||||||
if (appStatus === AppStatus.Installing) {
|
if (appStatus === AppStatusEnum.Installing) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const { slug } = e.cell.row.original;
|
const { slug } = e.cell.row.original;
|
||||||
let buttonFuntion = () => navigate(`/apps/${slug}`);
|
let buttonFuntion = () => navigate(`/apps/${slug}`);
|
||||||
if (appStatus === AppStatus.NotInstalled) {
|
if (appStatus === AppStatusEnum.NotInstalled) {
|
||||||
buttonFuntion = () => {
|
buttonFuntion = () => {
|
||||||
setAppSlug(slug);
|
setAppSlug(slug);
|
||||||
setInstallModalOpen(true);
|
setInstallModalOpen(true);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { CogIcon, PlusCircleIcon } from '@heroicons/react/outline';
|
import { CogIcon, PlusCircleIcon } from '@heroicons/react/outline';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { AppStatus } from 'src/services/apps';
|
import { AppStatusEnum } from 'src/services/apps';
|
||||||
|
|
||||||
export const initialEditorYaml = `luck: except
|
export const initialEditorYaml = `luck: except
|
||||||
natural: still
|
natural: still
|
||||||
|
@ -27,26 +27,26 @@ search:
|
||||||
|
|
||||||
const tableConsts = [
|
const tableConsts = [
|
||||||
{
|
{
|
||||||
status: AppStatus.Installed,
|
status: AppStatusEnum.Installed,
|
||||||
colorClass: 'green-600',
|
colorClass: 'green-600',
|
||||||
buttonTitle: 'Configure',
|
buttonTitle: 'Configure',
|
||||||
buttonIcon: <CogIcon className="-ml-0.5 mr-2 h-4 w-4" aria-hidden="true" />,
|
buttonIcon: <CogIcon className="-ml-0.5 mr-2 h-4 w-4" aria-hidden="true" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
status: AppStatus.NotInstalled,
|
status: AppStatusEnum.NotInstalled,
|
||||||
colorClass: 'gray-600',
|
colorClass: 'gray-600',
|
||||||
buttonTitle: 'Install',
|
buttonTitle: 'Install',
|
||||||
buttonIcon: <PlusCircleIcon className="-ml-0.5 mr-2 h-4 w-4" aria-hidden="true" />,
|
buttonIcon: <PlusCircleIcon className="-ml-0.5 mr-2 h-4 w-4" aria-hidden="true" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
status: AppStatus.Installing,
|
status: AppStatusEnum.Installing,
|
||||||
colorClass: 'primary-600',
|
colorClass: 'primary-600',
|
||||||
buttonTitle: null,
|
buttonTitle: null,
|
||||||
buttonIcon: null,
|
buttonIcon: null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const getConstForStatus = (appStatus: AppStatus, paramName: string) => {
|
export const getConstForStatus = (appStatus: AppStatusEnum, paramName: string) => {
|
||||||
const tableConst = _.find(tableConsts, { status: appStatus });
|
const tableConst = _.find(tableConsts, { status: appStatus });
|
||||||
return _.get(tableConst, paramName);
|
return _.get(tableConst, paramName);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* eslint-disable react-hooks/exhaustive-deps */
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { useApps } from 'src/services/apps';
|
import { useApps } from 'src/services/apps';
|
||||||
import { useAuth } from 'src/services/auth';
|
import { AppStatusEnum } from 'src/services/apps/types';
|
||||||
import { DashboardCard, DashboardUtility } from './components';
|
import { DashboardCard, DashboardUtility } from './components';
|
||||||
import { DASHBOARD_QUICK_ACCESS } from './consts';
|
import { DASHBOARD_QUICK_ACCESS } from './consts';
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@ export const Dashboard: React.FC = () => {
|
||||||
splitedDomain.shift();
|
splitedDomain.shift();
|
||||||
const { apps, loadApps } = useApps();
|
const { apps, loadApps } = useApps();
|
||||||
|
|
||||||
const { currentUser, isAdmin } = useAuth();
|
|
||||||
|
|
||||||
// Tell React to load the apps
|
// Tell React to load the apps
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadApps();
|
loadApps();
|
||||||
|
@ -32,7 +30,7 @@ export const Dashboard: React.FC = () => {
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 md:gap-4 lg:grid-cols-4 mb-10">
|
<div className="grid grid-cols-1 md:grid-cols-2 md:gap-4 lg:grid-cols-4 mb-10">
|
||||||
{apps
|
{apps
|
||||||
.filter((app) => ['dashboard', 'monitoring'].indexOf(app.slug) === -1)
|
.filter((app) => ['dashboard', 'monitoring'].indexOf(app.slug) === -1)
|
||||||
.filter((app) => currentUser?.app_roles.filter((role) => role.name === app.slug) !== [])
|
.filter((app) => app.status !== AppStatusEnum.NotInstalled)
|
||||||
.map((app) => (
|
.map((app) => (
|
||||||
<DashboardCard app={app} key={app.name} />
|
<DashboardCard app={app} key={app.name} />
|
||||||
))}
|
))}
|
||||||
|
@ -48,6 +46,7 @@ export const Dashboard: React.FC = () => {
|
||||||
))}
|
))}
|
||||||
{apps
|
{apps
|
||||||
.filter((app) => app.slug === 'monitoring' && app.url !== null)
|
.filter((app) => app.slug === 'monitoring' && app.url !== null)
|
||||||
|
.filter((app) => app.status !== AppStatusEnum.NotInstalled)
|
||||||
.map((app) => (
|
.map((app) => (
|
||||||
<DashboardUtility item={app} key={app.name} />
|
<DashboardUtility item={app} key={app.name} />
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -1,16 +1,9 @@
|
||||||
import { App, AppStatus } from './types';
|
import { App, AppStatus, AppStatusEnum } from './types';
|
||||||
|
|
||||||
const transformAppStatus = (status: string) => {
|
const transformAppStatus = (status: AppStatus) => {
|
||||||
switch (status) {
|
if (status.installed && status.ready) return AppStatusEnum.Installed;
|
||||||
case 'App installed and running':
|
if (status.installed && !status.ready) return AppStatusEnum.Installing;
|
||||||
return AppStatus.Installed;
|
return AppStatusEnum.NotInstalled;
|
||||||
case 'Not installed':
|
|
||||||
return AppStatus.NotInstalled;
|
|
||||||
// For now default to "Installing" status for any app that isn't installed
|
|
||||||
// or not installed. Could also mean "upgrading", or "broken"...
|
|
||||||
default:
|
|
||||||
return AppStatus.Installing;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const transformApp = (response: any): App => {
|
export const transformApp = (response: any): App => {
|
||||||
|
|
|
@ -2,7 +2,7 @@ export interface App {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
slug: string;
|
slug: string;
|
||||||
status?: AppStatus;
|
status?: AppStatusEnum;
|
||||||
url: string;
|
url: string;
|
||||||
automaticUpdates: boolean;
|
automaticUpdates: boolean;
|
||||||
configuration?: string;
|
configuration?: string;
|
||||||
|
@ -15,8 +15,15 @@ export interface DisableAppForm {
|
||||||
removeAppData: boolean;
|
removeAppData: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum AppStatus {
|
export interface AppStatus {
|
||||||
|
installed: boolean;
|
||||||
|
ready: boolean;
|
||||||
|
message: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum AppStatusEnum {
|
||||||
NotInstalled = 'Not installed',
|
NotInstalled = 'Not installed',
|
||||||
Installed = 'Installed',
|
Installed = 'Installed',
|
||||||
Installing = 'Installing',
|
Installing = 'Installing',
|
||||||
|
External = 'External',
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue