Skip to content

Commit

Permalink
Merge pull request #612 from kinvolk/fix-empty-version-filtering
Browse files Browse the repository at this point in the history
frontend: Prevent sending an empty version when fetching instances
  • Loading branch information
joaquimrocha authored Jun 23, 2022
2 parents 901f009 + ebf5a42 commit 8d6076d
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frontend/src/api/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,19 @@ export default class API {
static getInstances(
applicationID: string,
groupID: string,
queryOptions = {}
queryOptions: {
[key: string]: any;
} = {}
): Promise<Instances> {
let url = BASE_URL + '/apps/' + applicationID + '/groups/' + groupID + '/instances';

if (!_.isEmpty(queryOptions)) {
url += '?' + queryString.stringify(queryOptions);
let sanitizedOptions = queryOptions;
const { version, ...otherOptions } = queryOptions;
if (!version) {
sanitizedOptions = otherOptions;
}
url += '?' + queryString.stringify(sanitizedOptions);
}

return API.getJSON(url);
Expand Down
46 changes: 46 additions & 0 deletions frontend/src/components/Footer.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { createStore } from '@reduxjs/toolkit';
import { Meta, Story } from '@storybook/react/types-6-0';
import { Provider } from 'react-redux';
import { MemoryRouter } from 'react-router-dom';
import FooterComponent from './Footer';

export default {
title: 'Footer',
component: FooterComponent,
argTypes: {},
decorators: [
Story => {
return (
<MemoryRouter>
<Story />
</MemoryRouter>
);
},
],
} as Meta;

const Template: Story = args => {
// eslint-disable-next-line no-unused-vars
const store = createStore((state = { config: {} }, action) => state, {
config: {
...args,
},
});
return (
<Provider store={store}>
<FooterComponent />
</Provider>
);
};

export const FooterNoOverride = Template.bind({});
FooterNoOverride.args = {
title: '',
nebraska_version: '',
};

export const FooterOverride = Template.bind({});
FooterOverride.args = {
title: 'Some Pro Update Service',
nebraska_version: '1.2.3',
};
25 changes: 25 additions & 0 deletions frontend/src/components/__snapshots__/Footer.stories.storyshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Storyshots Footer Footer No Override 1`] = `
<div
id="root"
>
<div
class="MuiBox-root MuiBox-root"
>
Nebraska
</div>
</div>
`;

exports[`Storyshots Footer Footer Override 1`] = `
<div
id="root"
>
<div
class="MuiBox-root MuiBox-root"
>
Some Pro Update Service 1.2.3
</div>
</div>
`;

0 comments on commit 8d6076d

Please sign in to comment.