Skip to content

Commit

Permalink
Merge pull request #252 from dushimsam/dushimsam/feat/admin/maintenan…
Browse files Browse the repository at this point in the history
…ce-integration

feat(integration): Integrated the fossology maintenance page.

Reviewed-by: [email protected]
Tested-by:[email protected]
  • Loading branch information
shaheemazmalmmd committed Sep 6, 2022
2 parents 615a373 + 4714044 commit cf11dae
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 81 deletions.
4 changes: 2 additions & 2 deletions src/api/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import endpoints from "constants/endpoints";
import sendRequest from "./sendRequest";

export const getInfoApi = () => {
const url = endpoints.info.info();
const url = endpoints.admin.info.info();
return sendRequest({
url,
method: "GET",
});
};

export const getHealthApi = () => {
const url = endpoints.info.health();
const url = endpoints.admin.info.health();
return sendRequest({
url,
method: "GET",
Expand Down
4 changes: 2 additions & 2 deletions src/api/info.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jest.mock("api/sendRequest");

describe("info", () => {
test("getInfoApi", () => {
const url = endpoints.info.info();
const url = endpoints.admin.info.info();
sendRequest.mockImplementation(() => true);

expect(getInfoApi()).toBe(sendRequest({}));
Expand All @@ -34,7 +34,7 @@ describe("info", () => {
});

test("getHealthApi", () => {
const url = endpoints.info.health();
const url = endpoints.admin.info.health();
sendRequest.mockImplementation(() => true);

expect(getHealthApi()).toBe(sendRequest({}));
Expand Down
4 changes: 2 additions & 2 deletions src/api/licenses.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import sendRequest from "./sendRequest";

// Fetching the licenses with their kind i.e (candidate, main, all)
export const getAllLicenseApi = ({ page, limit, kind }) => {
const url = endpoints.license.get();
const url = endpoints.admin.license.get();
return sendRequest({
url,
method: "GET",
Expand All @@ -49,7 +49,7 @@ export const createCandidateLicenseApi = ({
licenseUrl,
mergeRequest,
}) => {
const url = endpoints.license.createCandidateLicense();
const url = endpoints.admin.license.createCandidateLicense();
return sendRequest({
url,
method: "POST",
Expand Down
4 changes: 2 additions & 2 deletions src/api/licenses.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("licenses", () => {
const page = 1;
const limit = 2;
const kind = "kind";
const url = endpoints.license.get();
const url = endpoints.admin.license.get();

sendRequest.mockImplementation(() => true);

Expand Down Expand Up @@ -53,7 +53,7 @@ describe("licenses", () => {
const risk = "risk";
const licenseUrl = "licenseUrl";
const mergeRequest = "mergeRequest";
const url = endpoints.license.createCandidateLicense();
const url = endpoints.admin.license.createCandidateLicense();

expect(
createCandidateLicenseApi({
Expand Down
39 changes: 39 additions & 0 deletions src/api/maintenance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright (C) 2022 Samuel Dushimimana ([email protected])
SPDX-License-Identifier: GPL-2.0
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
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 General Public License for more details.
You should have received a copy of the GNU 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.
*/

import endpoints from "constants/endpoints";

// Getting Authorization Token
import { getToken } from "shared/authHelper";

// Function for calling the fetch function for the APIs
import sendRequest from "./sendRequest";

// Creating a maintenance
export const createMaintenanceApi = (data) => {
const url = endpoints.admin.maintenance.create();
return sendRequest({
url,
method: "POST",
headers: {
Authorization: getToken(),
},
body: data,
});
};
export default createMaintenanceApi;
42 changes: 42 additions & 0 deletions src/api/maintenance.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright (C) 2022 Samuel Dushimimana ([email protected])
SPDX-License-Identifier: GPL-2.0
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
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 General Public License for more details.
You should have received a copy of the GNU 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.
*/

import sendRequest from "api/sendRequest";
import endpoints from "constants/endpoints";
import { getToken } from "shared/authHelper";
import { createMaintenanceApi } from "api/maintenance";

jest.mock("api/sendRequest");

describe("maintenance", () => {
test("createMaintenanceApi", () => {
const data = { options: ["O", "L"] };
const url = endpoints.admin.maintenance.create();

sendRequest.mockImplementation(() => true);
expect(createMaintenanceApi(data)).toBe(sendRequest({}));
expect(sendRequest).toHaveBeenCalledWith(
expect.objectContaining({
url,
method: "POST",
headers: {
Authorization: getToken(),
},
body: data,
})
);
});
});
6 changes: 3 additions & 3 deletions src/components/Widgets/Button/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const Button = ({
<ButtonContainer
type={type}
onClick={onClick}
data-toggle={dataToggle}
data-dismiss={dataDismiss}
data-target={dataTarget}
dataDismiss={dataDismiss}
dataToggle={dataToggle}
dataTarget={dataTarget}
className={`bg-primary-color text-secondary-color font-demi text-center hover-primary-color ${className}`}
disabled={disabled}
>
Expand Down
34 changes: 18 additions & 16 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,24 @@ export const initialFolderList = [
];

export const initialMantainanceFields = {
allNonSlow: false,
allOperations: false,
validateFolderContents: false,
rmvGoldFiles: false,
rmvOrphanedRows: false,
rmvLogFiles: false,
normalizePriority: false,
rmvUploads: false,
rmvTokens: false,
rmvTempTables: false,
analyseDb: false,
rmvRepoFiles: false,
dbReindexing: false,
verbose: false,
rmvRepoOldFiles1: false,
rmvRepoOldFiles2: false,
a: false,
A: false,
F: false,
g: false,
E: false,
L: false,
N: false,
R: false,
t: false,
T: false,
D: false,
Z: false,
I: false,
v: false,
o: false,
l: false,
logsDate: "",
goldDate: "",
};

export const accessLevels = [
Expand Down
19 changes: 11 additions & 8 deletions src/constants/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,17 @@ const endpoints = {
getAllDeletable: () => `${apiUrl}/groups/deletable`,
delete: (groupId) => `${apiUrl}/groups/${groupId}`,
},
},
license: {
get: () => `${apiUrl}/license`,
createCandidateLicense: () => `${apiUrl}/license`,
},
info: {
info: () => `${apiUrl}/info`,
health: () => `${apiUrl}/health`,
maintenance: {
create: () => `${apiUrl}/maintenance`,
},
license: {
get: () => `${apiUrl}/license`,
createCandidateLicense: () => `${apiUrl}/license`,
},
info: {
info: () => `${apiUrl}/info`,
health: () => `${apiUrl}/health`,
},
},
};

Expand Down
Loading

0 comments on commit cf11dae

Please sign in to comment.