]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-13999 Drop orgs from webhooks
authorJeremy Davis <jeremy.davis@sonarsource.com>
Tue, 8 Dec 2020 16:35:40 +0000 (17:35 +0100)
committersonartech <sonartech@sonarsource.com>
Tue, 22 Dec 2020 20:09:35 +0000 (20:09 +0000)
server/sonar-web/src/main/js/api/webhooks.ts
server/sonar-web/src/main/js/apps/webhooks/components/App.tsx
server/sonar-web/src/main/js/apps/webhooks/components/__tests__/App-test.tsx

index 93d9e572c4e0a6ab5a3895a7820b54a507e26e4e..2b4abe28128a1e6ebe554474783905bcfc20fe68 100644 (file)
@@ -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);
 }
 
index d4f3346219acb8aa9543973633c11640f2c3f1c1..6e5f88ddc6a15699f8b65eae2a007f6502a550bb 100644 (file)
@@ -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
     };
   };
index a539729cdbe0d2cc65b80bb82dc7e3ea273cb31a..97196d6cd41b1eb65afa48cdd4489a94594ab34c 100644 (file)
@@ -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);