mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
# Addresses #9349 # Implements https://www.loom.com/share/bbf8d6f97fe74e65a0c9a394f1bda3f1 - New Controls page, only visible to Global|Team Admins|Maintainers - Header for free users is 'Controls', for premium is a teams filter dropdown that defaults to 'No teams,' which filters via updating the URL query param "team_id" - Includes tabs macUpdates (default) and macSettings - Cleaned up how site nav items are conditionally included/excluded based on authorization – see `frontend/components/top_nav/SiteTopNav/navItems.ts` - Updated masthead styles: Removed icons from site nav links; updated colors and spacing; Updated default user avatar TBD in separate PR (waiting on guidance) # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/` - [x] Updated testing suite inventory - [x] Manual QA for all new/changed functionality Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
92 lines
2.4 KiB
TypeScript
92 lines
2.4 KiB
TypeScript
import React, { useState } from "react";
|
|
|
|
import Button from "components/buttons/Button";
|
|
// @ts-ignore
|
|
import InputField from "components/forms/fields/InputField";
|
|
import {
|
|
IAppConfigFormProps,
|
|
IFormField,
|
|
IAppConfigFormErrors,
|
|
} from "../constants";
|
|
|
|
const baseClass = "app-config-form";
|
|
|
|
const WebAddress = ({
|
|
appConfig,
|
|
handleSubmit,
|
|
isUpdatingSettings,
|
|
}: IAppConfigFormProps): JSX.Element => {
|
|
const [formData, setFormData] = useState<any>({
|
|
serverURL: appConfig.server_settings.server_url || "",
|
|
});
|
|
|
|
const { serverURL } = formData;
|
|
|
|
const [formErrors, setFormErrors] = useState<IAppConfigFormErrors>({});
|
|
|
|
const handleInputChange = ({ name, value }: IFormField) => {
|
|
setFormData({ ...formData, [name]: value });
|
|
setFormErrors({});
|
|
};
|
|
|
|
const validateForm = () => {
|
|
const errors: IAppConfigFormErrors = {};
|
|
|
|
if (!serverURL) {
|
|
errors.server_url = "Fleet server URL must be present";
|
|
}
|
|
|
|
setFormErrors(errors);
|
|
};
|
|
|
|
const onFormSubmit = (evt: React.MouseEvent<HTMLFormElement>) => {
|
|
evt.preventDefault();
|
|
|
|
// Formatting of API not UI
|
|
const formDataToSubmit = {
|
|
server_settings: {
|
|
server_url: serverURL,
|
|
live_query_disabled: appConfig.server_settings.live_query_disabled,
|
|
enable_analytics: appConfig.server_settings.enable_analytics,
|
|
},
|
|
};
|
|
|
|
handleSubmit(formDataToSubmit);
|
|
};
|
|
|
|
return (
|
|
<form className={baseClass} onSubmit={onFormSubmit} autoComplete="off">
|
|
<div className={`${baseClass}__section`}>
|
|
<h2>Fleet web address</h2>
|
|
<div className={`${baseClass}__inputs`}>
|
|
<InputField
|
|
label="Fleet app URL"
|
|
hint={
|
|
<span>
|
|
Include base path only (eg. no <code>/latest</code>)
|
|
</span>
|
|
}
|
|
onChange={handleInputChange}
|
|
name="serverURL"
|
|
value={serverURL}
|
|
parseTarget
|
|
onBlur={validateForm}
|
|
error={formErrors.server_url}
|
|
tooltip="The base URL of this instance for use in Fleet links."
|
|
/>
|
|
</div>
|
|
</div>
|
|
<Button
|
|
type="submit"
|
|
variant="brand"
|
|
disabled={Object.keys(formErrors).length > 0}
|
|
className="save-loading"
|
|
isLoading={isUpdatingSettings}
|
|
>
|
|
Save
|
|
</Button>
|
|
</form>
|
|
);
|
|
};
|
|
|
|
export default WebAddress;
|