mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Fix frontend bug on "Edit pack" page (#604)
Changes part of Fleet 3.10.0 prevented the frontend from handling any values other than `darwin`, `linux`, `all`, and `windows`. Users that manage packs via fleectl and the Fleet UI may encounter this bug when using 3.10.0. - Adds a case for the frontend to handle `freebsd`, `posix`, `any`, and any other string specified in the `platform` key in pack configuration.
This commit is contained in:
parent
0474999bd2
commit
90e82a62b3
3 changed files with 30 additions and 5 deletions
|
|
@ -13,16 +13,22 @@ const baseClass = 'scheduled-query-list-item';
|
|||
const generatePlatformText = (platforms) => {
|
||||
const ALL_PLATFORMS = [
|
||||
{ text: 'All', value: 'all' },
|
||||
{ text: 'macOS', value: 'darwin' },
|
||||
{ text: 'Windows', value: 'windows' },
|
||||
{ text: 'Linux', value: 'linux' },
|
||||
{ text: 'macOS', value: 'darwin' },
|
||||
];
|
||||
|
||||
if (platforms) {
|
||||
const platformArray = platforms.split(',');
|
||||
const platformsArray = platforms.split(',');
|
||||
|
||||
const textArray = platformArray.map((platform) => {
|
||||
const text = find(ALL_PLATFORMS, { value: platform }).text;
|
||||
const textArray = platformsArray.map((platform) => {
|
||||
// Trim spaces from the platform
|
||||
const trimmedPlatform = platform.trim();
|
||||
const platformObject = find(ALL_PLATFORMS, { value: trimmedPlatform });
|
||||
// Convert trimmed value to the corresponding text if the value exists
|
||||
// in the ALL_PLATFORMS array.
|
||||
// Otherwise, just use the trimmed value.
|
||||
const text = platformObject ? platformObject.text : trimmedPlatform;
|
||||
|
||||
return text;
|
||||
});
|
||||
|
|
@ -32,7 +38,7 @@ const generatePlatformText = (platforms) => {
|
|||
return displayText;
|
||||
}
|
||||
|
||||
return '---';
|
||||
return 'All';
|
||||
};
|
||||
|
||||
class ScheduledQueriesListItem extends Component {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,24 @@ describe('ScheduledQueriesListItem - component', () => {
|
|||
expect(component.text()).toContain(scheduledQueryStub.shard);
|
||||
});
|
||||
|
||||
it('renders the converted platform attributes', () => {
|
||||
const scheduledQuery = { ...scheduledQueryStub, platform: 'darwin,linux,all,windows' };
|
||||
const component = mount(<ScheduledQueriesListItem checked={false} {...defaultProps}scheduledQuery={scheduledQuery} />);
|
||||
expect(component.text()).toContain('macOS');
|
||||
expect(component.text()).toContain('Linux');
|
||||
expect(component.text()).toContain('All');
|
||||
expect(component.text()).toContain('Windows');
|
||||
});
|
||||
|
||||
it('renders the platform attributes when there are no conversions', () => {
|
||||
const scheduledQuery = { ...scheduledQueryStub, platform: 'darwin,freebsd, bar, foo' };
|
||||
const component = mount(<ScheduledQueriesListItem checked={false} {...defaultProps} scheduledQuery={scheduledQuery} />);
|
||||
expect(component.text()).toContain('macOS');
|
||||
expect(component.text()).toContain('freebsd');
|
||||
expect(component.text()).toContain('bar');
|
||||
expect(component.text()).toContain('foo');
|
||||
});
|
||||
|
||||
it('renders a Checkbox component', () => {
|
||||
const component = shallow(<ScheduledQueriesListItem {...defaultProps} />);
|
||||
expect(component.find('Checkbox').length).toEqual(1);
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@
|
|||
letter-spacing: -0.5px;
|
||||
text-align: left;
|
||||
color: $core-black;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&:nth-child(5),
|
||||
|
|
|
|||
Loading…
Reference in a new issue