Skip to content
Merged
Show file tree
Hide file tree
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
22 changes: 21 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ endif
# Used for semver bumping
PROTECTED_BRANCH := master
APP_NAME := $(shell basename -s .git `git config --get remote.origin.url`)
CURRENT_VERSION := $(shell git describe --abbrev=0 --tags)
CURRENT_VERSION := $(strip $(shell git describe --abbrev=0 --tags))
LATEST_RELEASE_TAG_RAW := $(shell git tag -l "v*" --sort=-v:refname | grep -v '\-rc' | head -n 1 || true)
LATEST_RELEASE_TAG := $(strip $(LATEST_RELEASE_TAG_RAW))
ifeq ($(LATEST_RELEASE_TAG),)
LATEST_RELEASE_TAG := $(CURRENT_VERSION)
endif
VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(CURRENT_VERSION))))
MAJOR := $(word 1,$(VERSION_PARTS))
MINOR := $(word 2,$(VERSION_PARTS))
Expand Down Expand Up @@ -81,6 +86,11 @@ endef
patch: ## to bump patch version (semver)
$(call check_protected_branch)
$(call check_pending_pulls)
@$(eval BASE_VERSION := $(strip $(LATEST_RELEASE_TAG)))
@$(eval BASE_VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(BASE_VERSION)))))
@$(eval MAJOR := $(word 1,$(BASE_VERSION_PARTS)))
@$(eval MINOR := $(word 2,$(BASE_VERSION_PARTS)))
@$(eval PATCH := $(word 3,$(BASE_VERSION_PARTS)))
@$(eval PATCH := $(shell echo $$(($(PATCH)+1))))
$(call prompt_approval,$(MAJOR).$(MINOR).$(PATCH))
@echo Bumping $(APP_NAME) to Patch version $(MAJOR).$(MINOR).$(PATCH)
Expand All @@ -91,6 +101,11 @@ patch: ## to bump patch version (semver)
minor: ## to bump minor version (semver)
$(call check_protected_branch)
$(call check_pending_pulls)
@$(eval BASE_VERSION := $(strip $(LATEST_RELEASE_TAG)))
@$(eval BASE_VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(BASE_VERSION)))))
@$(eval MAJOR := $(word 1,$(BASE_VERSION_PARTS)))
@$(eval MINOR := $(word 2,$(BASE_VERSION_PARTS)))
@$(eval PATCH := $(word 3,$(BASE_VERSION_PARTS)))
@$(eval MINOR := $(shell echo $$(($(MINOR)+1))))
@$(eval PATCH := 0)
$(call prompt_approval,$(MAJOR).$(MINOR).$(PATCH))
Expand All @@ -102,6 +117,11 @@ minor: ## to bump minor version (semver)
major: ## to bump major version (semver)
$(call check_protected_branch)
$(call check_pending_pulls)
@$(eval BASE_VERSION := $(strip $(LATEST_RELEASE_TAG)))
@$(eval BASE_VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(BASE_VERSION)))))
@$(eval MAJOR := $(word 1,$(BASE_VERSION_PARTS)))
@$(eval MINOR := $(word 2,$(BASE_VERSION_PARTS)))
@$(eval PATCH := $(word 3,$(BASE_VERSION_PARTS)))
$(eval MAJOR := $(shell echo $$(($(MAJOR)+1))))
$(eval MINOR := 0)
$(eval PATCH := 0)
Expand Down
71 changes: 36 additions & 35 deletions webapp/src/components/link_tooltip/link_tooltip.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import React, { useEffect, useMemo, useState } from 'react';
import React, {useEffect, useMemo, useState} from 'react';
import PropTypes from 'prop-types';
import './tooltip.css';
import { GitMergeIcon, GitPullRequestIcon, IssueClosedIcon, IssueOpenedIcon } from '@primer/octicons-react';
import {GitMergeIcon, GitPullRequestIcon, IssueClosedIcon, IssueOpenedIcon} from '@primer/octicons-react';
import ReactMarkdown from 'react-markdown';

import Client from '@/client';

