Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EPMRPP-76676 || Logs error fix #3085

Merged
merged 8 commits into from
Apr 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,57 @@ 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';
import { PUBLIC_PLUGIN_ACCESS_TYPE } from 'controllers/plugins/constants';

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 calculateIconSrc = () => {
const calculateIconParams = () => {
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 URLS.pluginCommandCommon(projectId, name, COMMAND_GET_FILE);
return {
url: URLS.pluginCommandCommon(projectId, name, COMMAND_GET_FILE),
requestParams: commandParams,
};
}

const integration = filterIntegrationsByName(globalIntegrations, name)[0];
if (!integration) {
return null;
if (integration) {
return {
url: URLS.projectIntegrationByIdCommand(projectId, integration.id, COMMAND_GET_FILE),
requestParams: commandParams,
};
}

return URLS.projectIntegrationByIdCommand(projectId, integration.id, COMMAND_GET_FILE);
return {
url: isPublic
? URLS.pluginPublicFile(name, details.binaryData.icon)
: URLS.pluginFile(name, details.binaryData.icon),
};
}
AmsterGet marked this conversation as resolved.
Show resolved Hide resolved

return PLUGIN_IMAGES_MAP[name] || PLUGIN_DEFAULT_IMAGE;
return {
url: PLUGIN_IMAGES_MAP[name] || PLUGIN_DEFAULT_IMAGE,
};
};

const { url, requestParams } = calculateIconParams();

return (
<div className={className}>
<Image
src={calculateIconSrc()}
src={url}
fallback={PLUGIN_DEFAULT_IMAGE}
isStatic={!isDynamicIconAvailable}
requestParams={{ method: 'PUT', data: { fileKey: 'icon' } }}
requestParams={requestParams}
preloaderColor="charcoal"
className={className}
{...rest}
Expand Down