modify apps table
This commit is contained in:
parent
3f6fd2dfc6
commit
9bb54bce00
2 changed files with 56 additions and 21 deletions
|
@ -1,6 +1,6 @@
|
||||||
/* eslint-disable react-hooks/exhaustive-deps */
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import React, { useState, useCallback, useMemo } from 'react';
|
import React, { useState, useCallback, useMemo } from 'react';
|
||||||
import { SearchIcon, PlusIcon } from '@heroicons/react/solid';
|
import { SearchIcon } from '@heroicons/react/solid';
|
||||||
import { Table } from 'src/components';
|
import { Table } from 'src/components';
|
||||||
import { columns, data } from './consts';
|
import { columns, data } from './consts';
|
||||||
|
|
||||||
|
@ -20,16 +20,6 @@ export const Apps: React.FC = () => {
|
||||||
<div className="max-w-7xl mx-auto py-4 px-3 sm:px-6 lg:px-8 h-full flex-grow">
|
<div className="max-w-7xl mx-auto py-4 px-3 sm:px-6 lg:px-8 h-full flex-grow">
|
||||||
<div className="pb-5 mt-6 border-b border-gray-200 sm:flex sm:items-center sm:justify-between">
|
<div className="pb-5 mt-6 border-b border-gray-200 sm:flex sm:items-center sm:justify-between">
|
||||||
<h1 className="text-3xl leading-6 font-bold text-gray-900">Apps</h1>
|
<h1 className="text-3xl leading-6 font-bold text-gray-900">Apps</h1>
|
||||||
|
|
||||||
<div className="mt-3 sm:mt-0 sm:ml-4">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-primary-700 hover:bg-primary-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-800"
|
|
||||||
>
|
|
||||||
<PlusIcon className="-ml-0.5 mr-2 h-4 w-4" aria-hidden="true" />
|
|
||||||
Add new app
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-between w-100 my-3 items-center">
|
<div className="flex justify-between w-100 my-3 items-center">
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { CogIcon } from '@heroicons/react/outline';
|
import { CogIcon, PlusCircleIcon } from '@heroicons/react/outline';
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
export const initialEditorYaml = () => {
|
export const initialEditorYaml = () => {
|
||||||
return `luck: except
|
return `luck: except
|
||||||
|
@ -25,6 +26,38 @@ search:
|
||||||
great: stomach`;
|
great: stomach`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export enum AppStatus {
|
||||||
|
NotInstalled = 'Not installed',
|
||||||
|
Installed = 'Installed',
|
||||||
|
Installing = 'Installing',
|
||||||
|
}
|
||||||
|
|
||||||
|
const tableConsts = [
|
||||||
|
{
|
||||||
|
status: AppStatus.Installed,
|
||||||
|
colorClass: 'green-600',
|
||||||
|
buttonTitle: 'Configure',
|
||||||
|
buttonIcon: <CogIcon className="-ml-0.5 mr-2 h-4 w-4" aria-hidden="true" />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: AppStatus.NotInstalled,
|
||||||
|
colorClass: 'gray-600',
|
||||||
|
buttonTitle: 'Install',
|
||||||
|
buttonIcon: <PlusCircleIcon className="-ml-0.5 mr-2 h-4 w-4" aria-hidden="true" />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
status: AppStatus.Installing,
|
||||||
|
colorClass: 'primary-600',
|
||||||
|
buttonTitle: null,
|
||||||
|
buttonIcon: null,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const getConstForStatus = (appStatus: AppStatus, paramName: string) => {
|
||||||
|
const tableConst = _.find(tableConsts, { status: appStatus });
|
||||||
|
return _.get(tableConst, paramName);
|
||||||
|
};
|
||||||
|
|
||||||
export const columns: any = [
|
export const columns: any = [
|
||||||
{
|
{
|
||||||
Header: 'Name',
|
Header: 'Name',
|
||||||
|
@ -47,10 +80,11 @@ export const columns: any = [
|
||||||
Header: 'Status',
|
Header: 'Status',
|
||||||
accessor: 'status',
|
accessor: 'status',
|
||||||
Cell: (e: any) => {
|
Cell: (e: any) => {
|
||||||
|
const appStatus = e.cell.row.original.status as AppStatus;
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<div className="flex-shrink-0 h-4 w-4 rounded-full bg-green-600" />
|
<div className={`flex-shrink-0 h-4 w-4 rounded-full bg-${getConstForStatus(appStatus, 'colorClass')}`} />
|
||||||
<div className="ml-2 text-sm text-green-600">{e.cell.row.original.status}</div>
|
<div className={`ml-2 text-sm text-${getConstForStatus(appStatus, 'colorClass')}`}>{appStatus}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -58,7 +92,11 @@ export const columns: any = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: ' ',
|
Header: ' ',
|
||||||
Cell: () => {
|
Cell: (e: any) => {
|
||||||
|
const appStatus = e.cell.row.original.status as AppStatus;
|
||||||
|
if (appStatus === AppStatus.Installing) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div className="text-right opacity-0 group-hover:opacity-100 transition-opacity">
|
<div className="text-right opacity-0 group-hover:opacity-100 transition-opacity">
|
||||||
<button
|
<button
|
||||||
|
@ -66,8 +104,8 @@ export const columns: any = [
|
||||||
type="button"
|
type="button"
|
||||||
className="inline-flex items-center px-4 py-2 border border-gray-200 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500"
|
className="inline-flex items-center px-4 py-2 border border-gray-200 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500"
|
||||||
>
|
>
|
||||||
<CogIcon className="-ml-0.5 mr-2 h-4 w-4" aria-hidden="true" />
|
{getConstForStatus(appStatus, 'buttonIcon')}
|
||||||
Configure
|
{getConstForStatus(appStatus, 'buttonTitle')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -80,25 +118,32 @@ export const data: any[] = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'Nextcloud',
|
name: 'Nextcloud',
|
||||||
status: 'Active for everyone',
|
status: AppStatus.Installed,
|
||||||
assetSrc: './assets/nextcloud.svg',
|
assetSrc: './assets/nextcloud.svg',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
name: 'Wekan',
|
name: 'Wekan',
|
||||||
status: 'Active for everyone',
|
status: AppStatus.Installing,
|
||||||
assetSrc: './assets/wekan.svg',
|
assetSrc: './assets/wekan.svg',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
name: 'Zulip',
|
name: 'Zulip',
|
||||||
status: 'Active for everyone',
|
status: AppStatus.NotInstalled,
|
||||||
assetSrc: './assets/zulip.svg',
|
assetSrc: './assets/zulip.svg',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 4,
|
id: 4,
|
||||||
name: 'Wordpress',
|
name: 'Wordpress',
|
||||||
status: 'Active for everyone',
|
status: AppStatus.NotInstalled,
|
||||||
assetSrc: './assets/wordpress.svg',
|
assetSrc: './assets/wordpress.svg',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export interface AppInfo {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
status: AppStatus;
|
||||||
|
assetSrc: string;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue