yeet name_first and name_last from users table
This commit is contained in:
parent
f1be653486
commit
bf9dfa87da
20 changed files with 144 additions and 82 deletions
|
@ -50,8 +50,6 @@ class MakeUserCommand extends Command
|
|||
$root_admin = $this->option('admin') ?? $this->confirm(trans('command/messages.user.ask_admin'));
|
||||
$email = $this->option('email') ?? $this->ask(trans('command/messages.user.ask_email'));
|
||||
$username = $this->option('username') ?? $this->ask(trans('command/messages.user.ask_username'));
|
||||
$name_first = $this->option('name-first') ?? $this->ask(trans('command/messages.user.ask_name_first'));
|
||||
$name_last = $this->option('name-last') ?? $this->ask(trans('command/messages.user.ask_name_last'));
|
||||
|
||||
if (is_null($password = $this->option('password')) && !$this->option('no-password')) {
|
||||
$this->warn(trans('command/messages.user.ask_password_help'));
|
||||
|
@ -59,7 +57,7 @@ class MakeUserCommand extends Command
|
|||
$password = $this->secret(trans('command/messages.user.ask_password'));
|
||||
}
|
||||
|
||||
$user = $this->creationService->handle(compact('email', 'username', 'name_first', 'name_last', 'password', 'root_admin'));
|
||||
$user = $this->creationService->handle(compact('email', 'username', 'password', 'root_admin'));
|
||||
$this->table(['Field', 'Value'], [
|
||||
['UUID', $user->uuid],
|
||||
['Email', $user->email],
|
||||
|
|
|
@ -24,30 +24,13 @@ class StoreUserRequest extends ApplicationApiRequest
|
|||
'admin_role_id',
|
||||
])->toArray();
|
||||
|
||||
$response['first_name'] = $rules['name_first'];
|
||||
$response['last_name'] = $rules['name_last'];
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function validated(): array
|
||||
{
|
||||
$data = parent::validated();
|
||||
|
||||
$data['name_first'] = $data['first_name'];
|
||||
$data['name_last'] = $data['last_name'];
|
||||
|
||||
unset($data['first_name'], $data['last_name']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'external_id' => 'Third Party Identifier',
|
||||
'name_first' => 'First Name',
|
||||
'name_last' => 'Last Name',
|
||||
'root_admin' => 'Root Administrator Status',
|
||||
];
|
||||
}
|
||||
|
|
|
@ -87,8 +87,6 @@ class User extends Model implements
|
|||
'external_id',
|
||||
'username',
|
||||
'email',
|
||||
'name_first',
|
||||
'name_last',
|
||||
'password',
|
||||
'language',
|
||||
'use_totp',
|
||||
|
@ -144,8 +142,6 @@ class User extends Model implements
|
|||
'email' => 'required|email|between:1,191|unique:users,email',
|
||||
'external_id' => 'sometimes|nullable|string|max:191|unique:users,external_id',
|
||||
'username' => 'required|between:1,191|unique:users,username',
|
||||
'name_first' => 'required|string|between:1,191',
|
||||
'name_last' => 'required|string|between:1,191',
|
||||
'password' => 'sometimes|nullable|string',
|
||||
'admin_role_id' => 'sometimes|nullable|exists:admin_roles,id',
|
||||
'root_admin' => 'boolean',
|
||||
|
|
|
@ -53,7 +53,7 @@ class AddedToServer extends Notification implements ShouldQueue
|
|||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage())
|
||||
->greeting('Hello ' . $this->server->user . '!')
|
||||
->greeting('Hello user!')
|
||||
->line('You have been added as a subuser for the following server, allowing you certain control over the server.')
|
||||
->line('Server Name: ' . $this->server->name)
|
||||
->action('Visit Server', url('/server/' . $this->server->uuidShort));
|
||||
|
|
|
@ -54,7 +54,7 @@ class RemovedFromServer extends Notification implements ShouldQueue
|
|||
{
|
||||
return (new MailMessage())
|
||||
->error()
|
||||
->greeting('Hello ' . $this->server->user . '.')
|
||||
->greeting('Hello user!')
|
||||
->line('You have been removed as a subuser for the following server.')
|
||||
->line('Server Name: ' . $this->server->name)
|
||||
->action('Visit Panel', route('index'));
|
||||
|
|
|
@ -32,7 +32,6 @@ class SubuserObserver
|
|||
event(new Events\Subuser\Created($subuser));
|
||||
|
||||
$subuser->user->notify((new AddedToServer([
|
||||
'user' => $subuser->user->name_first,
|
||||
'name' => $subuser->server->name,
|
||||
'uuidShort' => $subuser->server->uuidShort,
|
||||
])));
|
||||
|
@ -54,7 +53,6 @@ class SubuserObserver
|
|||
event(new Events\Subuser\Deleted($subuser));
|
||||
|
||||
$subuser->user->notify((new RemovedFromServer([
|
||||
'user' => $subuser->user->name_first,
|
||||
'name' => $subuser->server->name,
|
||||
])));
|
||||
}
|
||||
|
|
|
@ -82,8 +82,6 @@ class SubuserCreationService
|
|||
$user = $this->userCreationService->handle([
|
||||
'email' => $email,
|
||||
'username' => $username,
|
||||
'name_first' => 'Server',
|
||||
'name_last' => 'Subuser',
|
||||
'root_admin' => false,
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -33,8 +33,6 @@ class UserTransformer extends BaseTransformer
|
|||
'uuid' => $model->uuid,
|
||||
'username' => $model->username,
|
||||
'email' => $model->email,
|
||||
'first_name' => $model->name_first,
|
||||
'last_name' => $model->name_last,
|
||||
'language' => $model->language,
|
||||
'root_admin' => (bool) $model->root_admin,
|
||||
'2fa' => (bool) $model->use_totp,
|
||||
|
|
|
@ -26,8 +26,6 @@ class AccountTransformer extends BaseClientTransformer
|
|||
'admin' => $model->root_admin,
|
||||
'username' => $model->username,
|
||||
'email' => $model->email,
|
||||
'first_name' => $model->name_first,
|
||||
'last_name' => $model->name_last,
|
||||
'language' => $model->language,
|
||||
];
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class YeetNamesFromUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn(['name_first', 'name_last']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('name_first')->after('email')->nullable();
|
||||
$table->string('name_last')->after('name_first')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
|
@ -11,8 +11,6 @@ export interface User {
|
|||
uuid: string;
|
||||
username: string;
|
||||
email: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
language: string;
|
||||
adminRoleId: number | null;
|
||||
rootAdmin: boolean;
|
||||
|
@ -33,8 +31,6 @@ export const rawDataToUser = ({ attributes }: FractalResponseData): User => ({
|
|||
uuid: attributes.uuid,
|
||||
username: attributes.username,
|
||||
email: attributes.email,
|
||||
firstName: attributes.first_name,
|
||||
lastName: attributes.last_name,
|
||||
language: attributes.language,
|
||||
adminRoleId: attributes.admin_role_id,
|
||||
rootAdmin: attributes.root_admin,
|
||||
|
@ -54,8 +50,6 @@ export interface Filters {
|
|||
uuid?: string;
|
||||
username?: string;
|
||||
email?: string;
|
||||
firstName?: string;
|
||||
lastName?: string;
|
||||
}
|
||||
|
||||
export const Context = createContext<Filters>();
|
||||
|
|
|
@ -4,8 +4,6 @@ import { User, rawDataToUser } from '@/api/admin/users/getUsers';
|
|||
export interface Values {
|
||||
username: string;
|
||||
email: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
password: string;
|
||||
adminRoleId: number | null;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,6 @@ interface ExtendedWindow extends Window {
|
|||
username: string;
|
||||
email: string;
|
||||
/* eslint-disable camelcase */
|
||||
name_first: string;
|
||||
name_last: string;
|
||||
root_admin: boolean;
|
||||
use_totp: boolean;
|
||||
language: string;
|
||||
|
@ -56,8 +54,6 @@ const App = () => {
|
|||
uuid: PterodactylUser.uuid,
|
||||
username: PterodactylUser.username,
|
||||
email: PterodactylUser.email,
|
||||
firstName: PterodactylUser.name_first,
|
||||
lastName: PterodactylUser.name_last,
|
||||
language: PterodactylUser.language,
|
||||
rootAdmin: PterodactylUser.root_admin,
|
||||
useTotp: PterodactylUser.use_totp,
|
||||
|
|
|
@ -131,7 +131,7 @@ const ServersContainer = () => {
|
|||
<td css={tw`px-6 text-sm text-left whitespace-nowrap`}>
|
||||
<NavLink to={`/admin/users/${server.relations.user?.id}`} css={tw`text-primary-400 hover:text-primary-300`}>
|
||||
<div css={tw`text-sm text-neutral-200`}>
|
||||
{server.relations.user?.firstName} {server.relations.user?.lastName}
|
||||
Silly User
|
||||
</div>
|
||||
|
||||
<div css={tw`text-sm text-neutral-400`}>
|
||||
|
|
|
@ -52,8 +52,6 @@ export function InformationContainer ({ title, initialValues, children, onSubmit
|
|||
initialValues = {
|
||||
username: '',
|
||||
email: '',
|
||||
firstName: '',
|
||||
lastName: '',
|
||||
password: '',
|
||||
adminRoleId: 0,
|
||||
};
|
||||
|
@ -66,8 +64,6 @@ export function InformationContainer ({ title, initialValues, children, onSubmit
|
|||
validationSchema={object().shape({
|
||||
username: string().min(1).max(32),
|
||||
email: string(),
|
||||
firstName: string(),
|
||||
lastName: string(),
|
||||
password: exists ? string() : string().required(),
|
||||
})}
|
||||
>
|
||||
|
@ -98,26 +94,6 @@ export function InformationContainer ({ title, initialValues, children, onSubmit
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div css={tw`md:w-full md:flex md:flex-row mt-6`}>
|
||||
<div css={tw`md:w-full md:flex md:flex-col md:mr-4 mt-6 md:mt-0`}>
|
||||
<Field
|
||||
id={'firstName'}
|
||||
name={'firstName'}
|
||||
label={'First Name'}
|
||||
type={'text'}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div css={tw`md:w-full md:flex md:flex-col md:ml-4 mt-6 md:mt-0`}>
|
||||
<Field
|
||||
id={'lastName'}
|
||||
name={'lastName'}
|
||||
label={'Last Name'}
|
||||
type={'text'}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div css={tw`md:w-full md:flex md:flex-row mt-6`}>
|
||||
<div css={tw`md:w-full md:flex md:flex-col md:mr-4 mt-6 md:mt-0`}>
|
||||
<Field
|
||||
|
@ -184,8 +160,6 @@ function EditInformationContainer () {
|
|||
initialValues={{
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
firstName: user.firstName,
|
||||
lastName: user.lastName,
|
||||
adminRoleId: user.adminRoleId,
|
||||
password: '',
|
||||
}}
|
||||
|
@ -240,8 +214,8 @@ function UserEditContainer () {
|
|||
<AdminContentBlock title={'User - ' + user.id}>
|
||||
<div css={tw`w-full flex flex-row items-center mb-8`}>
|
||||
<div css={tw`flex flex-col flex-shrink`} style={{ minWidth: '0' }}>
|
||||
<h2 css={tw`text-2xl text-neutral-50 font-header font-medium`}>{user.firstName} {user.lastName}</h2>
|
||||
<p css={tw`text-base text-neutral-400 whitespace-nowrap overflow-ellipsis overflow-hidden`}>{user.email}</p>
|
||||
<h2 css={tw`text-2xl text-neutral-50 font-header font-medium`}>{user.email}</h2>
|
||||
<p css={tw`text-base text-neutral-400 whitespace-nowrap overflow-ellipsis overflow-hidden`}>{user.uuid}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
105
resources/scripts/components/admin/users/UserRouter.tsx
Normal file
105
resources/scripts/components/admin/users/UserRouter.tsx
Normal file
|
@ -0,0 +1,105 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { useLocation } from 'react-router';
|
||||
import tw from 'twin.macro';
|
||||
import { Route, Switch, useRouteMatch } from 'react-router-dom';
|
||||
import { action, Action, Actions, createContextStore, useStoreActions } from 'easy-peasy';
|
||||
import { User } from '@/api/admin/users/getUsers';
|
||||
import getUser from '@/api/admin/users/getUser';
|
||||
import AdminContentBlock from '@/components/admin/AdminContentBlock';
|
||||
import Spinner from '@/components/elements/Spinner';
|
||||
import FlashMessageRender from '@/components/FlashMessageRender';
|
||||
import { ApplicationStore } from '@/state';
|
||||
import { SubNavigation, SubNavigationLink } from '@/components/admin/SubNavigation';
|
||||
|
||||
interface ctx {
|
||||
user: User | undefined;
|
||||
setUser: Action<ctx, User | undefined>;
|
||||
}
|
||||
|
||||
export const Context = createContextStore<ctx>({
|
||||
user: undefined,
|
||||
|
||||
setUser: action((state, payload) => {
|
||||
state.user = payload;
|
||||
}),
|
||||
});
|
||||
|
||||
const UserRouter = () => {
|
||||
const location = useLocation();
|
||||
const match = useRouteMatch<{ id?: string }>();
|
||||
|
||||
const { clearFlashes, clearAndAddHttpError } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
|
||||
const [ loading, setLoading ] = useState(true);
|
||||
|
||||
const user = Context.useStoreState(state => state.user);
|
||||
const setUser = Context.useStoreActions(actions => actions.setUser);
|
||||
|
||||
useEffect(() => {
|
||||
clearFlashes('user');
|
||||
|
||||
getUser(Number(match.params?.id), [ 'database_host', 'location' ])
|
||||
.then(user => setUser(user))
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
clearAndAddHttpError({ key: 'user', error });
|
||||
})
|
||||
.then(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
if (loading || user === undefined) {
|
||||
return (
|
||||
<AdminContentBlock>
|
||||
<FlashMessageRender byKey={'user'} css={tw`mb-4`}/>
|
||||
|
||||
<div css={tw`w-full flex flex-col items-center justify-center`} style={{ height: '24rem' }}>
|
||||
<Spinner size={'base'}/>
|
||||
</div>
|
||||
</AdminContentBlock>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<AdminContentBlock title={'User - ' + user.id}>
|
||||
<div css={tw`w-full flex flex-row items-center mb-4`}>
|
||||
<div css={tw`flex flex-col flex-shrink`} style={{ minWidth: '0' }}>
|
||||
<h2 css={tw`text-2xl text-neutral-50 font-header font-medium`}>{user.email}</h2>
|
||||
<p css={tw`text-base text-neutral-400 whitespace-nowrap overflow-ellipsis overflow-hidden`}>{user.uuid}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<FlashMessageRender byKey={'user'} css={tw`mb-4`}/>
|
||||
|
||||
<SubNavigation>
|
||||
<SubNavigationLink to={`${match.url}`} name={'About'}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path clipRule="evenodd" fillRule="evenodd" d="M4 4a2 2 0 012-2h8a2 2 0 012 2v12a1 1 0 110 2h-3a1 1 0 01-1-1v-2a1 1 0 00-1-1H9a1 1 0 00-1 1v2a1 1 0 01-1 1H4a1 1 0 110-2V4zm3 1h2v2H7V5zm2 4H7v2h2V9zm2-4h2v2h-2V5zm2 4h-2v2h2V9z" />
|
||||
</svg>
|
||||
</SubNavigationLink>
|
||||
|
||||
<SubNavigationLink to={`${match.url}/servers`} name={'Servers'}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path clipRule="evenodd" fillRule="evenodd" d="M2 5a2 2 0 012-2h12a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V5zm3.293 1.293a1 1 0 011.414 0l3 3a1 1 0 010 1.414l-3 3a1 1 0 01-1.414-1.414L7.586 10 5.293 7.707a1 1 0 010-1.414zM11 12a1 1 0 100 2h3a1 1 0 100-2h-3z" />
|
||||
</svg>
|
||||
</SubNavigationLink>
|
||||
</SubNavigation>
|
||||
|
||||
<Switch location={location}>
|
||||
<Route path={`${match.path}`} exact>
|
||||
<p>About</p>
|
||||
</Route>
|
||||
|
||||
<Route path={`${match.path}/servers`} exact>
|
||||
<p>Servers</p>
|
||||
</Route>
|
||||
</Switch>
|
||||
</AdminContentBlock>
|
||||
);
|
||||
};
|
||||
|
||||
export default () => {
|
||||
return (
|
||||
<Context.Provider>
|
||||
<UserRouter/>
|
||||
</Context.Provider>
|
||||
);
|
||||
};
|
|
@ -130,7 +130,7 @@ const UsersContainer = () => {
|
|||
|
||||
<div css={tw`ml-4`}>
|
||||
<div css={tw`text-sm text-neutral-200`}>
|
||||
{user.firstName} {user.lastName}
|
||||
Silly User
|
||||
</div>
|
||||
|
||||
<div css={tw`text-sm text-neutral-400`}>
|
||||
|
|
|
@ -20,7 +20,7 @@ import ServersContainer from '@/components/admin/servers/ServersContainer';
|
|||
import NewServerContainer from '@/components/admin/servers/NewServerContainer';
|
||||
import UsersContainer from '@/components/admin/users/UsersContainer';
|
||||
import NewUserContainer from '@/components/admin/users/NewUserContainer';
|
||||
import UserEditContainer from '@/components/admin/users/UserEditContainer';
|
||||
import UserRouter from '@/components/admin/users/UserRouter';
|
||||
import RolesContainer from '@/components/admin/roles/RolesContainer';
|
||||
import RoleEditContainer from '@/components/admin/roles/RoleEditContainer';
|
||||
import NestsContainer from '@/components/admin/nests/NestsContainer';
|
||||
|
@ -173,7 +173,7 @@ const AdminRouter = ({ location, match }: RouteComponentProps) => {
|
|||
<img src={user !== undefined ? user.avatarURL + '?s=64' : ''} alt="Profile Picture" css={tw`h-10 w-10 rounded-full select-none`} />
|
||||
|
||||
<div css={tw`flex flex-col ml-4`}>
|
||||
<span css={tw`font-header font-medium text-sm text-neutral-50 whitespace-nowrap leading-tight select-none`}>{user?.firstName} {user?.lastName}</span>
|
||||
<span css={tw`font-header font-medium text-sm text-neutral-50 whitespace-nowrap leading-tight select-none`}>Silly User</span>
|
||||
<span css={tw`font-header font-normal text-xs text-neutral-300 whitespace-nowrap leading-tight select-none`}>{user?.roleName}</span>
|
||||
</div>
|
||||
|
||||
|
@ -237,8 +237,7 @@ const AdminRouter = ({ location, match }: RouteComponentProps) => {
|
|||
<Route path={`${match.path}/users/new`} component={NewUserContainer} exact/>
|
||||
<Route
|
||||
path={`${match.path}/users/:id`}
|
||||
component={UserEditContainer}
|
||||
exact
|
||||
component={UserRouter}
|
||||
/>
|
||||
|
||||
<Route path={`${match.path}/roles`} component={RolesContainer} exact/>
|
||||
|
|
|
@ -5,8 +5,6 @@ export interface UserData {
|
|||
uuid: string;
|
||||
username: string;
|
||||
email: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
language: string;
|
||||
rootAdmin: boolean;
|
||||
useTotp: boolean;
|
||||
|
|
Loading…
Reference in a new issue