Add readonly mode to backend, stub out UI for toggles.
parent
e960700f91
commit
6249ea8b0a
|
@ -0,0 +1,10 @@
|
|||
class AddUserInterfaceReadOnlyModeToWebAppConfig < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
safety_assured do
|
||||
add_column :web_app_configs,
|
||||
:user_interface_read_only_mode,
|
||||
:boolean,
|
||||
default: false
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1663,7 +1663,8 @@ CREATE TABLE public.web_app_configs (
|
|||
hide_sensors boolean DEFAULT false,
|
||||
confirm_plant_deletion boolean DEFAULT true,
|
||||
discard_unsaved_sequences boolean DEFAULT false,
|
||||
confirm_sequence_deletion boolean DEFAULT true
|
||||
confirm_sequence_deletion boolean DEFAULT true,
|
||||
user_interface_read_only_mode boolean DEFAULT false
|
||||
);
|
||||
|
||||
|
||||
|
@ -3149,6 +3150,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||
('20190701155706'),
|
||||
('20190709194037'),
|
||||
('20190715214412'),
|
||||
('20190722160305');
|
||||
('20190722160305'),
|
||||
('20190729134954');
|
||||
|
||||
|
||||
|
|
|
@ -318,6 +318,7 @@ export function fakeWebAppConfig(): TaggedWebAppConfig {
|
|||
disable_emergency_unlock_confirmation: false,
|
||||
map_size_x: 2900,
|
||||
map_size_y: 1400,
|
||||
user_interface_read_only_mode: false
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -72,6 +72,13 @@ export const fetchLabFeatures =
|
|||
value: false,
|
||||
displayInvert: true,
|
||||
},
|
||||
{
|
||||
name: t("User Interface Read Only Mode"),
|
||||
description: t(Content.USER_INTERFACE_READ_ONLY_MODE),
|
||||
storageKey: BooleanSetting.user_interface_read_only_mode,
|
||||
value: false,
|
||||
displayInvert: false,
|
||||
}
|
||||
].map(fetchSettingValue(getConfigValue)));
|
||||
|
||||
/** Always allow toggling from true => false (deactivate).
|
||||
|
|
|
@ -538,6 +538,10 @@ export namespace Content {
|
|||
export const EMERGENCY_UNLOCK_CONFIRM_CONFIG =
|
||||
trim(`Confirm when unlocking FarmBot after an emergency stop.`);
|
||||
|
||||
export const USER_INTERFACE_READ_ONLY_MODE =
|
||||
trim(`Disallow account data changes. This does
|
||||
not prevent Farmwares or FarmBot OS from changing settings.`);
|
||||
|
||||
export const CONFIRM_EMERGENCY_UNLOCK_CONFIRM_DISABLE =
|
||||
trim(`Warning! When disabled, clicking the UNLOCK button will immediately
|
||||
unlock FarmBot instead of confirming that it is safe to do so.
|
||||
|
|
|
@ -8,7 +8,6 @@ import {
|
|||
|
||||
/** @fileoverview Resource selectors for SINGULAR resources. */
|
||||
|
||||
/** Wow! */
|
||||
export const getFbosConfig =
|
||||
(i: ResourceIndex): TaggedFbosConfig | undefined =>
|
||||
findAll<TaggedFbosConfig>(i, "FbosConfig")[0];
|
||||
|
|
|
@ -249,3 +249,14 @@ export function getUserAccountSettings(index: ResourceIndex): TaggedUser {
|
|||
export function all(index: ResourceIndex) {
|
||||
return betterCompact(Object.keys(index.all).map(uuid => index.references[uuid]));
|
||||
}
|
||||
|
||||
/** Returns `true` if the user is allowed to modify account data.
|
||||
* This is a helper function of the "readonly" account lock. */
|
||||
export function appIsReadonly(index: ResourceIndex) {
|
||||
const conf = getWebAppConfig(index);
|
||||
if (conf) {
|
||||
return conf.body.user_interface_read_only_mode;
|
||||
} else {
|
||||
return true; // Don't allow data updates until config is found
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ export const BooleanSetting: Record<BooleanConfigKey, BooleanConfigKey> = {
|
|||
discard_unsaved: "discard_unsaved",
|
||||
time_format_24_hour: "time_format_24_hour",
|
||||
disable_emergency_unlock_confirmation: "disable_emergency_unlock_confirmation",
|
||||
user_interface_read_only_mode: "user_interface_read_only_mode",
|
||||
|
||||
/** Farmware settings */
|
||||
show_first_party_farmware: "show_first_party_farmware",
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
"coveralls": "3.0.5",
|
||||
"enzyme": "3.10.0",
|
||||
"enzyme-adapter-react-16": "1.14.0",
|
||||
"farmbot": "8.0.3-rc1",
|
||||
"farmbot": "8.0.3",
|
||||
"i18next": "17.0.6",
|
||||
"lodash": "4.17.15",
|
||||
"markdown-it": "9.0.1",
|
||||
|
|
Loading…
Reference in New Issue