panel icon indicating copy to clipboard operation
panel copied to clipboard

Nest and egg limitation to navigation

Open makkmarci13 opened this issue 3 years ago • 3 comments

Is there an existing feature request for this?

  • [X] I have searched the existing issues before opening this feature request.

Describe the feature you would like to see.

I would be happy if this modification will be accepted and integrated to the panel. I made a modification to ServerRouter and server routes with which menus can be limited to specified egg or nest id(s).

Describe the solution you'd like.

Please paste this line to /app/Transformers/Api/Client/ServerTransformer.php under the 'is_transferring' => !is_null($server->transfer) line

'nest_id' => $server->nest_id, 'egg_id' => $server->egg_id,

Please paste this lines to /resources/scripts/routers/routes.ts under the permission: string | string[] | null; line

nestId?: number; eggId?: number; nestIds?: number[]; eggIds?: number[];

Please paste this line to /resources/scripts/api/server/getServer.ts under the allocations: Allocation[]; line

nestId: number; eggId: number;

Please paste this line to /resources/scripts/api/server/getServer.ts under the allocations: ((data.relationships?.allocations as FractalResponseList | undefined)?.data || []).map(rawDataToServerAllocation), line

nestId: data.nest_id, eggId: data.egg_id,

Please paste this lines to /resources/scripts/routers/ServerRouter.tsx under the import routes from '@/routers/routes'; line

import { Navigation, ComponentLoader } from '@/routers/ServerElements';

Please replace the marked codes in (help02.png) to this line (it should look like help04.png)

<Navigation />

Please replace the marked codes in (help03.png) to this line (it should look like help04.png)

<ComponentLoader />

And devs simple can write nestId: 1, or eggId: 1, or nestIds: [1, 2], or eggIds: [1, 2], to the menu block.

ServerElement.tsx to resources/scripts/routers/ folder: https://pastebin.com/aAfbKMTF

help02: help02

help03: help03

help04: help04

Additional context to this request.

No response

makkmarci13 avatar Jun 28 '22 12:06 makkmarci13

Why not just make a PR?

Boy132 avatar Jun 28 '22 12:06 Boy132

Whats your plan when nests and eggs have different IDs on each installation?

DaneEveritt avatar Jun 28 '22 22:06 DaneEveritt

I just want this build-in limitation (obviously it'll be helpful for addons), For users, it'll easier to install, because they need to edit less files. And also helpful for all devs, cause currently everybody use own system to limit these, and if somebody use many addons from many devs, installiation can be very hard (if client don't know anything about react). (missclicked to close firstly)

makkmarci13 avatar Jun 28 '22 22:06 makkmarci13

FYI it looks like the ServerElements file no longer exists in newer Pterodactyl installs? So this line item appears to reference a file that isn't there:

import { Navigation, ComponentLoader } from '@/routers/ServerElements';

When I do a yarn run build:production I see this output:

ERROR in ./resources/scripts/routers/ServerRouter.tsx
Module not found: Error: Can't resolve '@/routers/ServerElements' in '/var/www/pterodactyl/resources/scripts/routers'
 @ ./resources/scripts/routers/ServerRouter.tsx 19:0-71 79:138-148 87:435-450
 @ ./resources/scripts/components/App.tsx
 @ ./resources/scripts/index.tsx
 @ multi react-hot-loader/patch ./resources/scripts/index.tsx

ERROR in resources/scripts/routers/ServerRouter.tsx:23:45
TS2307: Cannot find module '@/routers/ServerElements' or its corresponding type declarations.
    21 | import PermissionRoute from '@/components/elements/PermissionRoute';
    22 | import routes from '@/routers/routes';
  > 23 | import { Navigation, ComponentLoader } from '@/routers/ServerElements';
       |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    24 |
    25 | export default () => {
    26 |     const match = useRouteMatch<{ id: string }>();
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

UPDATE / SOLVED: I was able to grab the file from a resource via Discord, also needed to change my $rust_egg_ids = [19]; value to $rust_egg_ids = [14]; in /var/www/pterodactyl/app/Http/Middleware/Api/Client/Server/IsRust.php file.

jchambo avatar Oct 01 '22 13:10 jchambo