Skip to content

Commit

Permalink
init server tags prototype with config variable and corresponding dro…
Browse files Browse the repository at this point in the history
…pdown in room settings
  • Loading branch information
Ithanil committed Apr 22, 2024
1 parent 3f64bef commit 9dfbd56
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import React from 'react';
import {
Row, Col, Button, Stack,
Row, Col, Button, Stack, Dropdown,
} from 'react-bootstrap';
import { useParams } from 'react-router-dom';
import Card from 'react-bootstrap/Card';
Expand All @@ -33,6 +33,7 @@ import { useAuth } from '../../../../contexts/auth/AuthProvider';
import UpdateRoomNameForm from './forms/UpdateRoomNameForm';
import useRoom from '../../../../hooks/queries/rooms/useRoom';
import UnshareRoom from './UnshareRoom';
import SimpleSelect from '../../../shared_components/utilities/SimpleSelect';

export default function RoomSettings() {
const { t } = useTranslation();
Expand All @@ -45,6 +46,12 @@ export default function RoomSettings() {
const updateMutationWrapper = () => useUpdateRoomSetting(friendlyId);
const deleteMutationWrapper = (args) => useDeleteRoom({ friendlyId, ...args });

const serverTagsMap = (process.env.SERVER_TAGS_MAP || '').split(",").reduce((map, pair) => {
let [key, value] = pair.split(":");
map[key] = value;
return map;
}, {});

return (
<div id="room-settings" className="pt-3">
<Card className="mx-auto p-4 border-0 card-shadow">
Expand All @@ -66,6 +73,23 @@ export default function RoomSettings() {
config={roomConfigs?.glModeratorAccessCode}
description={t('room.settings.generate_mods_access_code')}
/>
<Row>
<SimpleSelect defaultValue=''>
{
<Dropdown.Item key='' value=''>
</Dropdown.Item>
}

{
<Dropdown.Item
key={Object.keys(serverTagsMap)[0]}
value={Object.values(serverTagsMap)[0]}
>
{ Object.values(serverTagsMap)[0] }
</Dropdown.Item>
}
</SimpleSelect>
</Row>
</Col>
<Col className="ps-4">
<Row> <h6 className="text-brand">{ t('room.settings.user_settings') }</h6> </Row>
Expand Down
4 changes: 4 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ class ApplicationRecord < ActiveRecord::Base
def virus_scan?
ENV.fetch('CLAMAV_SCANNING', 'false') == 'true'
end

def server_tags_hash
ENV.fetch('SERVER_TAGS_MAP', '').split(",").map { |pair| pair.split(":") }.to_h
end
end
4 changes: 3 additions & 1 deletion esbuild.dev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as esbuild from 'esbuild';

// Fetch 'RELATIVE_URL_ROOT' ENV variable value while removing any trailing slashes.
const relativeUrlRoot = (process.env.RELATIVE_URL_ROOT || '').replace(/\/*$/, '');
const serverTagsMap = (process.env.SERVER_TAGS_MAP || '');

esbuild.context({
entryPoints: ['app/javascript/main.jsx'],
Expand All @@ -15,6 +16,7 @@ esbuild.context({
define: {
'process.env.RELATIVE_URL_ROOT': `"${relativeUrlRoot}"`,
'process.env.OMNIAUTH_PATH': `"${relativeUrlRoot}/auth/openid_connect"`, // currently, only OIDC is implemented
'process.env.SERVER_TAGS_MAP': `"${serverTagsMap}"`,
},
}).then(context => {
if (process.argv.includes("--watch")) {
Expand All @@ -30,4 +32,4 @@ esbuild.context({
}).catch((e) => {
console.error('build failed:', e);
process.exit(1)
})
})
2 changes: 2 additions & 0 deletions esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as esbuild from 'esbuild';

// Fetch 'RELATIVE_URL_ROOT' ENV variable value while removing any trailing slashes.
const relativeUrlRoot = (process.env.RELATIVE_URL_ROOT || '').replace(/\/*$/, '');
const serverTagsMap = (process.env.SERVER_TAGS_MAP || '');

await esbuild.build({
entryPoints: ['app/javascript/main.jsx'],
Expand All @@ -15,6 +16,7 @@ await esbuild.build({
define: {
'process.env.RELATIVE_URL_ROOT': `"${relativeUrlRoot}"`,
'process.env.OMNIAUTH_PATH': `"${relativeUrlRoot}/auth/openid_connect"`, // currently, only OIDC is implemented
'process.env.SERVER_TAGS_MAP': `"${serverTagsMap}"`,
},
});

Expand Down

0 comments on commit 9dfbd56

Please sign in to comment.