Skip to content

Commit

Permalink
Merge branch 'fossology:main' into krishna9304/167/warning-in-delete-…
Browse files Browse the repository at this point in the history
…user-page
  • Loading branch information
krishna9304 authored Jun 7, 2022
2 parents 785adc7 + e11ded8 commit 6bdac2a
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 69 deletions.
5 changes: 0 additions & 5 deletions src/api/sendRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { getLocalStorage, setLocalStorage } from "shared/storageHelper";
const sendRequest = ({
url,
method,
credentials = false,
body,
groupName,
headers = {},
Expand Down Expand Up @@ -80,10 +79,6 @@ const sendRequest = ({
} else {
options.body = null;
}

if (credentials) {
options.credentials = credentials;
}
if (queryParams) {
URL = `${url}?${stringify(queryParams)}`;
}
Expand Down
22 changes: 0 additions & 22 deletions src/api/sendRequest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,28 +146,6 @@ describe("sendRequest", () => {
);
});

test("sendRequest handles credentials", async () => {
defaultArgs.credentials = "user:password";
fetch.mockResponse(JSON.stringify({}));

await sendRequest(defaultArgs);

expect(fetch).toHaveBeenCalledWith(
defaultArgs.url,
expect.objectContaining({
body: defaultArgs.body,
credentials: defaultArgs.credentials,
headers: new Headers({
"content-type": "application/json",
accept: "application/json",
groupName: "myGroupName",
...defaultArgs.headers,
}),
method: defaultArgs.method,
})
);
});

test("sendRequest handles queryParams", async () => {
defaultArgs.queryParams = {
option1: "abc",
Expand Down
1 change: 0 additions & 1 deletion src/api/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export const createUploadVcsApi = (header, body) => {
return sendRequest({
url,
method: "POST",
credentials: false,
headers: {
...header,
Authorization: getToken(),
Expand Down
1 change: 0 additions & 1 deletion src/api/upload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ describe("upload", () => {
expect.objectContaining({
url,
method: "POST",
credentials: false,
headers: {
...header,
Authorization: getToken(),
Expand Down
2 changes: 0 additions & 2 deletions src/api/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export const getAllUsersApi = () => {
return sendRequest({
url,
method: "GET",
credentials: "include",
headers: {
Authorization: getToken(),
},
Expand All @@ -56,7 +55,6 @@ export const deleteUserApi = (id) => {
return sendRequest({
url,
method: "DELETE",
credentials: "include",
headers: {
Authorization: getToken(),
},
Expand Down
2 changes: 0 additions & 2 deletions src/api/users.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ describe("users", () => {
expect.objectContaining({
url,
method: "GET",
credentials: "include",
headers: {
Authorization: getToken(),
},
Expand All @@ -65,7 +64,6 @@ describe("users", () => {
expect.objectContaining({
url,
method: "DELETE",
credentials: "include",
headers: {
Authorization: getToken(),
},
Expand Down
35 changes: 35 additions & 0 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,38 @@ export const initialMessage = {
type: "success",
text: "",
};

export const initialState = {
searchType: "allfiles",
uploadId: "",
filename: "",
tag: "",
filesizemin: "",
filesizemax: "",
license: "",
copyright: "",
page: 1,
limit: 10,
};
export const initialMessageSearch = {
type: "danger",
text: "",
};
export const entriesOptionsSearch = [
{
id: 10,
entry: "10",
},
{
id: 25,
entry: "25",
},
{
id: 50,
entry: "50",
},
{
id: 100,
entry: "100",
},
];
45 changes: 9 additions & 36 deletions src/pages/Search/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,14 @@ import { Alert, Button, InputContainer, Spinner } from "components/Widgets";
// Required functions for calling APIs
import search from "services/search";

// Required constants
import {
initialState,
initialMessageSearch,
entriesOptionsSearch,
} from "../../constants/constants";

const Search = () => {
const initialState = {
searchType: "allfiles",
uploadId: "",
filename: "",
tag: "",
filesizemin: "",
filesizemax: "",
license: "",
copyright: "",
page: 1,
limit: 10,
};
const initialMessage = {
type: "danger",
text: "",
};
const entriesOptions = [
{
id: 10,
entry: "10",
},
{
id: 25,
entry: "25",
},
{
id: 50,
entry: "50",
},
{
id: 100,
entry: "100",
},
];
// Data for searching specific uploads
const [searchData, setSearchData] = useState(initialState);

Expand All @@ -74,7 +47,7 @@ const Search = () => {
// State Variables for handling Error Boundaries
const [loading, setLoading] = useState(false);
const [showMessage, setShowMessage] = useState(false);
const [message, setMessage] = useState(initialMessage);
const [message, setMessage] = useState(initialMessageSearch);

const handleSubmit = (e) => {
e.preventDefault();
Expand Down Expand Up @@ -146,7 +119,7 @@ const Search = () => {
name="limit"
type="select"
onChange={(e) => handleChange(e)}
options={entriesOptions}
options={entriesOptionsSearch}
property="entry"
>
Show entries:
Expand Down

0 comments on commit 6bdac2a

Please sign in to comment.