From 7e8a5f12713d36850026f1484dd4a1cb6c65c898 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 4 Jul 2020 17:15:49 -0700 Subject: [PATCH] Update database screens --- .../components/elements/GreyRowBox.tsx | 6 +- .../server/databases/CreateDatabaseButton.tsx | 31 +++--- .../server/databases/DatabaseRow.tsx | 102 +++++++++--------- .../server/databases/DatabasesContainer.tsx | 20 ++-- .../server/databases/RotatePasswordButton.tsx | 3 +- 5 files changed, 86 insertions(+), 76 deletions(-) diff --git a/resources/scripts/components/elements/GreyRowBox.tsx b/resources/scripts/components/elements/GreyRowBox.tsx index e33dae6ca..e86c61dc2 100644 --- a/resources/scripts/components/elements/GreyRowBox.tsx +++ b/resources/scripts/components/elements/GreyRowBox.tsx @@ -1,12 +1,10 @@ import styled from 'styled-components/macro'; import tw from 'twin.macro'; -export default styled.div` +export default styled.div<{ $hoverable?: boolean }>` ${tw`flex rounded no-underline text-neutral-200 items-center bg-neutral-700 p-4 border border-transparent transition-colors duration-150`}; - &:not(.no-hover):hover { - ${tw`border-neutral-500`}; - } + ${props => props.$hoverable !== false && tw`hover:border-neutral-500`}; & > div.icon { ${tw`rounded-full bg-neutral-500 p-3`}; diff --git a/resources/scripts/components/server/databases/CreateDatabaseButton.tsx b/resources/scripts/components/server/databases/CreateDatabaseButton.tsx index cf5b8c63d..2b035ce2c 100644 --- a/resources/scripts/components/server/databases/CreateDatabaseButton.tsx +++ b/resources/scripts/components/server/databases/CreateDatabaseButton.tsx @@ -9,6 +9,8 @@ import { httpErrorToHuman } from '@/api/http'; import FlashMessageRender from '@/components/FlashMessageRender'; import useFlash from '@/plugins/useFlash'; import useServer from '@/plugins/useServer'; +import Button from '@/components/elements/Button'; +import tw from 'twin.macro'; interface Values { databaseName: string; @@ -48,7 +50,7 @@ export default () => { }; return ( - + <> { setVisible(false); }} > - -

Create new database

-
+ +

Create new database

+ { label={'Database Name'} description={'A descriptive name for your database instance.'} /> -
+
{ description={'Where connections should be allowed from. Use % for wildcards.'} />
-
- - + +
) } - - + + ); }; diff --git a/resources/scripts/components/server/databases/DatabaseRow.tsx b/resources/scripts/components/server/databases/DatabaseRow.tsx index 9adc38519..68559e6ca 100644 --- a/resources/scripts/components/server/databases/DatabaseRow.tsx +++ b/resources/scripts/components/server/databases/DatabaseRow.tsx @@ -17,6 +17,11 @@ import Can from '@/components/elements/Can'; import { ServerDatabase } from '@/api/server/getServerDatabases'; import useServer from '@/plugins/useServer'; import useFlash from '@/plugins/useFlash'; +import tw from 'twin.macro'; +import Button from '@/components/elements/Button'; +import Label from '@/components/elements/Label'; +import Input from '@/components/elements/Input'; +import GreyRowBox from '@/components/elements/GreyRowBox'; interface Props { database: ServerDatabase; @@ -51,13 +56,14 @@ export default ({ database, className }: Props) => { addError({ key: 'database:delete', message: httpErrorToHuman(error) }); }); }; - + return ( - + <> { ({ isSubmitting, isValid, resetForm }) => ( @@ -70,13 +76,13 @@ export default ({ database, className }: Props) => { resetForm(); }} > - -

Confirm database deletion

-

+ +

Confirm database deletion

+

Deleting a database is a permanent action, it cannot be undone. This will permanetly delete the {database.name} database and remove all associated data.

-
+ { label={'Confirm Database Name'} description={'Enter the database name to confirm deletion.'} /> -
- - +
@@ -106,62 +113,61 @@ export default ({ database, className }: Props) => { }
setConnectionVisible(false)}> - -

Database connection details

+ +

Database connection details

- - + +
-
- - + +
-
+
- +
-
-
- + +
+
-
-

{database.name}

+
+

{database.name}

-
-

{database.connectionString}

-

Endpoint

+
+

{database.connectionString}

+

Endpoint

-
-

{database.allowConnectionsFrom}

-

Connections from

+
+

{database.allowConnectionsFrom}

+

Connections from

-
-

{database.username}

-

Username

+
+

{database.username}

+

Username

-
- +
+ - +
-
- + + ); }; diff --git a/resources/scripts/components/server/databases/DatabasesContainer.tsx b/resources/scripts/components/server/databases/DatabasesContainer.tsx index 9213347f0..90db7c27c 100644 --- a/resources/scripts/components/server/databases/DatabasesContainer.tsx +++ b/resources/scripts/components/server/databases/DatabasesContainer.tsx @@ -11,6 +11,8 @@ import Can from '@/components/elements/Can'; import useFlash from '@/plugins/useFlash'; import useServer from '@/plugins/useServer'; import PageContentBlock from '@/components/elements/PageContentBlock'; +import tw from 'twin.macro'; +import Fade from '@/components/elements/Fade'; export default () => { const { uuid, featureLimits } = useServer(); @@ -35,11 +37,11 @@ export default () => { return ( - + {(!databases.length && loading) ? - + : - + <> {databases.length > 0 ? databases.map((database, index) => ( @@ -50,28 +52,28 @@ export default () => { /> )) : -

+

{featureLimits.databases > 0 ? - `It looks like you have no databases.` + 'It looks like you have no databases.' : - `Databases cannot be created for this server.` + 'Databases cannot be created for this server.' }

} {(featureLimits.databases > 0 && databases.length > 0) && -

+

{databases.length} of {featureLimits.databases} databases have been allocated to this server.

} {featureLimits.databases > 0 && featureLimits.databases !== databases.length && -
+
} - + } ); diff --git a/resources/scripts/components/server/databases/RotatePasswordButton.tsx b/resources/scripts/components/server/databases/RotatePasswordButton.tsx index fdb31a1e2..41c116006 100644 --- a/resources/scripts/components/server/databases/RotatePasswordButton.tsx +++ b/resources/scripts/components/server/databases/RotatePasswordButton.tsx @@ -6,6 +6,7 @@ import { ServerContext } from '@/state/server'; import { ServerDatabase } from '@/api/server/getServerDatabases'; import { httpErrorToHuman } from '@/api/http'; import Button from '@/components/elements/Button'; +import tw from 'twin.macro'; export default ({ databaseId, onUpdate }: { databaseId: string; @@ -38,7 +39,7 @@ export default ({ databaseId, onUpdate }: { }; return ( - );