Skip to content

Commit

Permalink
cherry pick more scoped software fixes (#25126)
Browse files Browse the repository at this point in the history
cherry pick for more scoped software via labels fixes
  • Loading branch information
ghernandez345 authored Jan 6, 2025
1 parent 82d9f46 commit 1f05269
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
5 changes: 3 additions & 2 deletions frontend/components/PlatformSelector/PlatformSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ export const PlatformSelector = ({
</Checkbox>
</span>
<div className="form-field__help-text">
To apply the profile to new hosts, you&apos;ll have to delete it and
upload a new profile.
Your policy will only run on the selected platform(s). Additionally, if
install software automation is enabled, it will only be installed on
hosts defined in the software scope.
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/interfaces/software.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export interface ISoftwarePackage {
pending_uninstall: number;
failed_uninstall: number;
};
automatic_install_policies?: ISoftwarePackagePolicy[];
automatic_install_policies?: ISoftwarePackagePolicy[] | null;
install_during_setup?: boolean;
labels_include_any: ILabelSoftwareTitle[] | null;
labels_exclude_any: ILabelSoftwareTitle[] | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import React from "react";
import Button from "components/buttons/Button";
import Modal from "components/Modal";

import { IPackageFormData } from "pages/SoftwarePage/components/PackageForm/PackageForm";

const baseClass = "save-changes-modal";

export interface IConfirmSaveChangesModalProps {
Expand Down Expand Up @@ -38,7 +36,7 @@ const ConfirmSaveChangesModal = ({
<p>{warningText}</p>
<p>
Installs or uninstalls currently running on a host will still
complete, but results wont appear in Fleet.
complete, but results won&apos;t appear in Fleet.
</p>
<p>You cannot undo this action.</p>
<div className="modal-cta-wrap">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { IPackageFormData } from "pages/SoftwarePage/components/PackageForm/Pack
import {
generateSelectedLabels,
getCustomTarget,
getInstallType,
getTargetType,
} from "pages/SoftwarePage/components/PackageForm/helpers";

Expand Down Expand Up @@ -70,11 +71,7 @@ const EditSoftwareModal = ({
});
const [uploadProgress, setUploadProgress] = useState(0);

const {
data: labels,
isLoading: isLoadingLabels,
isError: isErrorLabels,
} = useQuery<ILabelSummary[], Error>(
const { data: labels } = useQuery<ILabelSummary[], Error>(
["custom_labels"],
() => labelsAPI.summary().then((res) => getCustomLabels(res.labels)),
{
Expand Down Expand Up @@ -178,6 +175,7 @@ const EditSoftwareModal = ({
postInstallScript: software.post_install_script || "",
uninstallScript: software.uninstall_script || "",
selfService: software.self_service || false,
installType: getInstallType(software),
targetType: getTargetType(software),
customTarget: getCustomTarget(software),
labelTargets: generateSelectedLabels(software),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ export const CUSTOM_TARGET_OPTIONS: IDropdownOption[] = [
},
];

export const getInstallType = (softwarePackage: ISoftwarePackage) => {
return softwarePackage.automatic_install_policies ? "automatic" : "manual";
};

export const getTargetType = (softwarePackage: ISoftwarePackage) => {
if (!softwarePackage) return "All hosts";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ const DeleteLabelModal = ({
<>
<p>
If a configuration profile uses this label as a custom target, the
profile will break: it won&apos;t be applied to new hosts.
profile will break. After deleting the label, remove broken profiles
and upload new profiles in their place.
</p>
<p>
To apply the profile to new hosts, you&apos;ll have to delete it and
upload a new profile.
If software uses this label as a custom target, the label will not be
able to be deleted. Please remove the label from the software target
first before deleting.
</p>
<div className="modal-cta-wrap">
<Button
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/hosts/ManageHostsPage/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const getDeleteLabelErrorMessages = (error: unknown): string => {
if (hasStatusKey(error) && error.status === 422) {
return getErrorReason(error).includes("built-in")
? "Built-in labels can't be modified or deleted."
: "Couldn't delete. Software uses this label as a custom target. Please delete the software and try again.";
: "Couldn't delete. Software uses this label as a custom target. Remove the label from the software target and try again.";
}

return "Could not delete label. Please try again.";
Expand Down

0 comments on commit 1f05269

Please sign in to comment.