fleet/frontend/pages/SoftwarePage/components/forms/PackageAdvancedOptions/PackageAdvancedOptions.tsx

296 lines
8.6 KiB
TypeScript
Raw Normal View History

import React, { useState } from "react";
import { noop } from "lodash";
import { LEARN_MORE_ABOUT_BASE_LINK } from "utilities/constants";
import { getExtensionFromFileName } from "utilities/file/fileUtils";
import {
isPackageType,
isWindowsPackageType,
FMA: missing pieces (#22593) # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [ ] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [ ] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for new osquery data ingestion features. - [ ] Added/updated tests - [ ] If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes - [ ] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [ ] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [ ] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [ ] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [ ] Manual QA for all new/changed functionality - For Orbit and Fleet Desktop changes: - [ ] Orbit runs on macOS, Linux and Windows. Check if the orbit feature/bugfix should only apply to one platform (`runtime.GOOS`). - [ ] Manual QA must be performed in the three main OSs, macOS, Windows and Linux. - [ ] Auto-update manual QA, from released version of component to new version (see [tools/tuf/test](../tools/tuf/test/README.md)).
2024-10-03 17:49:27 +00:00
isFleetMaintainedPackageType,
PackageType,
} from "interfaces/package_type";
import CustomLink from "components/CustomLink";
import RevealButton from "components/buttons/RevealButton";
import { IPackageFormData } from "../PackageForm/PackageForm";
import AdvancedOptionsFields from "../AdvancedOptionsFields";
const getSupportedScriptTypeText = (pkgType: PackageType) => {
return `Currently, ${
UI – Uninstall features for host details, install/uninstall actions, activity feed, misc other items (#21933) ## #21566 - Host details updates for Uninstall packages details > software page. Full tasks outlined in the issue, [Figma here](https://www.figma.com/design/ToQaK2yUJwDyzagTdrbOfX/%2320320-Uninstall-packages?node-id=5364-13173&m=dev) **Updated install status tooltips:** ![install-status-tooltips](https://github.com/user-attachments/assets/9869c7d6-f953-4adc-9692-52f5dad9d81a) **Uninstall action:** ![uninstall-action](https://github.com/user-attachments/assets/189d5755-556c-48ca-8824-08db14ec95d4) **Update install details:** ![Screenshot 2024-09-09 at 1 12 58 PM](https://github.com/user-attachments/assets/f52b349b-9f01-49d4-b952-6efd60f29979) ## #21931 - updated specs for install/uninstall states ## #21568 - activity feed items for Uninstall ![Screenshot 2024-09-09 at 5 00 07 PM](https://github.com/user-attachments/assets/eb61949a-9f8d-4b9e-a437-2d31a6808f07) ![Screenshot 2024-09-09 at 5 42 52 PM](https://github.com/user-attachments/assets/a8c2de0e-27e3-4d2b-bf69-702ea7b72e48) ![Screenshot 2024-09-09 at 5 43 03 PM](https://github.com/user-attachments/assets/b6127ed3-6fcf-439e-aa3d-91038a025d92) ## #21567 - Uninstall details modal ![Screenshot 2024-09-10 at 7 42 18 PM](https://github.com/user-attachments/assets/a42e4e4a-eadd-4e75-84c5-c5f6a6230950) _remaining TODO_: - [x] manually QA 'failed' states - [x] determine where to source timestamp from for uninstall activities - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com> Co-authored-by: Victor Lyuboslavsky <victor@fleetdm.com>
2024-09-12 15:51:59 +00:00
isWindowsPackageType(pkgType) ? "PowerS" : "s"
}hell scripts are supported.`;
};
const PKG_TYPE_TO_ID_TEXT = {
pkg: "package IDs",
deb: "package name",
rpm: "package name",
msi: "product code",
exe: "software name",
Add support for zip files as Windows FMAs (#36841) ### Summary This PR adds support for `.zip` files as Windows Fleet Managed Apps (FMAs). Zip files on Windows are treated similarly to `.exe` files and require custom install/uninstall scripts, typically used for AppX/MSIX packages that are distributed as zip archives. ### Changes **Backend:** - Added `.zip` as a supported Windows package type in `SoftwareInstallerPlatformFromExtension` - Updated validation to require install/uninstall scripts for zip files (similar to `.exe` files) - Added `addZipPackageMetadata` function to handle zip file metadata extraction - Updated error messages to include `.zip` in the list of supported file types - Enhanced `appExists` validation to detect provisioned AppX packages (packages that are provisioned for all users but don't show up in the programs table until a user logs in) - Added version normalization logic to handle version string differences (e.g., "11.2.1495.0" vs "11.2.1495") - Updated winget ingester to recognize zip files and default to user scope for MSIX/zip installers **Frontend:** - Added `.zip` to `windowsPackageTypes` in `package_type.ts` - Updated `PackageAdvancedOptions` component to require install/uninstall scripts for zip files - Added validation rules for zip files in `PackageForm/helpers.tsx` - Updated help text and tooltips to indicate script requirements for zip packages - Updated `software_install_scripts.ts` to include zip in default script handling **Maintained Apps:** - Added Microsoft Company Portal as a maintained app example using zip files - Created install/uninstall PowerShell scripts that: - Extract zip files containing AppX packages - Provision packages for all future users (works in headless environments) - Install packages for the current user - Handle both provisioned and installed package detection **Tests:** - Updated integration tests to include `.zip` in supported file type error messages - Updated unit tests for `SoftwareInstallerPlatformFromExtension` and `SofwareInstallerSourceFromExtensionAndName` ### Use Case This enables distribution of Windows AppX/MSIX packages that are packaged as zip files (common for Microsoft Store apps like Company Portal). The implementation handles both provisioned packages (for all users) and user-installed packages, ensuring detection works in both headless and interactive environments. ### Testing - Updated existing tests to include zip file support - Added Microsoft Company Portal as a maintained app example with full install/uninstall scripts --- **Note:** This PR follows the same pattern as `.exe` file support, requiring custom install/uninstall scripts since zip files can contain various content types that need custom handling.
2025-12-15 17:03:43 +00:00
zip: "software name",
sh: "package name",
ps1: "package name",
2025-10-28 16:44:17 +00:00
ipa: "software name",
} as const;
const getInstallScriptTooltip = (pkgType: PackageType) => {
Add support for zip files as Windows FMAs (#36841) ### Summary This PR adds support for `.zip` files as Windows Fleet Managed Apps (FMAs). Zip files on Windows are treated similarly to `.exe` files and require custom install/uninstall scripts, typically used for AppX/MSIX packages that are distributed as zip archives. ### Changes **Backend:** - Added `.zip` as a supported Windows package type in `SoftwareInstallerPlatformFromExtension` - Updated validation to require install/uninstall scripts for zip files (similar to `.exe` files) - Added `addZipPackageMetadata` function to handle zip file metadata extraction - Updated error messages to include `.zip` in the list of supported file types - Enhanced `appExists` validation to detect provisioned AppX packages (packages that are provisioned for all users but don't show up in the programs table until a user logs in) - Added version normalization logic to handle version string differences (e.g., "11.2.1495.0" vs "11.2.1495") - Updated winget ingester to recognize zip files and default to user scope for MSIX/zip installers **Frontend:** - Added `.zip` to `windowsPackageTypes` in `package_type.ts` - Updated `PackageAdvancedOptions` component to require install/uninstall scripts for zip files - Added validation rules for zip files in `PackageForm/helpers.tsx` - Updated help text and tooltips to indicate script requirements for zip packages - Updated `software_install_scripts.ts` to include zip in default script handling **Maintained Apps:** - Added Microsoft Company Portal as a maintained app example using zip files - Created install/uninstall PowerShell scripts that: - Extract zip files containing AppX packages - Provision packages for all future users (works in headless environments) - Install packages for the current user - Handle both provisioned and installed package detection **Tests:** - Updated integration tests to include `.zip` in supported file type error messages - Updated unit tests for `SoftwareInstallerPlatformFromExtension` and `SofwareInstallerSourceFromExtensionAndName` ### Use Case This enables distribution of Windows AppX/MSIX packages that are packaged as zip files (common for Microsoft Store apps like Company Portal). The implementation handles both provisioned packages (for all users) and user-installed packages, ensuring detection works in both headless and interactive environments. ### Testing - Updated existing tests to include zip file support - Added Microsoft Company Portal as a maintained app example with full install/uninstall scripts --- **Note:** This PR follows the same pattern as `.exe` file support, requiring custom install/uninstall scripts since zip files can contain various content types that need custom handling.
2025-12-15 17:03:43 +00:00
if (pkgType === "exe" || pkgType === "tar.gz") {
if (pkgType === "exe") {
return "Required for .exe packages.";
}
return "Required for .tar.gz archives.";
}
if (pkgType === "zip" && isWindowsPackageType(pkgType)) {
return "Required for .zip packages.";
}
return undefined;
};
const getInstallHelpText = (pkgType: PackageType) => {
if (pkgType === "exe") {
return (
<>
For Windows, Fleet only creates install scripts for .msi packages. Use
the $INSTALLER_PATH variable to point to the installer.{" "}
{getSupportedScriptTypeText(pkgType)}{" "}
<CustomLink
url={`${LEARN_MORE_ABOUT_BASE_LINK}/exe-install-scripts`}
text="Learn more"
newTab
/>
</>
);
}
Add support for zip files as Windows FMAs (#36841) ### Summary This PR adds support for `.zip` files as Windows Fleet Managed Apps (FMAs). Zip files on Windows are treated similarly to `.exe` files and require custom install/uninstall scripts, typically used for AppX/MSIX packages that are distributed as zip archives. ### Changes **Backend:** - Added `.zip` as a supported Windows package type in `SoftwareInstallerPlatformFromExtension` - Updated validation to require install/uninstall scripts for zip files (similar to `.exe` files) - Added `addZipPackageMetadata` function to handle zip file metadata extraction - Updated error messages to include `.zip` in the list of supported file types - Enhanced `appExists` validation to detect provisioned AppX packages (packages that are provisioned for all users but don't show up in the programs table until a user logs in) - Added version normalization logic to handle version string differences (e.g., "11.2.1495.0" vs "11.2.1495") - Updated winget ingester to recognize zip files and default to user scope for MSIX/zip installers **Frontend:** - Added `.zip` to `windowsPackageTypes` in `package_type.ts` - Updated `PackageAdvancedOptions` component to require install/uninstall scripts for zip files - Added validation rules for zip files in `PackageForm/helpers.tsx` - Updated help text and tooltips to indicate script requirements for zip packages - Updated `software_install_scripts.ts` to include zip in default script handling **Maintained Apps:** - Added Microsoft Company Portal as a maintained app example using zip files - Created install/uninstall PowerShell scripts that: - Extract zip files containing AppX packages - Provision packages for all future users (works in headless environments) - Install packages for the current user - Handle both provisioned and installed package detection **Tests:** - Updated integration tests to include `.zip` in supported file type error messages - Updated unit tests for `SoftwareInstallerPlatformFromExtension` and `SofwareInstallerSourceFromExtensionAndName` ### Use Case This enables distribution of Windows AppX/MSIX packages that are packaged as zip files (common for Microsoft Store apps like Company Portal). The implementation handles both provisioned packages (for all users) and user-installed packages, ensuring detection works in both headless and interactive environments. ### Testing - Updated existing tests to include zip file support - Added Microsoft Company Portal as a maintained app example with full install/uninstall scripts --- **Note:** This PR follows the same pattern as `.exe` file support, requiring custom install/uninstall scripts since zip files can contain various content types that need custom handling.
2025-12-15 17:03:43 +00:00
if (pkgType === "zip") {
return (
<>
For Windows, Fleet only creates install scripts for .msi packages. Use
the $INSTALLER_PATH variable to point to the installer.{" "}
{getSupportedScriptTypeText(pkgType)}{" "}
<CustomLink
url={`${LEARN_MORE_ABOUT_BASE_LINK}/exe-install-scripts`}
text="Learn more"
newTab
/>
</>
);
}
return (
<>
Use the $INSTALLER_PATH variable to point to the installer.{" "}
{getSupportedScriptTypeText(pkgType)}{" "}
<CustomLink
url={`${LEARN_MORE_ABOUT_BASE_LINK}/install-scripts`}
text="Learn more about install scripts"
newTab
/>
</>
);
};
const getPostInstallHelpText = (pkgType: PackageType) => {
return getSupportedScriptTypeText(pkgType);
};
const getUninstallScriptTooltip = (pkgType: PackageType) => {
Add support for zip files as Windows FMAs (#36841) ### Summary This PR adds support for `.zip` files as Windows Fleet Managed Apps (FMAs). Zip files on Windows are treated similarly to `.exe` files and require custom install/uninstall scripts, typically used for AppX/MSIX packages that are distributed as zip archives. ### Changes **Backend:** - Added `.zip` as a supported Windows package type in `SoftwareInstallerPlatformFromExtension` - Updated validation to require install/uninstall scripts for zip files (similar to `.exe` files) - Added `addZipPackageMetadata` function to handle zip file metadata extraction - Updated error messages to include `.zip` in the list of supported file types - Enhanced `appExists` validation to detect provisioned AppX packages (packages that are provisioned for all users but don't show up in the programs table until a user logs in) - Added version normalization logic to handle version string differences (e.g., "11.2.1495.0" vs "11.2.1495") - Updated winget ingester to recognize zip files and default to user scope for MSIX/zip installers **Frontend:** - Added `.zip` to `windowsPackageTypes` in `package_type.ts` - Updated `PackageAdvancedOptions` component to require install/uninstall scripts for zip files - Added validation rules for zip files in `PackageForm/helpers.tsx` - Updated help text and tooltips to indicate script requirements for zip packages - Updated `software_install_scripts.ts` to include zip in default script handling **Maintained Apps:** - Added Microsoft Company Portal as a maintained app example using zip files - Created install/uninstall PowerShell scripts that: - Extract zip files containing AppX packages - Provision packages for all future users (works in headless environments) - Install packages for the current user - Handle both provisioned and installed package detection **Tests:** - Updated integration tests to include `.zip` in supported file type error messages - Updated unit tests for `SoftwareInstallerPlatformFromExtension` and `SofwareInstallerSourceFromExtensionAndName` ### Use Case This enables distribution of Windows AppX/MSIX packages that are packaged as zip files (common for Microsoft Store apps like Company Portal). The implementation handles both provisioned packages (for all users) and user-installed packages, ensuring detection works in both headless and interactive environments. ### Testing - Updated existing tests to include zip file support - Added Microsoft Company Portal as a maintained app example with full install/uninstall scripts --- **Note:** This PR follows the same pattern as `.exe` file support, requiring custom install/uninstall scripts since zip files can contain various content types that need custom handling.
2025-12-15 17:03:43 +00:00
if (pkgType === "exe" || pkgType === "tar.gz") {
if (pkgType === "exe") {
return "Required for .exe packages.";
}
return "Required for .tar.gz archives.";
}
if (pkgType === "zip" && isWindowsPackageType(pkgType)) {
return "Required for .zip packages.";
}
return undefined;
};
const getUninstallHelpText = (pkgType: PackageType) => {
Add support for zip files as Windows FMAs (#36841) ### Summary This PR adds support for `.zip` files as Windows Fleet Managed Apps (FMAs). Zip files on Windows are treated similarly to `.exe` files and require custom install/uninstall scripts, typically used for AppX/MSIX packages that are distributed as zip archives. ### Changes **Backend:** - Added `.zip` as a supported Windows package type in `SoftwareInstallerPlatformFromExtension` - Updated validation to require install/uninstall scripts for zip files (similar to `.exe` files) - Added `addZipPackageMetadata` function to handle zip file metadata extraction - Updated error messages to include `.zip` in the list of supported file types - Enhanced `appExists` validation to detect provisioned AppX packages (packages that are provisioned for all users but don't show up in the programs table until a user logs in) - Added version normalization logic to handle version string differences (e.g., "11.2.1495.0" vs "11.2.1495") - Updated winget ingester to recognize zip files and default to user scope for MSIX/zip installers **Frontend:** - Added `.zip` to `windowsPackageTypes` in `package_type.ts` - Updated `PackageAdvancedOptions` component to require install/uninstall scripts for zip files - Added validation rules for zip files in `PackageForm/helpers.tsx` - Updated help text and tooltips to indicate script requirements for zip packages - Updated `software_install_scripts.ts` to include zip in default script handling **Maintained Apps:** - Added Microsoft Company Portal as a maintained app example using zip files - Created install/uninstall PowerShell scripts that: - Extract zip files containing AppX packages - Provision packages for all future users (works in headless environments) - Install packages for the current user - Handle both provisioned and installed package detection **Tests:** - Updated integration tests to include `.zip` in supported file type error messages - Updated unit tests for `SoftwareInstallerPlatformFromExtension` and `SofwareInstallerSourceFromExtensionAndName` ### Use Case This enables distribution of Windows AppX/MSIX packages that are packaged as zip files (common for Microsoft Store apps like Company Portal). The implementation handles both provisioned packages (for all users) and user-installed packages, ensuring detection works in both headless and interactive environments. ### Testing - Updated existing tests to include zip file support - Added Microsoft Company Portal as a maintained app example with full install/uninstall scripts --- **Note:** This PR follows the same pattern as `.exe` file support, requiring custom install/uninstall scripts since zip files can contain various content types that need custom handling.
2025-12-15 17:03:43 +00:00
// Check for Windows zip files first (before isFleetMaintainedPackageType check)
if (pkgType === "zip" && isWindowsPackageType(pkgType)) {
return (
<>
For Windows, Fleet only creates uninstall scripts for .msi packages.
$PACKAGE_ID will be populated with the software name from the .zip file
after it&apos;s added. {getSupportedScriptTypeText(pkgType)}{" "}
<CustomLink
url={`${LEARN_MORE_ABOUT_BASE_LINK}/exe-install-scripts`}
text="Learn more"
newTab
/>
</>
);
}
FMA: missing pieces (#22593) # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [ ] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [ ] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for new osquery data ingestion features. - [ ] Added/updated tests - [ ] If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes - [ ] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [ ] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [ ] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [ ] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [ ] Manual QA for all new/changed functionality - For Orbit and Fleet Desktop changes: - [ ] Orbit runs on macOS, Linux and Windows. Check if the orbit feature/bugfix should only apply to one platform (`runtime.GOOS`). - [ ] Manual QA must be performed in the three main OSs, macOS, Windows and Linux. - [ ] Auto-update manual QA, from released version of component to new version (see [tools/tuf/test](../tools/tuf/test/README.md)).
2024-10-03 17:49:27 +00:00
if (isFleetMaintainedPackageType(pkgType)) {
return "Currently, only shell scripts are supported.";
}
if (pkgType === "exe") {
return (
<>
For Windows, Fleet only creates uninstall scripts for .msi packages.
$PACKAGE_ID will be populated with the software name from the .exe file
after it&apos;s added. {getSupportedScriptTypeText(pkgType)}{" "}
<CustomLink
url={`${LEARN_MORE_ABOUT_BASE_LINK}/exe-install-scripts`}
text="Learn more"
newTab
/>
</>
);
FMA: missing pieces (#22593) # Checklist for submitter If some of the following don't apply, delete the relevant line. <!-- Note that API documentation changes are now addressed by the product design team. --> - [ ] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/Committing-Changes.md#changes-files) for more information. - [ ] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for new osquery data ingestion features. - [ ] Added/updated tests - [ ] If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes - [ ] If database migrations are included, checked table schema to confirm autoupdate - For database migrations: - [ ] Checked schema for all modified table for columns that will auto-update timestamps during migration. - [ ] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects. - [ ] Ensured the correct collation is explicitly set for character columns (`COLLATE utf8mb4_unicode_ci`). - [ ] Manual QA for all new/changed functionality - For Orbit and Fleet Desktop changes: - [ ] Orbit runs on macOS, Linux and Windows. Check if the orbit feature/bugfix should only apply to one platform (`runtime.GOOS`). - [ ] Manual QA must be performed in the three main OSs, macOS, Windows and Linux. - [ ] Auto-update manual QA, from released version of component to new version (see [tools/tuf/test](../tools/tuf/test/README.md)).
2024-10-03 17:49:27 +00:00
}
if (pkgType === "tar.gz") {
return (
<>
Currently, only shell scripts are supported.{" "}
<CustomLink
url={`${LEARN_MORE_ABOUT_BASE_LINK}/uninstall-scripts`}
text="Learn more about uninstall scripts"
newTab
/>
</>
);
}
if (pkgType === "msi") {
return (
<>
$UPGRADE_CODE will be populated with the .msi&apos;s upgrade code if
available, and $PACKAGE_ID will be populated with its product code,
after the software is added. {getSupportedScriptTypeText(pkgType)}{" "}
<CustomLink
url={`${LEARN_MORE_ABOUT_BASE_LINK}/uninstall-scripts`}
text="Learn more about uninstall scripts"
newTab
/>
</>
);
}
return (
<>
$PACKAGE_ID will be populated with the {PKG_TYPE_TO_ID_TEXT[pkgType]} from
the .{pkgType} file after the software is added.{" "}
{getSupportedScriptTypeText(pkgType)}{" "}
<CustomLink
url={`${LEARN_MORE_ABOUT_BASE_LINK}/uninstall-scripts`}
text="Learn more about uninstall scripts"
newTab
/>
</>
);
};
const baseClass = "package-advanced-options";
interface IPackageAdvancedOptionsProps {
errors: { preInstallQuery?: string; postInstallScript?: string };
selectedPackage: IPackageFormData["software"];
preInstallQuery?: string;
installScript: string;
postInstallScript?: string;
uninstallScript?: string;
showSchemaButton?: boolean;
onClickShowSchema?: () => void;
onChangePreInstallQuery: (value?: string) => void;
onChangeInstallScript: (value: string) => void;
onChangePostInstallScript: (value?: string) => void;
onChangeUninstallScript: (value?: string) => void;
/** Currently for editing FMA only, users cannot edit */
gitopsCompatible?: boolean;
gitOpsModeEnabled?: boolean;
}
const PackageAdvancedOptions = ({
showSchemaButton = false,
errors,
selectedPackage,
preInstallQuery,
installScript,
postInstallScript,
uninstallScript,
onClickShowSchema = noop,
onChangePreInstallQuery,
onChangeInstallScript,
onChangePostInstallScript,
onChangeUninstallScript,
gitopsCompatible = false,
gitOpsModeEnabled = false,
}: IPackageAdvancedOptionsProps) => {
const [showAdvancedOptions, setShowAdvancedOptions] = useState(false);
const name = selectedPackage?.name || "";
const ext = getExtensionFromFileName(name);
const renderAdvancedOptions = () => {
if (!isPackageType(ext)) {
// this should never happen
return null;
}
return (
<AdvancedOptionsFields
className={`${baseClass}__input-fields`}
showSchemaButton={showSchemaButton}
installScriptTooltip={getInstallScriptTooltip(ext)}
installScriptHelpText={getInstallHelpText(ext)}
postInstallScriptHelpText={getPostInstallHelpText(ext)}
uninstallScriptTooltip={getUninstallScriptTooltip(ext)}
uninstallScriptHelpText={getUninstallHelpText(ext)}
errors={errors}
preInstallQuery={preInstallQuery}
installScript={installScript}
postInstallScript={postInstallScript}
uninstallScript={uninstallScript}
onClickShowSchema={onClickShowSchema}
onChangePreInstallQuery={onChangePreInstallQuery}
onChangeInstallScript={onChangeInstallScript}
onChangePostInstallScript={onChangePostInstallScript}
onChangeUninstallScript={onChangeUninstallScript}
gitopsCompatible={gitopsCompatible}
gitOpsModeEnabled={gitOpsModeEnabled}
/>
);
};
Add support for zip files as Windows FMAs (#36841) ### Summary This PR adds support for `.zip` files as Windows Fleet Managed Apps (FMAs). Zip files on Windows are treated similarly to `.exe` files and require custom install/uninstall scripts, typically used for AppX/MSIX packages that are distributed as zip archives. ### Changes **Backend:** - Added `.zip` as a supported Windows package type in `SoftwareInstallerPlatformFromExtension` - Updated validation to require install/uninstall scripts for zip files (similar to `.exe` files) - Added `addZipPackageMetadata` function to handle zip file metadata extraction - Updated error messages to include `.zip` in the list of supported file types - Enhanced `appExists` validation to detect provisioned AppX packages (packages that are provisioned for all users but don't show up in the programs table until a user logs in) - Added version normalization logic to handle version string differences (e.g., "11.2.1495.0" vs "11.2.1495") - Updated winget ingester to recognize zip files and default to user scope for MSIX/zip installers **Frontend:** - Added `.zip` to `windowsPackageTypes` in `package_type.ts` - Updated `PackageAdvancedOptions` component to require install/uninstall scripts for zip files - Added validation rules for zip files in `PackageForm/helpers.tsx` - Updated help text and tooltips to indicate script requirements for zip packages - Updated `software_install_scripts.ts` to include zip in default script handling **Maintained Apps:** - Added Microsoft Company Portal as a maintained app example using zip files - Created install/uninstall PowerShell scripts that: - Extract zip files containing AppX packages - Provision packages for all future users (works in headless environments) - Install packages for the current user - Handle both provisioned and installed package detection **Tests:** - Updated integration tests to include `.zip` in supported file type error messages - Updated unit tests for `SoftwareInstallerPlatformFromExtension` and `SofwareInstallerSourceFromExtensionAndName` ### Use Case This enables distribution of Windows AppX/MSIX packages that are packaged as zip files (common for Microsoft Store apps like Company Portal). The implementation handles both provisioned packages (for all users) and user-installed packages, ensuring detection works in both headless and interactive environments. ### Testing - Updated existing tests to include zip file support - Added Microsoft Company Portal as a maintained app example with full install/uninstall scripts --- **Note:** This PR follows the same pattern as `.exe` file support, requiring custom install/uninstall scripts since zip files can contain various content types that need custom handling.
2025-12-15 17:03:43 +00:00
const requiresAdvancedOptions =
ext === "exe" || ext === "zip" || ext === "tar.gz";
return (
<div className={baseClass}>
<RevealButton
className={`${baseClass}__accordion-title`}
isShowing={showAdvancedOptions}
showText="Advanced options"
hideText="Advanced options"
caretPosition="after"
onClick={() => setShowAdvancedOptions(!showAdvancedOptions)}
disabled={!selectedPackage || requiresAdvancedOptions}
disabledTooltipContent={
requiresAdvancedOptions ? (
<>Install and uninstall scripts are required for .{ext} packages.</>
) : (
<>
Choose a file to modify <br />
advanced options.
</>
)
}
/>
Add support for zip files as Windows FMAs (#36841) ### Summary This PR adds support for `.zip` files as Windows Fleet Managed Apps (FMAs). Zip files on Windows are treated similarly to `.exe` files and require custom install/uninstall scripts, typically used for AppX/MSIX packages that are distributed as zip archives. ### Changes **Backend:** - Added `.zip` as a supported Windows package type in `SoftwareInstallerPlatformFromExtension` - Updated validation to require install/uninstall scripts for zip files (similar to `.exe` files) - Added `addZipPackageMetadata` function to handle zip file metadata extraction - Updated error messages to include `.zip` in the list of supported file types - Enhanced `appExists` validation to detect provisioned AppX packages (packages that are provisioned for all users but don't show up in the programs table until a user logs in) - Added version normalization logic to handle version string differences (e.g., "11.2.1495.0" vs "11.2.1495") - Updated winget ingester to recognize zip files and default to user scope for MSIX/zip installers **Frontend:** - Added `.zip` to `windowsPackageTypes` in `package_type.ts` - Updated `PackageAdvancedOptions` component to require install/uninstall scripts for zip files - Added validation rules for zip files in `PackageForm/helpers.tsx` - Updated help text and tooltips to indicate script requirements for zip packages - Updated `software_install_scripts.ts` to include zip in default script handling **Maintained Apps:** - Added Microsoft Company Portal as a maintained app example using zip files - Created install/uninstall PowerShell scripts that: - Extract zip files containing AppX packages - Provision packages for all future users (works in headless environments) - Install packages for the current user - Handle both provisioned and installed package detection **Tests:** - Updated integration tests to include `.zip` in supported file type error messages - Updated unit tests for `SoftwareInstallerPlatformFromExtension` and `SofwareInstallerSourceFromExtensionAndName` ### Use Case This enables distribution of Windows AppX/MSIX packages that are packaged as zip files (common for Microsoft Store apps like Company Portal). The implementation handles both provisioned packages (for all users) and user-installed packages, ensuring detection works in both headless and interactive environments. ### Testing - Updated existing tests to include zip file support - Added Microsoft Company Portal as a maintained app example with full install/uninstall scripts --- **Note:** This PR follows the same pattern as `.exe` file support, requiring custom install/uninstall scripts since zip files can contain various content types that need custom handling.
2025-12-15 17:03:43 +00:00
{(showAdvancedOptions ||
ext === "exe" ||
ext === "zip" ||
ext === "tar.gz") &&
!!selectedPackage &&
renderAdvancedOptions()}
</div>
);
};
export default PackageAdvancedOptions;