aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/account
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2018-03-27 11:52:20 +0200
committerSonarTech <sonartech@sonarsource.com>2018-05-16 20:20:46 +0200
commit965717195e58808778753edd0daa0e3d9e831cdd (patch)
treef1aaeebba925cec8366fae5eccfa1f1f08fc11d6 /server/sonar-web/src/main/js/apps/account
parent5073eb0f98e99ab0efbdd3f34b07a97f11e1d26c (diff)
downloadsonarqube-965717195e58808778753edd0daa0e3d9e831cdd.tar.gz
sonarqube-965717195e58808778753edd0daa0e3d9e831cdd.zip
Introduce Bitbucket Cloud Application
SONAR-10514 Bitbucket Cloud application install/uninstall * Bitbucket Cloud /install WS * Expose Bitbucket application descriptor as WS * Implement WS /integration/bitbucketcloud/uninstall SONAR-10517 Bitbucket Cloud settings widget * Create Bitbucket Cloud module * Create Bitbucket Setting widget * Bitbucket settings widget require SC authentication * Add WS /integration/bitbucketcloud/repo_config * Add WS /integration/bitbucketcloud/bind_repo * Add WS /integration/bitbucketcloud/after_login SONAR-10516 Bitbucket Cloud repository widget * Add WS /integration/bitbucketcloud/repo_widget * Add WS /integration/bitbucketcloud/repo_widget_data BRANCH-59, BRANCH-60 Bitbucket Cloud PR decoration SONAR-10605 Bitbucket Cloud PR widget * Add integration/bitbucketcloud/pr_widget endpoint * Add integration/bitbucketcloud/pr_widget_data endpoint
Diffstat (limited to 'server/sonar-web/src/main/js/apps/account')
-rw-r--r--server/sonar-web/src/main/js/apps/account/projects/ProjectCard.tsx18
-rw-r--r--server/sonar-web/src/main/js/apps/account/projects/Projects.tsx9
-rw-r--r--server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.tsx45
-rw-r--r--server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.tsx (renamed from server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.js)4
-rw-r--r--server/sonar-web/src/main/js/apps/account/projects/__tests__/Projects-test.tsx (renamed from server/sonar-web/src/main/js/apps/account/projects/__tests__/Projects-test.js)33
-rw-r--r--server/sonar-web/src/main/js/apps/account/projects/types.ts32
6 files changed, 39 insertions, 102 deletions
diff --git a/server/sonar-web/src/main/js/apps/account/projects/ProjectCard.tsx b/server/sonar-web/src/main/js/apps/account/projects/ProjectCard.tsx
index 15d180785b7..f05af84c229 100644
--- a/server/sonar-web/src/main/js/apps/account/projects/ProjectCard.tsx
+++ b/server/sonar-web/src/main/js/apps/account/projects/ProjectCard.tsx
@@ -20,29 +20,29 @@
import * as React from 'react';
import { sortBy } from 'lodash';
import { Link } from 'react-router';
-import { Project } from './types';
import DateFromNow from '../../../components/intl/DateFromNow';
import DateTimeFormatter from '../../../components/intl/DateTimeFormatter';
import Level from '../../../components/ui/Level';
import Tooltip from '../../../components/controls/Tooltip';
import { translateWithParameters, translate } from '../../../helpers/l10n';
+import { MyProject } from '../../../app/types';
interface Props {
- project: Project;
+ project: MyProject;
}
export default function ProjectCard({ project }: Props) {
- const isAnalyzed = project.lastAnalysisDate != null;
const links = sortBy(project.links, 'type');
+ const { lastAnalysisDate } = project;
return (
<div className="account-project-card clearfix">
<aside className="account-project-side">
- {isAnalyzed ? (
+ {lastAnalysisDate !== undefined ? (
<div className="account-project-analysis">
- <DateFromNow date={project.lastAnalysisDate}>
+ <DateFromNow date={lastAnalysisDate}>
{fromNow => (
- <Tooltip overlay={<DateTimeFormatter date={project.lastAnalysisDate} />}>
+ <Tooltip overlay={<DateTimeFormatter date={lastAnalysisDate} />}>
<span>{translateWithParameters('my_account.projects.analyzed_x', fromNow)}</span>
</Tooltip>
)}
@@ -54,7 +54,7 @@ export default function ProjectCard({ project }: Props) {
</div>
)}
- {project.qualityGate != null && (
+ {project.qualityGate !== undefined && (
<div className="account-project-quality-gate">
<Level level={project.qualityGate} />
</div>
@@ -73,9 +73,9 @@ export default function ProjectCard({ project }: Props) {
<a
className="link-with-icon"
href={link.href}
- title={link.name}
+ rel="nofollow"
target="_blank"
- rel="nofollow">
+ title={link.name}>
<i className={`icon-color-link icon-${link.type}`} />
</a>
</li>
diff --git a/server/sonar-web/src/main/js/apps/account/projects/Projects.tsx b/server/sonar-web/src/main/js/apps/account/projects/Projects.tsx
index ba029ffc813..15a00318c4b 100644
--- a/server/sonar-web/src/main/js/apps/account/projects/Projects.tsx
+++ b/server/sonar-web/src/main/js/apps/account/projects/Projects.tsx
@@ -19,15 +19,14 @@
*/
import * as React from 'react';
import ProjectCard from './ProjectCard';
-import { Project } from './types';
import ListFooter from '../../../components/controls/ListFooter';
import { translate } from '../../../helpers/l10n';
+import { MyProject } from '../../../app/types';
interface Props {
loading: boolean;
loadMore: () => void;
- projects: Project[];
- search: (query: string) => void;
+ projects: MyProject[];
total?: number;
}
@@ -55,9 +54,9 @@ export default function Projects(props: Props) {
{projects.length > 0 && (
<ListFooter
count={projects.length}
- total={props.total || 0}
- ready={!props.loading}
loadMore={props.loadMore}
+ ready={!props.loading}
+ total={props.total || 0}
/>
)}
</div>
diff --git a/server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.tsx b/server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.tsx
index 923c7c9acb8..a5d62ac64a3 100644
--- a/server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.tsx
+++ b/server/sonar-web/src/main/js/apps/account/projects/ProjectsContainer.tsx
@@ -22,22 +22,18 @@ import Helmet from 'react-helmet';
import Projects from './Projects';
import { getMyProjects } from '../../../api/components';
import { translate } from '../../../helpers/l10n';
+import { MyProject } from '../../../app/types';
interface State {
loading: boolean;
page: number;
- projects?: any[];
- query: string;
+ projects?: MyProject[];
total?: number;
}
export default class ProjectsContainer extends React.PureComponent<{}, State> {
mounted = false;
- state: State = {
- loading: true,
- page: 1,
- query: ''
- };
+ state: State = { loading: true, page: 1 };
componentDidMount() {
this.mounted = true;
@@ -48,30 +44,22 @@ export default class ProjectsContainer extends React.PureComponent<{}, State> {
this.mounted = false;
}
- loadProjects(page = this.state.page, query = this.state.query) {
+ loadProjects(page = this.state.page) {
this.setState({ loading: true });
- const data: { [p: string]: any } = { ps: 100 };
- if (page > 1) {
- data.p = page;
- }
- if (query) {
- data.q = query;
- }
- return getMyProjects(data).then((r: any) => {
- const projects = page > 1 ? [...(this.state.projects || []), ...r.projects] : r.projects;
- this.setState({
- projects,
- query,
+ const data = { p: page, ps: 100 };
+ return getMyProjects(data).then(({ paging, projects }) => {
+ this.setState(state => ({
+ projects: page > 1 ? [...(state.projects || []), ...projects] : projects,
loading: false,
- page: r.paging.pageIndex,
- total: r.paging.total
- });
+ page: paging.pageIndex,
+ total: paging.total
+ }));
});
}
- loadMore = () => this.loadProjects(this.state.page + 1);
-
- search = (query: string) => this.loadProjects(1, query);
+ loadMore = () => {
+ this.loadProjects(this.state.page + 1);
+ };
render() {
const helmet = <Helmet title={translate('my_account.projects')} />;
@@ -89,11 +77,10 @@ export default class ProjectsContainer extends React.PureComponent<{}, State> {
<div className="account-body account-container">
{helmet}
<Projects
+ loadMore={this.loadMore}
+ loading={this.state.loading}
projects={this.state.projects}
total={this.state.total}
- loading={this.state.loading}
- loadMore={this.loadMore}
- search={this.search}
/>
</div>
);
diff --git a/server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.js b/server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.tsx
index c714da617dc..924a53f21e1 100644
--- a/server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.js
+++ b/server/sonar-web/src/main/js/apps/account/projects/__tests__/ProjectCard-test.tsx
@@ -17,13 +17,13 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import React from 'react';
+import * as React from 'react';
import { shallow } from 'enzyme';
import { Link } from 'react-router';
import ProjectCard from '../ProjectCard';
import Level from '../../../../components/ui/Level';
-const BASE = { id: 'id', key: 'key', name: 'name', links: [] };
+const BASE = { key: 'key', links: [], name: 'name' };
it('should render key and name', () => {
const project = { ...BASE };
diff --git a/server/sonar-web/src/main/js/apps/account/projects/__tests__/Projects-test.js b/server/sonar-web/src/main/js/apps/account/projects/__tests__/Projects-test.tsx
index a11086a28ce..0d2cf182fad 100644
--- a/server/sonar-web/src/main/js/apps/account/projects/__tests__/Projects-test.js
+++ b/server/sonar-web/src/main/js/apps/account/projects/__tests__/Projects-test.tsx
@@ -17,46 +17,29 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import React from 'react';
+import * as React from 'react';
import { shallow } from 'enzyme';
import Projects from '../Projects';
import ProjectCard from '../ProjectCard';
import ListFooter from '../../../../components/controls/ListFooter';
+const PROJECTS = [
+ { key: 'key1', links: [], name: 'name1' },
+ { key: 'key2', links: [], name: 'name2' }
+];
it('should render list of ProjectCards', () => {
- const projects = [
- { id: 'id1', key: 'key1', name: 'name1', links: [] },
- { id: 'id2', key: 'key2', name: 'name2', links: [] }
- ];
-
const output = shallow(
- <Projects
- projects={projects}
- total={5}
- loading={false}
- search={() => true}
- loadMore={() => true}
- />
+ <Projects loadMore={() => true} loading={false} projects={PROJECTS} total={5} />
);
expect(output.find(ProjectCard).length).toBe(2);
});
it('should render ListFooter', () => {
- const projects = [
- { id: 'id1', key: 'key1', name: 'name1', links: [] },
- { id: 'id2', key: 'key2', name: 'name2', links: [] }
- ];
const loadMore = jest.fn();
const footer = shallow(
- <Projects
- projects={projects}
- total={5}
- loading={false}
- search={() => true}
- loadMore={loadMore}
- />
+ <Projects loadMore={loadMore} loading={false} projects={PROJECTS} total={5} />
).find(ListFooter);
expect(footer.length).toBe(1);
@@ -67,7 +50,7 @@ it('should render ListFooter', () => {
it('should render when no results', () => {
const output = shallow(
- <Projects projects={[]} total={0} loading={false} search={() => true} loadMore={() => true} />
+ <Projects loadMore={() => true} loading={false} projects={[]} total={0} />
);
expect(output.find('.js-no-results').length).toBe(1);
diff --git a/server/sonar-web/src/main/js/apps/account/projects/types.ts b/server/sonar-web/src/main/js/apps/account/projects/types.ts
deleted file mode 100644
index 930334bea55..00000000000
--- a/server/sonar-web/src/main/js/apps/account/projects/types.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-export interface Project {
- id: string;
- key: string;
- name: string;
- lastAnalysisDate: string;
- description: string;
- links: Array<{
- href: string;
- name: string;
- type: string;
- }>;
- qualityGate: string;
-}