Skip to content

Commit 574855a

Browse files
authored
Merge branch 'develop' into patch-1
2 parents de8ce4b + f6ee885 commit 574855a

33 files changed

+654
-270
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { rawDataToServerDatabase, ServerDatabase } from '@/api/server/getServerDatabases';
2+
import http from '@/api/http';
3+
4+
export default (uuid: string, data: { connectionsFrom: string; databaseName: string }): Promise<ServerDatabase> => {
5+
return new Promise((resolve, reject) => {
6+
http.post(`/api/client/servers/${uuid}/databases`, {
7+
database: data.databaseName,
8+
remote: data.connectionsFrom,
9+
}, {
10+
params: { include: 'password' },
11+
})
12+
.then(response => resolve(rawDataToServerDatabase(response.data.attributes)))
13+
.catch(reject);
14+
});
15+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import http from '@/api/http';
2+
3+
export default (uuid: string, database: string): Promise<void> => {
4+
return new Promise((resolve, reject) => {
5+
http.delete(`/api/client/servers/${uuid}/databases/${database}`)
6+
.then(() => resolve())
7+
.catch(reject);
8+
});
9+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import http from '@/api/http';
2+
3+
export interface ServerDatabase {
4+
id: string;
5+
name: string;
6+
username: string;
7+
connectionString: string;
8+
allowConnectionsFrom: string;
9+
password?: string;
10+
}
11+
12+
export const rawDataToServerDatabase = (data: any): ServerDatabase => ({
13+
id: data.id,
14+
name: data.name,
15+
username: data.username,
16+
connectionString: `${data.host.address}:${data.host.port}`,
17+
allowConnectionsFrom: data.connections_from,
18+
password: data.relationships && data.relationships.password ? data.relationships.password.attributes.password : undefined,
19+
});
20+
21+
export default (uuid: string, includePassword: boolean = true): Promise<ServerDatabase[]> => {
22+
return new Promise((resolve, reject) => {
23+
http.get(`/api/client/servers/${uuid}/databases`, {
24+
params: includePassword ? { include: 'password' } : undefined,
25+
})
26+
.then(response => resolve(
27+
(response.data.data || []).map((item: any) => rawDataToServerDatabase(item.attributes))
28+
))
29+
.catch(reject);
30+
});
31+
};

resources/scripts/components/FlashMessageRender.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import React from 'react';
22
import MessageBox from '@/components/MessageBox';
33
import { State, useStoreState } from 'easy-peasy';
4-
import { ApplicationState } from '@/state/types';
4+
import { ApplicationStore } from '@/state';
55

66
type Props = Readonly<{
77
byKey?: string;
88
spacerClass?: string;
9-
withBottomSpace?: boolean;
9+
className?: string;
1010
}>;
1111

12-
export default ({ withBottomSpace, spacerClass, byKey }: Props) => {
13-
const flashes = useStoreState((state: State<ApplicationState>) => state.flashes.items);
12+
export default ({ className, spacerClass, byKey }: Props) => {
13+
const flashes = useStoreState((state: State<ApplicationStore>) => state.flashes.items);
1414

1515
let filtered = flashes;
1616
if (byKey) {
@@ -21,9 +21,8 @@ export default ({ withBottomSpace, spacerClass, byKey }: Props) => {
2121
return null;
2222
}
2323

24-
// noinspection PointlessBooleanExpressionJS
2524
return (
26-
<div className={withBottomSpace === false ? undefined : 'mb-2'}>
25+
<div className={className}>
2726
{
2827
filtered.map((flash, index) => (
2928
<React.Fragment key={flash.id || flash.type + flash.message}>

resources/scripts/components/auth/ForgotPasswordContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import requestPasswordResetEmail from '@/api/auth/requestPasswordResetEmail';
44
import { httpErrorToHuman } from '@/api/http';
55
import LoginFormContainer from '@/components/auth/LoginFormContainer';
66
import { Actions, useStoreActions } from 'easy-peasy';
7-
import { ApplicationState } from '@/state/types';
87
import FlashMessageRender from '@/components/FlashMessageRender';
8+
import { ApplicationStore } from '@/state';
99

1010
export default () => {
1111
const [ isSubmitting, setSubmitting ] = React.useState(false);
1212
const [ email, setEmail ] = React.useState('');
1313

14-
const { clearFlashes, addFlash } = useStoreActions((actions: Actions<ApplicationState>) => actions.flashes);
14+
const { clearFlashes, addFlash } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
1515

1616
const handleFieldUpdate = (e: React.ChangeEvent<HTMLInputElement>) => setEmail(e.target.value);
1717

resources/scripts/components/auth/LoginCheckpointContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import loginCheckpoint from '@/api/auth/loginCheckpoint';
44
import { httpErrorToHuman } from '@/api/http';
55
import LoginFormContainer from '@/components/auth/LoginFormContainer';
66
import { Actions, useStoreActions } from 'easy-peasy';
7-
import { ApplicationState } from '@/state/types';
87
import { StaticContext } from 'react-router';
98
import FlashMessageRender from '@/components/FlashMessageRender';
9+
import { ApplicationStore } from '@/state';
1010

1111
export default ({ history, location: { state } }: RouteComponentProps<{}, StaticContext, { token?: string }>) => {
1212
const [ code, setCode ] = useState('');
1313
const [ isLoading, setIsLoading ] = useState(false);
1414

15-
const { clearFlashes, addFlash } = useStoreActions((actions: Actions<ApplicationState>) => actions.flashes);
15+
const { clearFlashes, addFlash } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
1616

1717
if (!state || !state.token) {
1818
history.replace('/auth/login');

resources/scripts/components/auth/LoginContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import { httpErrorToHuman } from '@/api/http';
55
import LoginFormContainer from '@/components/auth/LoginFormContainer';
66
import FlashMessageRender from '@/components/FlashMessageRender';
77
import { Actions, useStoreActions } from 'easy-peasy';
8-
import { ApplicationState } from '@/state/types';
8+
import { ApplicationStore } from '@/state';
99

1010
export default ({ history }: RouteComponentProps) => {
1111
const [ username, setUsername ] = useState('');
1212
const [ password, setPassword ] = useState('');
1313
const [ isLoading, setLoading ] = useState(false);
1414

15-
const { clearFlashes, addFlash } = useStoreActions((actions: Actions<ApplicationState>) => actions.flashes);
15+
const { clearFlashes, addFlash } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
1616

1717
const submit = (e: React.FormEvent<HTMLFormElement>) => {
1818
e.preventDefault();

resources/scripts/components/auth/ResetPasswordContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { httpErrorToHuman } from '@/api/http';
77
import LoginFormContainer from '@/components/auth/LoginFormContainer';
88
import FlashMessageRender from '@/components/FlashMessageRender';
99
import { Actions, useStoreActions } from 'easy-peasy';
10-
import { ApplicationState } from '@/state/types';
10+
import { ApplicationStore } from '@/state';
1111

1212
type Props = Readonly<RouteComponentProps<{ token: string }> & {}>;
1313

@@ -17,7 +17,7 @@ export default (props: Props) => {
1717
const [ password, setPassword ] = useState('');
1818
const [ passwordConfirm, setPasswordConfirm ] = useState('');
1919

20-
const { clearFlashes, addFlash } = useStoreActions((actions: Actions<ApplicationState>) => actions.flashes);
20+
const { clearFlashes, addFlash } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
2121

2222
const parsed = parse(props.location.search);
2323
if (email.length === 0 && parsed.email) {

resources/scripts/components/dashboard/DashboardContainer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { Link } from 'react-router-dom';
99

1010
export default () => (
1111
<div className={'my-10'}>
12-
<Link to={'/server/e9d6c836'} className={'flex no-underline text-neutral-200 cursor-pointer items-center bg-neutral-700 p-4 border border-transparent hover:border-neutral-500'}>
13-
<div className={'rounded-full bg-neutral-500 p-3'}>
12+
<Link to={'/server/e9d6c836'} className={'grey-row-box cursor-pointer'}>
13+
<div className={'icon'}>
1414
<FontAwesomeIcon icon={faServer}/>
1515
</div>
1616
<div className={'w-1/2 ml-4'}>
@@ -49,8 +49,8 @@ export default () => (
4949
</div>
5050
</div>
5151
</Link>
52-
<div className={'flex mt-px cursor-pointer items-center bg-neutral-700 p-4 border border-transparent hover:border-neutral-500'}>
53-
<div className={'rounded-full bg-neutral-500 p-3'}>
52+
<div className={'grey-row-box cursor-pointer mt-2'}>
53+
<div className={'icon'}>
5454
<FontAwesomeIcon icon={faServer}/>
5555
</div>
5656
<div className={'w-1/2 ml-4'}>

resources/scripts/components/dashboard/forms/UpdateEmailAddressForm.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from 'react';
22
import { Actions, State, useStoreActions, useStoreState } from 'easy-peasy';
3-
import { ApplicationState } from '@/state/types';
43
import { Form, Formik, FormikActions } from 'formik';
54
import * as Yup from 'yup';
65
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
76
import Field from '@/components/elements/Field';
87
import { httpErrorToHuman } from '@/api/http';
8+
import { ApplicationStore } from '@/state';
99

1010
interface Values {
1111
email: string;
@@ -18,10 +18,10 @@ const schema = Yup.object().shape({
1818
});
1919

2020
export default () => {
21-
const user = useStoreState((state: State<ApplicationState>) => state.user.data);
22-
const updateEmail = useStoreActions((state: Actions<ApplicationState>) => state.user.updateUserEmail);
21+
const user = useStoreState((state: State<ApplicationStore>) => state.user.data);
22+
const updateEmail = useStoreActions((state: Actions<ApplicationStore>) => state.user.updateUserEmail);
2323

24-
const { clearFlashes, addFlash } = useStoreActions((actions: Actions<ApplicationState>) => actions.flashes);
24+
const { clearFlashes, addFlash } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
2525

2626
const submit = (values: Values, { resetForm, setSubmitting }: FormikActions<Values>) => {
2727
clearFlashes('account:email');

0 commit comments

Comments
 (0)