import { getLabelFontColor, hexToRGB } from '../../utils/styles';
import {getLabelFontColor, hexToRGB} from '../../utils/styles';

const maxTicketDescriptionLength = 160;

export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) => {
export const LinkTooltip = ({href, connected, show, theme, enterpriseURL}) => {
const [data, setData] = useState(null);
useEffect(() => {
const initData = async () => {
Expand All @@ -37,12 +37,12 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) =>

let res;
switch (type) {
case 'issues':
res = await Client.getIssue(owner, repo, number);
break;
case 'pull':
res = await Client.getPullRequest(owner, repo, number);
break;
case 'issues':
res = await Client.getIssue(owner, repo, number);
break;
case 'pull':
res = await Client.getPullRequest(owner, repo, number);
break;
}
if (res) {
res.owner = owner;
Expand All @@ -64,6 +64,7 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) =>
if (!data?.user?.login) {
return null;
}

// Immediately map the html_url value when present (which should work for both Enterprise and Cloud)
if (data.user.html_url) {
return data.user.html_url;
Expand All @@ -88,32 +89,32 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) =>
let icon;
let color;
switch (data.type) {
case 'pull':
icon = <GitPullRequestIcon {...iconProps} />;

color = '#28a745';
if (data.state === 'closed') {
if (data.merged) {
color = '#6f42c1';
icon = <GitMergeIcon {...iconProps} />;
} else {
color = '#cb2431';
}
case 'pull':
icon = <GitPullRequestIcon {...iconProps}/>;

color = '#28a745';
if (data.state === 'closed') {
if (data.merged) {
color = '#6f42c1';
icon = <GitMergeIcon {...iconProps}/>;
} else {
color = '#cb2431';
}
}

break;
case 'issues':
color = data.state === 'open' ? '#28a745' : '#cb2431';
break;
case 'issues':
color = data.state === 'open' ? '#28a745' : '#cb2431';

if (data.state === 'open') {
icon = <IssueOpenedIcon {...iconProps} />;
} else {
icon = <IssueClosedIcon {...iconProps} />;
}
break;
if (data.state === 'open') {
icon = <IssueOpenedIcon {...iconProps}/>;
} else {
icon = <IssueClosedIcon {...iconProps}/>;
}
break;
}
return (
<span style={{ color }}>
<span style={{color}}>
{icon}
</span>
);
Expand All @@ -135,10 +136,10 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) =>
<div className='github-tooltip'>
<div
className='github-tooltip box github-tooltip--large github-tooltip--bottom-left p-4'
style={{ backgroundColor: theme.centerChannelBg, border: `1px solid ${hexToRGB(theme.centerChannelColor, '0.16')}` }}
style={{backgroundColor: theme.centerChannelBg, border: `1px solid ${hexToRGB(theme.centerChannelColor, '0.16')}`}}
>
<div className='header mb-1'>
<span style={{ color: theme.centerChannelColor }}>
<span style={{color: theme.centerChannelColor}}>
{data.repo}
</span>
{' on '}
Expand All @@ -156,7 +157,7 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) =>
href={href}
target='_blank'
rel='noopener noreferrer'
style={{ color: theme.centerChannelColor }}
style={{color: theme.centerChannelColor}}
>
<h5 className='mr-1'>{data.title}</h5>
<span>{'#' + data.number}</span>
Expand Down Expand Up @@ -202,7 +203,7 @@ export const LinkTooltip = ({ href, connected, show, theme, enterpriseURL }) =>
key={idx}
className='label mr-1'
title={label.description}
style={{ backgroundColor: '#' + label.color, color: getLabelFontColor(label.color) }}
style={{backgroundColor: '#' + label.color, color: getLabelFontColor(label.color)}}
>
<span>{label.name}</span>
</span>
Expand Down
26 changes: 13 additions & 13 deletions webapp/src/components/link_tooltip/link_tooltip.test.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from 'react';
import { mount } from 'enzyme';
import {mount} from 'enzyme';

import Client from '@/client';

import { LinkTooltip } from './link_tooltip';
import {LinkTooltip} from './link_tooltip';

jest.mock('@/client', () => ({
getIssue: jest.fn(),
getPullRequest: jest.fn(),
}));

jest.mock('react-markdown', () => () => <div />);
jest.mock('react-markdown', () => () => <div/>);

describe('LinkTooltip', () => {
const baseProps = {
Expand All @@ -37,7 +37,7 @@ describe('LinkTooltip', () => {
});

test('should fetch issue for github.com link', () => {
wrapper = mount(<LinkTooltip {...baseProps} />);
wrapper = mount(<LinkTooltip {...baseProps}/>);
expect(Client.getIssue).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '1');
});

Expand All @@ -46,7 +46,7 @@ describe('LinkTooltip', () => {
...baseProps,
href: 'https://github.com/mattermost/mattermost-plugin-github/pull/2',
};
wrapper = mount(<LinkTooltip {...props} />);
wrapper = mount(<LinkTooltip {...props}/>);
expect(Client.getPullRequest).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '2');
});

Expand All @@ -56,7 +56,7 @@ describe('LinkTooltip', () => {
href: 'https://github.example.com/mattermost/mattermost-plugin-github/issues/3',
enterpriseURL: 'https://github.example.com',
};
wrapper = mount(<LinkTooltip {...props} />);
wrapper = mount(<LinkTooltip {...props}/>);
expect(Client.getIssue).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '3');
});

Expand All @@ -66,7 +66,7 @@ describe('LinkTooltip', () => {
href: 'https://github.example.com/mattermost/mattermost-plugin-github/pull/4',
enterpriseURL: 'https://github.example.com',
};
wrapper = mount(<LinkTooltip {...props} />);
wrapper = mount(<LinkTooltip {...props}/>);
expect(Client.getPullRequest).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '4');
});

