Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a permission check for getting server docker image in Java Version Modal #4795

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import Can from '@/components/elements/Can';
import getServerStartup from '@/api/swr/getServerStartup';
import InputSpinner from '@/components/elements/InputSpinner';
import { usePermissions } from '@/plugins/usePermissions';

const MATCH_ERRORS = [
'minecraft 1.17 requires running the server with java 16 or above',
'minecraft 1.18 requires running the server with java 17 or above',
'minecraft 1.19 requires running the server with Java 17 or above',
'java.lang.unsupportedclassversionerror',
'unsupported major.minor version',
'has been compiled by a more recent version of the java runtime',
Expand All @@ -31,14 +33,20 @@
const { clearFlashes, clearAndAddHttpError } = useFlash();
const { instance } = ServerContext.useStoreState(state => state.socket);

const { data, isValidating, mutate } = getServerStartup(uuid, undefined, { revalidateOnMount: false });
const hasPermission = usePermissions('startup.docker-image');

const { data, isValidating, mutate } = hasPermission
? getServerStartup(uuid, undefined, { revalidateOnMount: false })
: { data: undefined, isValidating: false, mutate: undefined };

useEffect(() => {
if (!visible) return;

mutate().then(value => {
setSelectedVersion(Object.values(value?.dockerImages || [])[0] || '');
});
if (mutate) {
mutate().then((value) => {

Check failure on line 46 in resources/scripts/components/server/features/JavaVersionModalFeature.tsx

View workflow job for this annotation

GitHub Actions / Lint

Replace `(value)` with `value`
setSelectedVersion(Object.values(value?.dockerImages || [])[0] || '');
});
}
}, [visible]);

useWebsocketEvent(SocketEvent.CONSOLE_OUTPUT, data => {
Expand Down
Loading