summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJeremy Davis <jeremy.davis@sonarsource.com>2020-12-08 17:35:40 +0100
committersonartech <sonartech@sonarsource.com>2020-12-22 20:09:35 +0000
commit5141fc088089cdd155e8623e2d2f989e93c4fff4 (patch)
tree4def3277aa4bd90c0ca56cfe6644eeae7fbd0b74 /server
parent21bafe70615623b45a7e55097241f885c7519461 (diff)
downloadsonarqube-5141fc088089cdd155e8623e2d2f989e93c4fff4.tar.gz
sonarqube-5141fc088089cdd155e8623e2d2f989e93c4fff4.zip
SONAR-13999 Drop orgs from webhooks
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/api/webhooks.ts6
-rw-r--r--server/sonar-web/src/main/js/apps/webhooks/components/App.tsx5
-rw-r--r--server/sonar-web/src/main/js/apps/webhooks/components/__tests__/App-test.tsx38
3 files changed, 11 insertions, 38 deletions
diff --git a/server/sonar-web/src/main/js/api/webhooks.ts b/server/sonar-web/src/main/js/api/webhooks.ts
index 93d9e572c4e..2b4abe28128 100644
--- a/server/sonar-web/src/main/js/api/webhooks.ts
+++ b/server/sonar-web/src/main/js/api/webhooks.ts
@@ -22,7 +22,6 @@ import throwGlobalError from '../app/utils/throwGlobalError';
export function createWebhook(data: {
name: string;
- organization: string | undefined;
project?: string;
secret?: string;
url: string;
@@ -34,10 +33,7 @@ export function deleteWebhook(data: { webhook: string }): Promise<void | Respons
return post('/api/webhooks/delete', data).catch(throwGlobalError);
}
-export function searchWebhooks(data: {
- organization: string | undefined;
- project?: string;
-}): Promise<{ webhooks: T.Webhook[] }> {
+export function searchWebhooks(data: { project?: string }): Promise<{ webhooks: T.Webhook[] }> {
return getJSON('/api/webhooks/list', data).catch(throwGlobalError);
}
diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/App.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/App.tsx
index d4f3346219a..6e5f88ddc6a 100644
--- a/server/sonar-web/src/main/js/apps/webhooks/components/App.tsx
+++ b/server/sonar-web/src/main/js/apps/webhooks/components/App.tsx
@@ -28,7 +28,6 @@ import WebhooksList from './WebhooksList';
interface Props {
component?: T.LightComponent;
- organization: T.Organization | undefined;
}
interface State {
@@ -64,10 +63,8 @@ export default class App extends React.PureComponent<Props, State> {
);
};
- getScopeParams = ({ organization, component } = this.props) => {
- const organizationKey = organization && organization.key;
+ getScopeParams = ({ component } = this.props) => {
return {
- organization: component ? component.organization : organizationKey,
project: component && component.key
};
};
diff --git a/server/sonar-web/src/main/js/apps/webhooks/components/__tests__/App-test.tsx b/server/sonar-web/src/main/js/apps/webhooks/components/__tests__/App-test.tsx
index a539729cdbe..97196d6cd41 100644
--- a/server/sonar-web/src/main/js/apps/webhooks/components/__tests__/App-test.tsx
+++ b/server/sonar-web/src/main/js/apps/webhooks/components/__tests__/App-test.tsx
@@ -43,7 +43,6 @@ jest.mock('../../../../api/webhooks', () => ({
updateWebhook: jest.fn(() => Promise.resolve())
}));
-const organization: T.Organization = { key: 'foo', name: 'Foo', projectVisibility: 'private' };
const component = { key: 'bar', organization: 'foo', qualifier: 'TRK' };
beforeEach(() => {
@@ -54,15 +53,15 @@ beforeEach(() => {
});
it('should be in loading status', () => {
- expect(shallow(<App organization={undefined} />)).toMatchSnapshot();
+ expect(shallow(<App />)).toMatchSnapshot();
});
it('should fetch webhooks and display them', async () => {
- const wrapper = shallow(<App organization={organization} />);
+ const wrapper = shallow(<App />);
expect(wrapper.state('loading')).toBe(true);
await new Promise(setImmediate);
- expect(searchWebhooks).toHaveBeenCalledWith({ organization: organization.key });
+ expect(searchWebhooks).toHaveBeenCalledWith({});
wrapper.update();
expect(wrapper).toMatchSnapshot();
@@ -70,35 +69,17 @@ it('should fetch webhooks and display them', async () => {
describe('should correctly fetch webhooks when', () => {
it('on global scope', async () => {
- shallow(<App organization={undefined} />);
+ shallow(<App />);
await new Promise(setImmediate);
- expect(searchWebhooks).toHaveBeenCalledWith({ organization: undefined });
+ expect(searchWebhooks).toHaveBeenCalledWith({ projects: undefined });
});
it('on project scope', async () => {
- shallow(<App component={component} organization={undefined} />);
+ shallow(<App component={component} />);
await new Promise(setImmediate);
expect(searchWebhooks).toHaveBeenCalledWith({
- project: component.key,
- organization: component.organization
- });
- });
-
- it('on organization scope', async () => {
- shallow(<App component={undefined} organization={organization} />);
-
- await new Promise(setImmediate);
- expect(searchWebhooks).toHaveBeenCalledWith({ organization: organization.key });
- });
-
- it('on project scope within an organization', async () => {
- shallow(<App component={component} organization={organization} />);
-
- await new Promise(setImmediate);
- expect(searchWebhooks).toHaveBeenCalledWith({
- organization: organization.key,
project: component.key
});
});
@@ -106,11 +87,10 @@ describe('should correctly fetch webhooks when', () => {
it('should correctly handle webhook creation', async () => {
const webhook = { name: 'baz', url: 'http://baz' };
- const wrapper = shallow(<App organization={organization} />);
+ const wrapper = shallow(<App />);
(wrapper.instance() as App).handleCreate({ ...webhook });
expect(createWebhook).lastCalledWith({
...webhook,
- organization: organization.key,
project: undefined
});
@@ -124,7 +104,7 @@ it('should correctly handle webhook creation', async () => {
});
it('should correctly handle webhook deletion', async () => {
- const wrapper = shallow(<App organization={undefined} />);
+ const wrapper = shallow(<App />);
(wrapper.instance() as App).handleDelete('2');
expect(deleteWebhook).lastCalledWith({ webhook: '2' });
@@ -135,7 +115,7 @@ it('should correctly handle webhook deletion', async () => {
it('should correctly handle webhook update', async () => {
const newValues = { webhook: '1', name: 'Cfoo', url: 'http://cfoo' };
- const wrapper = shallow(<App organization={undefined} />);
+ const wrapper = shallow(<App />);
(wrapper.instance() as App).handleUpdate(newValues);
expect(updateWebhook).lastCalledWith(newValues);