Expand All @@ -76,7 +76,7 @@ describe('LinkTooltip', () => {
href: 'https://github.example.com/mattermost/mattermost-plugin-github/issues/5',
enterpriseURL: 'https://github.example.com/',
};
wrapper = mount(<LinkTooltip {...props} />);
wrapper = mount(<LinkTooltip {...props}/>);
expect(Client.getIssue).toHaveBeenCalledWith('mattermost', 'mattermost-plugin-github', '5');
});

Expand All @@ -86,7 +86,7 @@ describe('LinkTooltip', () => {
href: 'https://other-github.com/mattermost/mattermost-plugin-github/issues/6',
enterpriseURL: 'https://github.example.com',
};
wrapper = mount(<LinkTooltip {...props} />);
wrapper = mount(<LinkTooltip {...props}/>);
expect(Client.getIssue).not.toHaveBeenCalled();
});

Expand All @@ -104,7 +104,7 @@ describe('LinkTooltip', () => {
created_at: '2023-01-01T00:00:00Z',
});

wrapper = mount(<LinkTooltip {...baseProps} />);
wrapper = mount(<LinkTooltip {...baseProps}/>);

await new Promise((resolve) => setTimeout(resolve, 0));
wrapper.update();
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('LinkTooltip', () => {
href: 'https://github.example.com/mattermost/mattermost-plugin-github/issues/3',
enterpriseURL: 'https://github.example.com',
};
wrapper = mount(<LinkTooltip {...props} />);
wrapper = mount(<LinkTooltip {...props}/>);

await new Promise((resolve) => setTimeout(resolve, 0));
wrapper.update();
Expand Down Expand Up @@ -160,7 +160,7 @@ describe('LinkTooltip', () => {
href: 'https://github.example.com/mattermost/mattermost-plugin-github/issues/3',
enterpriseURL: 'https://github.example.com/',
};
wrapper = mount(<LinkTooltip {...props} />);
wrapper = mount(<LinkTooltip {...props}/>);

await new Promise((resolve) => setTimeout(resolve, 0));
wrapper.update();
Expand All @@ -182,7 +182,7 @@ describe('LinkTooltip', () => {
created_at: '2023-01-01T00:00:00Z',
});

wrapper = mount(<LinkTooltip {...baseProps} />);
wrapper = mount(<LinkTooltip {...baseProps}/>);

await new Promise((resolve) => setTimeout(resolve, 0));
wrapper.update();
Expand Down
Loading