From d081f328abec7f6b3d79c6f86d3ad8cbe084c04d Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Tue, 16 Jul 2019 22:15:14 -0700 Subject: [PATCH] Support deleting existing databases --- .../api/server/deleteServerDatabase.ts | 9 + .../scripts/components/FlashMessageRender.tsx | 7 +- .../server/databases/CreateDatabaseButton.tsx | 3 +- .../server/databases/DatabaseRow.tsx | 154 ++++++++++++++---- .../server/databases/DatabasesContainer.tsx | 13 +- resources/styles/components/typography.css | 2 +- tailwind.js | 2 + 7 files changed, 150 insertions(+), 40 deletions(-) create mode 100644 resources/scripts/api/server/deleteServerDatabase.ts diff --git a/resources/scripts/api/server/deleteServerDatabase.ts b/resources/scripts/api/server/deleteServerDatabase.ts new file mode 100644 index 00000000..23275bd3 --- /dev/null +++ b/resources/scripts/api/server/deleteServerDatabase.ts @@ -0,0 +1,9 @@ +import http from '@/api/http'; + +export default (uuid: string, database: string): Promise => { + return new Promise((resolve, reject) => { + http.delete(`/api/client/servers/${uuid}/databases/${database}`) + .then(() => resolve()) + .catch(reject); + }); +}; diff --git a/resources/scripts/components/FlashMessageRender.tsx b/resources/scripts/components/FlashMessageRender.tsx index adffd09d..cb0b3702 100644 --- a/resources/scripts/components/FlashMessageRender.tsx +++ b/resources/scripts/components/FlashMessageRender.tsx @@ -6,10 +6,10 @@ import { ApplicationStore } from '@/state'; type Props = Readonly<{ byKey?: string; spacerClass?: string; - withBottomSpace?: boolean; + className?: string; }>; -export default ({ withBottomSpace, spacerClass, byKey }: Props) => { +export default ({ className, spacerClass, byKey }: Props) => { const flashes = useStoreState((state: State) => state.flashes.items); let filtered = flashes; @@ -21,9 +21,8 @@ export default ({ withBottomSpace, spacerClass, byKey }: Props) => { return null; } - // noinspection PointlessBooleanExpressionJS return ( -
+
{ filtered.map((flash, index) => ( diff --git a/resources/scripts/components/server/databases/CreateDatabaseButton.tsx b/resources/scripts/components/server/databases/CreateDatabaseButton.tsx index 8430e492..54261605 100644 --- a/resources/scripts/components/server/databases/CreateDatabaseButton.tsx +++ b/resources/scripts/components/server/databases/CreateDatabaseButton.tsx @@ -69,7 +69,7 @@ export default ({ onCreated }: { onCreated: (database: ServerDatabase) => void } setVisible(false); }} > - +

Create new database

void }
+ +
+ + + ) + } + +
+
+ +
+
+

{database.name}

+
+
+

Endpoint:

+

{database.connectionString}

+
+
+

Connections + From:

+

{database.allowConnectionsFrom}

+
+
+

Username:

+

{database.username}

+
+
+ + +
-
-

{database.name}

-
-
-

Endpoint:

-

{database.connectionString}

-
-
-

Connections From:

-

{database.allowConnectionsFrom}

-
-
-

Username:

-

{database.username}

-
-
- - -
-
+ ); }; diff --git a/resources/scripts/components/server/databases/DatabasesContainer.tsx b/resources/scripts/components/server/databases/DatabasesContainer.tsx index 66b14e99..a7c2c1d7 100644 --- a/resources/scripts/components/server/databases/DatabasesContainer.tsx +++ b/resources/scripts/components/server/databases/DatabasesContainer.tsx @@ -40,11 +40,14 @@ export default () => { {databases.length > 0 ? - databases.map((database, index) => 0 ? 'mt-1' : undefined} - />) + databases.map((database, index) => ( + setDatabases(s => [ ...s.filter(d => d.id !== database.id) ])} + className={index > 0 ? 'mt-1' : undefined} + /> + )) :

It looks like you have no databases. Click the button below to create one now. diff --git a/resources/styles/components/typography.css b/resources/styles/components/typography.css index 301eabb2..c6b3f10f 100644 --- a/resources/styles/components/typography.css +++ b/resources/styles/components/typography.css @@ -13,5 +13,5 @@ h1, h2, h3, h4, h5, h6 { } p { - @apply .text-neutral-200; + @apply .text-neutral-200 .leading-snug; } diff --git a/tailwind.js b/tailwind.js index ec7f6c29..2f3314e5 100644 --- a/tailwind.js +++ b/tailwind.js @@ -290,7 +290,9 @@ module.exports = { leading: { 'none': 1, 'tight': 1.25, + 'snug': 1.375, 'normal': 1.5, + 'relaxed': 1.625, 'loose': 2, },