-
-
Target
-
- setSelectedTargetType(val as TargetType)
- }
- />
-
- setSelectedTargetType(val as TargetType)
- }
- />
-
- {selectedTargetType === "Custom" && renderCustomTarget()}
+
+
Target
+
{
+ window.location.href = PATHS.LABEL_NEW_DYNAMIC;
+ }}
+ />
)}
diff --git a/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/_styles.scss b/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/_styles.scss
index ab4a6a0b19..76fd241bf2 100644
--- a/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/_styles.scss
+++ b/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/_styles.scss
@@ -1,6 +1,8 @@
.add-profile-modal {
&__modal-content-wrap {
- margin-top: $pad-large;
+ display: flex;
+ flex-direction: column;
+ gap: $pad-medium;
.add-profile__file {
padding: $pad-medium $pad-large;
@@ -64,8 +66,8 @@
}
&--title {
- color: $ui-fleet-black-75;
- font-weight: $bold;
+ color: $ui-fleet-black-75;
+ font-weight: $bold;
}
}
@@ -73,124 +75,5 @@
display: flex;
justify-content: flex-end;
gap: $pad-small;
- padding-top: $pad-medium;
- }
-
- &__target {
- margin: $pad-large 0;
-
- .react-tabs__tab-panel {
- display: flex;
- flex-direction: column;
- gap: $pad-medium;
- padding-top: 0;
- }
- }
-
- &__custom-label-chooser {
- margin-top: $pad-medium;
- }
-
- &__description {
- margin: $pad-medium 0;
- }
-
- &__no-labels {
- display: flex;
- height: 187px;
- flex-direction: column;
- align-items: center;
- gap: $pad-small;
- justify-content: center;
- text-align: center;
-
- span {
- color: $ui-fleet-black-75;
- }
-
- &--title {
- font-size: $small;
- font-weight: $bold;
- color: $core-fleet-black !important;
- }
-
- &--description {
- font-size: $xx-small;
- margin-top: -$pad-xsmall;
- }
-
- .button {
- margin-top: $pad-small;
- }
- }
-
- &__selected-badges {
- display: flex;
- flex-wrap: wrap;
- gap: $pad-xsmall;
- }
-
- &__selected-badge {
- display: flex;
- align-items: center;
- gap: $pad-xxsmall;
- padding: $pad-xxsmall $pad-small;
- background-color: $ui-fleet-black-5;
- border: 1px solid $ui-fleet-black-10;
- border-radius: $border-radius;
- font-size: $xx-small;
- cursor: pointer;
- color: $ui-fleet-black-75;
-
- &:hover {
- background-color: $ui-fleet-black-10;
- border-color: $ui-fleet-black-25;
- }
- }
-
- &__checkboxes {
- display: flex;
- max-height: 187px;
- flex-direction: column;
- border-radius: $border-radius;
- border: 1px solid $ui-fleet-black-10;
- overflow-y: auto;
-
- .loading-spinner {
- margin: 69.5px auto;
- }
- }
-
- &__label {
- width: 100%;
- padding: $pad-small $pad-medium;
- box-sizing: border-box;
- display: flex;
- align-items: center;
-
- &:not(:last-child) {
- border-bottom: 1px solid $ui-fleet-black-10;
- }
-
- .form-field--checkbox {
- width: auto;
- }
- }
-
- &__label-name {
- padding-left: $pad-large;
- }
-
- .fleet-checkbox {
- height: 20px;
- display: flex;
- align-items: center;
-
- &__label {
- width: 490px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
}
}
diff --git a/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/helpers.tests.ts b/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/helpers.tests.ts
index e3454c8a92..a7f3bb9cf3 100644
--- a/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/helpers.tests.ts
+++ b/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/helpers.tests.ts
@@ -1,51 +1,69 @@
-import { listNamesFromSelectedLabels, generateLabelKey } from "./helpers";
+import generateCustomTargetLabelKey from "./helpers";
-describe("listNamesFromSelectedLabels", () => {
- it("returns names of selected labels", () => {
- expect(
- listNamesFromSelectedLabels({ foo: true, bar: false, baz: true })
- ).toEqual(["foo", "baz"]);
- });
-
- it("returns empty array when nothing is selected", () => {
- expect(listNamesFromSelectedLabels({ foo: false, bar: false })).toEqual([]);
- });
-
- it("returns empty array for an empty dict", () => {
- expect(listNamesFromSelectedLabels({})).toEqual([]);
- });
-});
-
-describe("generateLabelKey", () => {
+describe("generateCustomTargetLabelKey", () => {
it("returns empty object when target is not Custom", () => {
- expect(generateLabelKey("All hosts", "any", { foo: true }, {})).toEqual({});
+ expect(
+ generateCustomTargetLabelKey({
+ targetType: "All hosts",
+ includeMode: "any",
+ includeLabels: { foo: true },
+ excludeLabels: {},
+ })
+ ).toEqual({});
});
it("returns labelsIncludeAny when include mode is any", () => {
expect(
- generateLabelKey("Custom", "any", { foo: true, bar: true }, {})
+ generateCustomTargetLabelKey({
+ targetType: "Custom",
+ includeMode: "any",
+ includeLabels: { foo: true, bar: true },
+ excludeLabels: {},
+ })
).toEqual({ labelsIncludeAny: ["foo", "bar"] });
});
it("returns labelsIncludeAll when include mode is all", () => {
- expect(generateLabelKey("Custom", "all", { foo: true }, {})).toEqual({
- labelsIncludeAll: ["foo"],
- });
+ expect(
+ generateCustomTargetLabelKey({
+ targetType: "Custom",
+ includeMode: "all",
+ includeLabels: { foo: true },
+ excludeLabels: {},
+ })
+ ).toEqual({ labelsIncludeAll: ["foo"] });
});
it("returns labelsExcludeAny when exclude labels are selected", () => {
- expect(generateLabelKey("Custom", "any", {}, { bar: true })).toEqual({
- labelsExcludeAny: ["bar"],
- });
+ expect(
+ generateCustomTargetLabelKey({
+ targetType: "Custom",
+ includeMode: "any",
+ includeLabels: {},
+ excludeLabels: { bar: true },
+ })
+ ).toEqual({ labelsExcludeAny: ["bar"] });
});
it("returns both include and exclude keys when both have selections", () => {
expect(
- generateLabelKey("Custom", "any", { foo: true }, { bar: true })
- ).toEqual({ labelsIncludeAny: ["foo"], labelsExcludeAny: ["bar"] });
+ generateCustomTargetLabelKey({
+ targetType: "Custom",
+ includeMode: "all",
+ includeLabels: { foo: true },
+ excludeLabels: { bar: true },
+ })
+ ).toEqual({ labelsIncludeAll: ["foo"], labelsExcludeAny: ["bar"] });
});
it("omits keys for empty selections", () => {
- expect(generateLabelKey("Custom", "all", { foo: false }, {})).toEqual({});
+ expect(
+ generateCustomTargetLabelKey({
+ targetType: "Custom",
+ includeMode: "all",
+ includeLabels: { foo: false },
+ excludeLabels: {},
+ })
+ ).toEqual({});
});
});
diff --git a/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/helpers.ts b/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/helpers.ts
new file mode 100644
index 0000000000..dc3a6a0234
--- /dev/null
+++ b/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/helpers.ts
@@ -0,0 +1,35 @@
+import { LabelTargetMode, TargetType } from "components/TargetLabelSelector";
+import { listNamesFromSelectedLabels } from "services/entities/labels";
+
+interface IGenerateCustomTargetLabelKeyArgs {
+ targetType: TargetType;
+ includeMode: LabelTargetMode;
+ includeLabels: Record;
+ excludeLabels: Record;
+}
+
+const generateCustomTargetLabelKey = ({
+ targetType,
+ includeMode,
+ includeLabels,
+ excludeLabels,
+}: IGenerateCustomTargetLabelKeyArgs) => {
+ if (targetType !== "Custom") {
+ return {};
+ }
+
+ const result: Record = {};
+ const includeNames = listNamesFromSelectedLabels(includeLabels);
+ const excludeNames = listNamesFromSelectedLabels(excludeLabels);
+ if (includeNames.length) {
+ result[
+ includeMode === "all" ? "labelsIncludeAll" : "labelsIncludeAny"
+ ] = includeNames;
+ }
+ if (excludeNames.length) {
+ result.labelsExcludeAny = excludeNames;
+ }
+ return result;
+};
+
+export default generateCustomTargetLabelKey;
diff --git a/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/helpers.tsx b/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/helpers.tsx
deleted file mode 100644
index cc57929bbc..0000000000
--- a/frontend/pages/ManageControlsPage/OSSettings/cards/ConfigurationProfiles/components/ProfileUploader/components/AddProfileModal/helpers.tsx
+++ /dev/null
@@ -1,32 +0,0 @@
-export const listNamesFromSelectedLabels = (dict: Record) => {
- return Object.entries(dict).reduce((acc, [labelName, isSelected]) => {
- if (isSelected) {
- acc.push(labelName);
- }
- return acc;
- }, [] as string[]);
-};
-
-export const generateLabelKey = (
- target: string,
- includeMode: "any" | "all",
- includeLabels: Record,
- excludeLabels: Record
-) => {
- if (target !== "Custom") {
- return {};
- }
-
- const result: Record = {};
- const includeNames = listNamesFromSelectedLabels(includeLabels);
- const excludeNames = listNamesFromSelectedLabels(excludeLabels);
- if (includeNames.length) {
- result[
- includeMode === "all" ? "labelsIncludeAll" : "labelsIncludeAny"
- ] = includeNames;
- }
- if (excludeNames.length) {
- result.labelsExcludeAny = excludeNames;
- }
- return result;
-};
diff --git a/frontend/pages/SoftwarePage/SoftwareTitleDetailsPage/EditAutoUpdateConfigModal/EditAutoUpdateConfigModal.tsx b/frontend/pages/SoftwarePage/SoftwareTitleDetailsPage/EditAutoUpdateConfigModal/EditAutoUpdateConfigModal.tsx
index 47fa464f93..db2f69ef87 100644
--- a/frontend/pages/SoftwarePage/SoftwareTitleDetailsPage/EditAutoUpdateConfigModal/EditAutoUpdateConfigModal.tsx
+++ b/frontend/pages/SoftwarePage/SoftwareTitleDetailsPage/EditAutoUpdateConfigModal/EditAutoUpdateConfigModal.tsx
@@ -15,7 +15,7 @@ import Card from "components/Card";
import Modal from "components/Modal";
import ModalFooter from "components/ModalFooter";
import Checkbox from "components/forms/fields/Checkbox";
-import TargetLabelSelector from "components/TargetLabelSelector";
+import { DropdownTargetLabelSelector } from "components/TargetLabelSelector";
import GitOpsModeTooltipWrapper from "components/GitOpsModeTooltipWrapper";
import {
@@ -84,7 +84,7 @@ const EditAutoUpdateConfigModal = ({
),
});
- // Fetch labels for TargetLabelSelector
+ // Fetch labels for DropdownTargetLabelSelector
const { data: labels } = useQuery(
["custom_labels"],
() => labelsAPI.summary(teamId).then((res) => getCustomLabels(res.labels)),
@@ -276,7 +276,7 @@ const EditAutoUpdateConfigModal = ({
- (
-
-
{platformSelector.render()}
{isPremiumTier && (
-
{isExistingQuery && platformSelector.render()}
{isPremiumTier && (
-
{platformSelector.render()}
{isPremiumTier && (
- {
+ it("returns names of selected labels", () => {
+ expect(
+ listNamesFromSelectedLabels({ foo: true, bar: false, baz: true })
+ ).toEqual(["foo", "baz"]);
+ });
+
+ it("returns empty array when nothing is selected", () => {
+ expect(listNamesFromSelectedLabels({ foo: false, bar: false })).toEqual([]);
+ });
+
+ it("returns empty array for an empty dict", () => {
+ expect(listNamesFromSelectedLabels({})).toEqual([]);
+ });
+});
diff --git a/frontend/services/entities/labels.ts b/frontend/services/entities/labels.ts
index e7d1416583..83805490ce 100644
--- a/frontend/services/entities/labels.ts
+++ b/frontend/services/entities/labels.ts
@@ -98,6 +98,15 @@ export const getCustomLabels = (
});
};
+export const listNamesFromSelectedLabels = (dict: Record) => {
+ return Object.entries(dict).reduce((acc, [labelName, isSelected]) => {
+ if (isSelected) {
+ acc.push(labelName);
+ }
+ return acc;
+ }, [] as string[]);
+};
+
export default {
create: (formData: INewLabelFormData): Promise => {
const { LABELS } = endpoints;
diff --git a/frontend/services/entities/software.ts b/frontend/services/entities/software.ts
index 7eb462a00a..c618f0dbf9 100644
--- a/frontend/services/entities/software.ts
+++ b/frontend/services/entities/software.ts
@@ -35,7 +35,7 @@ import { ISoftwareVppFormData } from "pages/SoftwarePage/components/forms/Softwa
import { ISoftwareAutoUpdateConfigFormData } from "pages/SoftwarePage/SoftwareTitleDetailsPage/EditAutoUpdateConfigModal/EditAutoUpdateConfigModal";
import { ISoftwareDisplayNameFormData } from "pages/SoftwarePage/SoftwareTitleDetailsPage/EditIconModal/EditIconModal";
import { IAddFleetMaintainedData } from "pages/SoftwarePage/SoftwareAddPage/SoftwareFleetMaintained/FleetMaintainedAppDetailsPage/FleetMaintainedAppDetailsPage";
-import { listNamesFromSelectedLabels } from "components/TargetLabelSelector/TargetLabelSelector";
+import { listNamesFromSelectedLabels } from "services/entities/labels";
import { ISoftwareAndroidFormData } from "pages/SoftwarePage/components/forms/SoftwareAndroidForm/SoftwareAndroidForm";
import { ISoftwareConfigurationFormData } from "pages/SoftwarePage/SoftwareTitleDetailsPage/EditConfigurationModal/EditConfigurationModal";