From 31c28bd17777db5a5ddd14939439cec286f83301 Mon Sep 17 00:00:00 2001 From: Joaquim Rocha Date: Thu, 9 Jun 2022 14:52:13 +0100 Subject: [PATCH 1/2] frontend: Prevent sending an empty version when fetching instances Sending an empty version is not allowed in the current API. That should be ideally prevented in the backend, but until then, this patch removes an empty version from the query params in the respective API call. --- frontend/src/api/API.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/api/API.ts b/frontend/src/api/API.ts index 02fee216a..3195b4f7d 100644 --- a/frontend/src/api/API.ts +++ b/frontend/src/api/API.ts @@ -195,12 +195,19 @@ export default class API { static getInstances( applicationID: string, groupID: string, - queryOptions = {} + queryOptions: { + [key: string]: any; + } = {} ): Promise { 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); From ebf5a4202037386d172e48788ba05245a9d5195c Mon Sep 17 00:00:00 2001 From: Joaquim Rocha Date: Wed, 22 Jun 2022 21:03:48 +0100 Subject: [PATCH 2/2] frontend: Add stories for Footer --- frontend/src/components/Footer.stories.tsx | 46 +++++++++++++++++++ .../__snapshots__/Footer.stories.storyshot | 25 ++++++++++ 2 files changed, 71 insertions(+) create mode 100644 frontend/src/components/Footer.stories.tsx create mode 100644 frontend/src/components/__snapshots__/Footer.stories.storyshot diff --git a/frontend/src/components/Footer.stories.tsx b/frontend/src/components/Footer.stories.tsx new file mode 100644 index 000000000..613ceb684 --- /dev/null +++ b/frontend/src/components/Footer.stories.tsx @@ -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 ( + + + + ); + }, + ], +} as Meta; + +const Template: Story = args => { + // eslint-disable-next-line no-unused-vars + const store = createStore((state = { config: {} }, action) => state, { + config: { + ...args, + }, + }); + return ( + + + + ); +}; + +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', +}; diff --git a/frontend/src/components/__snapshots__/Footer.stories.storyshot b/frontend/src/components/__snapshots__/Footer.stories.storyshot new file mode 100644 index 000000000..b92938b3a --- /dev/null +++ b/frontend/src/components/__snapshots__/Footer.stories.storyshot @@ -0,0 +1,25 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Storyshots Footer Footer No Override 1`] = ` +
+
+ Nebraska +
+
+`; + +exports[`Storyshots Footer Footer Override 1`] = ` +
+
+ Some Pro Update Service 1.2.3 +
+
+`;