Skip to content

Commit

Permalink
regression: Cloud_Workspace_AirGapped_Restrictions_Remaining_Days v…
Browse files Browse the repository at this point in the history
…isible in admin settings page (#33798)
  • Loading branch information
gabriellsh authored Oct 29, 2024
1 parent 1fdf91e commit 374e1a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import type { EditableSetting, EditableSettingsContextValue } from '../EditableS
import { EditableSettingsContext } from '../EditableSettingsContext';

const defaultQuery: SettingsContextQuery = {};
const defaultOmit: Array<ISetting['_id']> = [];

type EditableSettingsProviderProps = {
children?: ReactNode;
query?: SettingsContextQuery;
omit?: Array<ISetting['_id']>;
};

const EditableSettingsProvider = ({ children, query = defaultQuery }: EditableSettingsProviderProps) => {
const EditableSettingsProvider = ({ children, query = defaultQuery, omit = defaultOmit }: EditableSettingsProviderProps) => {
const settingsCollectionRef = useRef<Mongo.Collection<EditableSetting>>(null) as MutableRefObject<Mongo.Collection<EditableSetting>>;
const persistedSettings = useSettings(query);

Expand All @@ -39,7 +41,13 @@ const EditableSettingsProvider = ({ children, query = defaultQuery }: EditableSe
for (const { _id, ...fields } of persistedSettings) {
settingsCollection.upsert(_id, { $set: { ...fields }, $unset: { changed: true } });
}
}, [getSettingsCollection, persistedSettings]);
// TODO: Remove option to omit settings from admin pages manually
// This is a very wacky workaround due to lack of support to omit settings from the
// admin settings page while keeping them public.
if (omit.length > 0) {
settingsCollection.remove({ _id: { $in: omit } });
}
}, [getSettingsCollection, persistedSettings, omit]);

const queryEditableSetting = useMemo(() => {
const validateSettingQueries = (
Expand Down
4 changes: 3 additions & 1 deletion apps/meteor/client/views/admin/settings/SettingsRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import EditableSettingsProvider from './EditableSettingsProvider';
import SettingsGroupSelector from './SettingsGroupSelector';
import SettingsPage from './SettingsPage';

const omittedSettings = ['Cloud_Workspace_AirGapped_Restrictions_Remaining_Days'];

export const SettingsRoute = (): ReactElement => {
const hasPermission = useIsPrivilegedSettingsContext();
const groupId = useRouteParameter('group');
Expand All @@ -21,7 +23,7 @@ export const SettingsRoute = (): ReactElement => {
}

return (
<EditableSettingsProvider>
<EditableSettingsProvider omit={omittedSettings}>
<SettingsGroupSelector groupId={groupId} onClickBack={() => router.navigate('/admin/settings')} />
</EditableSettingsProvider>
);
Expand Down

0 comments on commit 374e1a4

Please sign in to comment.