From 49b163401946f0a239e6979237665cf1cc857d17 Mon Sep 17 00:00:00 2001 From: Artsiom Sadouski Date: Thu, 28 Apr 2022 16:43:43 +0300 Subject: [PATCH 1/8] EPMRPP-76676 || Logs error fix --- .../integrations/elements/pluginIcon/pluginIcon.jsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx index 031920b9ce..6a451127a4 100644 --- a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx +++ b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx @@ -25,12 +25,17 @@ import { filterIntegrationsByName, isPluginSupportsCommonCommand } from 'control import { PLUGIN_DEFAULT_IMAGE, PLUGIN_IMAGES_MAP } from 'components/integrations/constants'; import { Image } from 'components/main/image'; +const PUBLIC_ACCESS_TYPE = 'public'; +const FILE_KEY = 'plugin-icon.svg'; + export const PluginIcon = ({ pluginData, className, ...rest }) => { const { details, name } = pluginData; const isDynamicIconAvailable = details && details.binaryData && details.binaryData.icon; const projectId = useSelector(activeProjectSelector); const globalIntegrations = useSelector(globalIntegrationsSelector); + const isPublic = details && details.accessType === PUBLIC_ACCESS_TYPE; + const calculateIconSrc = () => { if (isDynamicIconAvailable) { const isCommonCommandSupported = isPluginSupportsCommonCommand(pluginData, COMMAND_GET_FILE); @@ -44,7 +49,9 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { return null; } - return URLS.projectIntegrationByIdCommand(projectId, integration.id, COMMAND_GET_FILE); + return isPublic + ? URLS.pluginPublicFile(integration.name, FILE_KEY) + : URLS.projectIntegrationByIdCommand(projectId, integration.id, COMMAND_GET_FILE); } return PLUGIN_IMAGES_MAP[name] || PLUGIN_DEFAULT_IMAGE; @@ -56,7 +63,7 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { src={calculateIconSrc()} fallback={PLUGIN_DEFAULT_IMAGE} isStatic={!isDynamicIconAvailable} - requestParams={{ method: 'PUT', data: { fileKey: 'icon' } }} + requestParams={isPublic ? { method: 'GET' } : { method: 'PUT', data: { fileKey: 'icon' } }} preloaderColor="charcoal" className={className} {...rest} From 77f66c2dcdf46ce98a42e57471c38a08b02f15ad Mon Sep 17 00:00:00 2001 From: Artsiom Sadouski Date: Thu, 28 Apr 2022 19:21:47 +0300 Subject: [PATCH 2/8] EPMRPP-76676 || Code review fixes - 1 --- .../elements/pluginIcon/pluginIcon.jsx | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx index 6a451127a4..8db1ff2a94 100644 --- a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx +++ b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx @@ -24,9 +24,7 @@ import { globalIntegrationsSelector } from 'controllers/plugins/selectors'; import { filterIntegrationsByName, isPluginSupportsCommonCommand } from 'controllers/plugins/utils'; import { PLUGIN_DEFAULT_IMAGE, PLUGIN_IMAGES_MAP } from 'components/integrations/constants'; import { Image } from 'components/main/image'; - -const PUBLIC_ACCESS_TYPE = 'public'; -const FILE_KEY = 'plugin-icon.svg'; +import { PUBLIC_PLUGIN_ACCESS_TYPE } from 'controllers/plugins/constants'; export const PluginIcon = ({ pluginData, className, ...rest }) => { const { details, name } = pluginData; @@ -34,7 +32,11 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { const projectId = useSelector(activeProjectSelector); const globalIntegrations = useSelector(globalIntegrationsSelector); - const isPublic = details && details.accessType === PUBLIC_ACCESS_TYPE; + const isPublic = details && details.accessType === PUBLIC_PLUGIN_ACCESS_TYPE; + const isCommand = + (isPluginSupportsCommonCommand(pluginData, COMMAND_GET_FILE) || + filterIntegrationsByName(globalIntegrations, name)[0]) && + !isPublic; const calculateIconSrc = () => { if (isDynamicIconAvailable) { @@ -45,13 +47,13 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { } const integration = filterIntegrationsByName(globalIntegrations, name)[0]; - if (!integration) { - return null; + if (integration && !isPublic) { + return URLS.projectIntegrationByIdCommand(projectId, integration.id, COMMAND_GET_FILE); } return isPublic - ? URLS.pluginPublicFile(integration.name, FILE_KEY) - : URLS.projectIntegrationByIdCommand(projectId, integration.id, COMMAND_GET_FILE); + ? URLS.pluginPublicFile(integration.name, details.binaryData.icon) + : URLS.pluginFile(integration.name, details.binaryData.icon); } return PLUGIN_IMAGES_MAP[name] || PLUGIN_DEFAULT_IMAGE; @@ -63,7 +65,9 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { src={calculateIconSrc()} fallback={PLUGIN_DEFAULT_IMAGE} isStatic={!isDynamicIconAvailable} - requestParams={isPublic ? { method: 'GET' } : { method: 'PUT', data: { fileKey: 'icon' } }} + requestParams={ + !isCommand ? { method: 'GET' } : { method: 'PUT', data: { fileKey: 'icon' } } + } preloaderColor="charcoal" className={className} {...rest} From 61a1ee58d6f544d3a523f9f8398c9dde2e6bfea8 Mon Sep 17 00:00:00 2001 From: Artsiom Sadouski Date: Fri, 29 Apr 2022 14:36:26 +0300 Subject: [PATCH 3/8] EPMRPP-76676 || Code review fixes - 2 --- .../integrations/elements/pluginIcon/pluginIcon.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx index 8db1ff2a94..3727c4f0de 100644 --- a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx +++ b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx @@ -47,13 +47,13 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { } const integration = filterIntegrationsByName(globalIntegrations, name)[0]; - if (integration && !isPublic) { + if (integration) { return URLS.projectIntegrationByIdCommand(projectId, integration.id, COMMAND_GET_FILE); } return isPublic - ? URLS.pluginPublicFile(integration.name, details.binaryData.icon) - : URLS.pluginFile(integration.name, details.binaryData.icon); + ? URLS.pluginPublicFile(name, details.binaryData.icon) + : URLS.pluginFile(name, details.binaryData.icon); } return PLUGIN_IMAGES_MAP[name] || PLUGIN_DEFAULT_IMAGE; From 65132dcabc4193e6d3cf9dcd7d3a4bb12248ca6b Mon Sep 17 00:00:00 2001 From: Artsiom Sadouski Date: Fri, 29 Apr 2022 14:52:55 +0300 Subject: [PATCH 4/8] EPMRPP-76676 || Code review fixes - 3 --- .../elements/pluginIcon/pluginIcon.jsx | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx index 3727c4f0de..22f7d26f32 100644 --- a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx +++ b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx @@ -33,41 +33,50 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { const globalIntegrations = useSelector(globalIntegrationsSelector); const isPublic = details && details.accessType === PUBLIC_PLUGIN_ACCESS_TYPE; - const isCommand = - (isPluginSupportsCommonCommand(pluginData, COMMAND_GET_FILE) || - filterIntegrationsByName(globalIntegrations, name)[0]) && - !isPublic; const calculateIconSrc = () => { + const putRequestParams = { method: 'PUT', data: { fileKey: 'icon' } }; + const getRequestParams = { method: 'GET' }; + if (isDynamicIconAvailable) { const isCommonCommandSupported = isPluginSupportsCommonCommand(pluginData, COMMAND_GET_FILE); if (isCommonCommandSupported) { - return URLS.pluginCommandCommon(projectId, name, COMMAND_GET_FILE); + return { + url: URLS.pluginCommandCommon(projectId, name, COMMAND_GET_FILE), + requestParams: putRequestParams, + }; } const integration = filterIntegrationsByName(globalIntegrations, name)[0]; if (integration) { - return URLS.projectIntegrationByIdCommand(projectId, integration.id, COMMAND_GET_FILE); + return { + url: URLS.projectIntegrationByIdCommand(projectId, integration.id, COMMAND_GET_FILE), + requestParams: putRequestParams, + }; } - return isPublic - ? URLS.pluginPublicFile(name, details.binaryData.icon) - : URLS.pluginFile(name, details.binaryData.icon); + return { + url: isPublic + ? URLS.pluginPublicFile(name, details.binaryData.icon) + : URLS.pluginFile(name, details.binaryData.icon), + requestParams: getRequestParams, + }; } - return PLUGIN_IMAGES_MAP[name] || PLUGIN_DEFAULT_IMAGE; + return { + url: PLUGIN_IMAGES_MAP[name] || PLUGIN_DEFAULT_IMAGE, + requestParams: putRequestParams, + }; }; return (
Date: Fri, 29 Apr 2022 14:57:06 +0300 Subject: [PATCH 5/8] EPMRPP-76676 || Code review fixes - 4 --- .../integrations/elements/pluginIcon/pluginIcon.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx index 22f7d26f32..8a873c2ba4 100644 --- a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx +++ b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx @@ -34,7 +34,7 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { const isPublic = details && details.accessType === PUBLIC_PLUGIN_ACCESS_TYPE; - const calculateIconSrc = () => { + const calculateIconParams = () => { const putRequestParams = { method: 'PUT', data: { fileKey: 'icon' } }; const getRequestParams = { method: 'GET' }; @@ -73,10 +73,10 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { return (
Date: Fri, 29 Apr 2022 15:10:18 +0300 Subject: [PATCH 6/8] EPMRPP-76676 || Code review fixes - 5 --- .../components/integrations/elements/pluginIcon/pluginIcon.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx index 8a873c2ba4..89d5ee283d 100644 --- a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx +++ b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx @@ -66,7 +66,6 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { return { url: PLUGIN_IMAGES_MAP[name] || PLUGIN_DEFAULT_IMAGE, - requestParams: putRequestParams, }; }; From 8ad2e02b61380f828458aaa25e416a02d8efc744 Mon Sep 17 00:00:00 2001 From: Artsiom Sadouski Date: Fri, 29 Apr 2022 15:17:52 +0300 Subject: [PATCH 7/8] EPMRPP-76676 || Code review fixes - 6 --- .../integrations/elements/pluginIcon/pluginIcon.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx index 89d5ee283d..4c39025a71 100644 --- a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx +++ b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx @@ -69,13 +69,15 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { }; }; + const { url, requestParams } = calculateIconParams(); + return (
Date: Fri, 29 Apr 2022 15:44:29 +0300 Subject: [PATCH 8/8] EPMRPP-76676 || Code review fixes - 7 --- .../integrations/elements/pluginIcon/pluginIcon.jsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx index 4c39025a71..5412f9dc77 100644 --- a/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx +++ b/app/src/components/integrations/elements/pluginIcon/pluginIcon.jsx @@ -32,19 +32,17 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { const projectId = useSelector(activeProjectSelector); const globalIntegrations = useSelector(globalIntegrationsSelector); - const isPublic = details && details.accessType === PUBLIC_PLUGIN_ACCESS_TYPE; - const calculateIconParams = () => { - const putRequestParams = { method: 'PUT', data: { fileKey: 'icon' } }; - const getRequestParams = { method: 'GET' }; + const commandParams = { method: 'PUT', data: { fileKey: 'icon' } }; if (isDynamicIconAvailable) { + const isPublic = details && details.accessType === PUBLIC_PLUGIN_ACCESS_TYPE; const isCommonCommandSupported = isPluginSupportsCommonCommand(pluginData, COMMAND_GET_FILE); if (isCommonCommandSupported) { return { url: URLS.pluginCommandCommon(projectId, name, COMMAND_GET_FILE), - requestParams: putRequestParams, + requestParams: commandParams, }; } @@ -52,7 +50,7 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { if (integration) { return { url: URLS.projectIntegrationByIdCommand(projectId, integration.id, COMMAND_GET_FILE), - requestParams: putRequestParams, + requestParams: commandParams, }; } @@ -60,7 +58,6 @@ export const PluginIcon = ({ pluginData, className, ...rest }) => { url: isPublic ? URLS.pluginPublicFile(name, details.binaryData.icon) : URLS.pluginFile(name, details.binaryData.icon), - requestParams: getRequestParams, }; }