Skip to content

Commit

Permalink
Fixes 3336: expose module_hotfixes flag as checkbox for repo (#196)
Browse files Browse the repository at this point in the history
* Fixes 3336: expose module_hotfixes flag as checkbox for repo

* clarification in tooltips

* added ouiaid

* change tooltip to selecting
  • Loading branch information
xbhouse authored Jan 17, 2024
1 parent 755ef78 commit 06c13a9
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/Pages/ContentListTable/components/AddContent/AddContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ const AddContent = () => {
gpgLoading,
metadataVerification,
snapshot,
moduleHotfixesEnabled
},
index,
) => (
Expand Down Expand Up @@ -651,6 +652,27 @@ const AddContent = () => {
setSelected={(value) => setVersionSelected(value, index)}
/>
</FormGroup>
<FormGroup fieldId='enable_module_hotfixes'>
<Switch
label='Modularity filtering disabled'
labelOff='Modularity filtering enabled'
ouiaId={`module_hotfixes_switch_${moduleHotfixesEnabled ? 'on' : 'off'}`}
aria-label='enable_module_hotfixes'
hasCheckIcon
id={'module-hotfixes-switch' + index}
name='module-hotfixes-switch'
isChecked={moduleHotfixesEnabled}
onChange={() => {
updateVariable(index, { moduleHotfixesEnabled: !moduleHotfixesEnabled });
}}
/>
<Tooltip content='Optional: Selecting this will set the module_hotfixes flag on the clients, allowing the repository to not be filtered by modularity'>
<OutlinedQuestionCircleIcon
className='pf-u-ml-xs'
color={global_Color_200.value}
/>
</Tooltip>
</FormGroup>
<FormGroup
label='GPG key'
labelIcon={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ it('mapFormikToAPIValues', () => {
expanded: false,
metadataVerification: false,
snapshot: true,
moduleHotfixesEnabled: false
},
];

Expand All @@ -47,6 +48,7 @@ it('mapFormikToAPIValues', () => {
gpg_key: '',
metadata_verification: false,
snapshot: true,
module_hotfixes: false
},
];

Expand Down
5 changes: 4 additions & 1 deletion src/Pages/ContentListTable/components/AddContent/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface FormikValues {
metadataVerification: boolean;
expanded: boolean;
snapshot: boolean;
moduleHotfixesEnabled: boolean;
}

export const getDefaultFormikValues = (overrides: Partial<FormikValues> = {}): FormikValues => ({
Expand All @@ -45,6 +46,7 @@ export const getDefaultFormikValues = (overrides: Partial<FormikValues> = {}): F
expanded: true,
metadataVerification: false,
snapshot: false,
moduleHotfixesEnabled: false,
...overrides,
});

Expand All @@ -58,14 +60,15 @@ export const isValidURL = (val: string) => {
};

export const mapFormikToAPIValues = (formikValues: FormikValues[]) =>
formikValues.map(({ name, url, arch, versions, gpgKey, metadataVerification, snapshot }) => ({
formikValues.map(({ name, url, arch, versions, gpgKey, metadataVerification, snapshot, moduleHotfixesEnabled }) => ({
name,
url,
distribution_arch: arch,
distribution_versions: versions,
gpg_key: gpgKey,
snapshot,
metadata_verification: metadataVerification,
module_hotfixes: moduleHotfixesEnabled,
}));

const mapNoMetaDataError = (validationData: ValidationResponse) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ const EditContentForm = ({
gpgLoading,
metadataVerification,
snapshot,
moduleHotfixesEnabled,
},
index,
) => (
Expand Down Expand Up @@ -522,6 +523,27 @@ const EditContentForm = ({
setSelected={(value) => setVersionSelected(value, index)}
/>
</FormGroup>
<FormGroup fieldId='enable_module_hotfixes'>
<Switch
label='Modularity filtering disabled'
labelOff='Modularity filtering enabled'
ouiaId={`module_hotfixes_switch_${moduleHotfixesEnabled ? 'on' : 'off'}`}
aria-label='enable_module_hotfixes'
hasCheckIcon
id={'module-hotfixes-switch' + index}
name='module-hotfixes-switch'
isChecked={moduleHotfixesEnabled}
onChange={() => {
updateVariable(index, { moduleHotfixesEnabled: !moduleHotfixesEnabled });
}}
/>
<Tooltip content='Optional: Selecting this will set the module_hotfixes flag on the clients, allowing the repository to not be filtered by modularity'>
<OutlinedQuestionCircleIcon
className='pf-u-ml-xs'
color={global_Color_200.value}
/>
</Tooltip>
</FormGroup>
<FormGroup
label='GPG key'
labelIcon={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ it('mapFormikToEditAPIValues', () => {
uuid: 'stuff',
metadataVerification: false,
snapshot: false,
moduleHotfixesEnabled: false,
},
];

Expand All @@ -27,6 +28,7 @@ it('mapFormikToEditAPIValues', () => {
uuid: 'stuff',
snapshot: false,
metadata_verification: false,
module_hotfixes: false,
},
];

Expand All @@ -51,6 +53,7 @@ it('mapToDefaultFormikValues', () => {
gpg_key: 'stuffAndThings',
metadata_verification: false,
snapshot: false,
module_hotfixes: false,
},
];
const mapped = [
Expand All @@ -65,6 +68,7 @@ it('mapToDefaultFormikValues', () => {
metadataVerification: false,
expanded: true,
uuid: 'stuffAndThings',
moduleHotfixesEnabled: false,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ export interface FormikEditValues {
expanded: boolean;
uuid: string;
snapshot: boolean;
moduleHotfixesEnabled: boolean;
}

export const mapFormikToEditAPIValues = (formikValues: FormikEditValues[]): EditContentRequest =>
formikValues.map(
({ name, url, arch, versions, gpgKey, metadataVerification, uuid, snapshot }) => ({
({ name, url, arch, versions, gpgKey, metadataVerification, uuid, snapshot, moduleHotfixesEnabled }) => ({
uuid,
name,
url,
Expand All @@ -24,6 +25,7 @@ export const mapFormikToEditAPIValues = (formikValues: FormikEditValues[]): Edit
gpg_key: gpgKey,
metadata_verification: metadataVerification,
snapshot,
module_hotfixes: moduleHotfixesEnabled,
}),
);

Expand All @@ -39,6 +41,7 @@ export const mapToDefaultFormikValues = (values: ContentItem[]): FormikEditValue
gpg_key: gpgKey,
metadata_verification: metadataVerification,
snapshot,
module_hotfixes: moduleHotfixesEnabled,
},
index,
) => ({
Expand All @@ -52,6 +55,7 @@ export const mapToDefaultFormikValues = (values: ContentItem[]): FormikEditValue
expanded: index + 1 === values.length,
uuid,
snapshot,
moduleHotfixesEnabled,
}),
);

Expand Down
3 changes: 3 additions & 0 deletions src/services/Content/ContentApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface ContentItem {
snapshot: boolean;
last_snapshot_uuid?: string;
last_snapshot?: SnapshotItem;
module_hotfixes: boolean;
}

export interface PopularRepository {
Expand All @@ -39,6 +40,7 @@ export interface CreateContentRequestItem {
gpg_key?: string;
metadata_verification?: boolean;
snapshot?: boolean;
module_hotfixes?: boolean;
}

export interface ErrorItem {
Expand All @@ -64,6 +66,7 @@ export interface EditContentRequestItem {
gpg_key: string;
metadata_verification: boolean;
snapshot: boolean;
module_hotfixes: boolean;
}

export type EditContentRequest = Array<EditContentRequestItem>;
Expand Down
2 changes: 2 additions & 0 deletions src/testingHelpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export const defaultContentItem: ContentItem = {
failed_introspections_count: 0,
metadata_verification: false,
snapshot: false,
module_hotfixes: false,
};

export const defaultIntrospectTask: AdminTask = {
Expand Down Expand Up @@ -227,4 +228,5 @@ export const defaultContentItemWithSnapshot: ContentItem = {
metadata_verification: false,
snapshot: true,
last_snapshot: defaultSnapshotItem,
module_hotfixes: false,
};

0 comments on commit 06c13a9

Please sign in to comment.