Wizard: Cleanup after removing V1
This removes files that are no longer needed and uninstalls DDF dependencies.
This commit is contained in:
parent
3082cdd81a
commit
0ac68864f4
3 changed files with 0 additions and 124 deletions
|
|
@ -7,8 +7,6 @@
|
|||
"npm": ">=7.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@data-driven-forms/pf4-component-mapper": "3.22.4",
|
||||
"@data-driven-forms/react-form-renderer": "3.22.4",
|
||||
"@patternfly/patternfly": "5.3.1",
|
||||
"@patternfly/react-core": "5.3.3",
|
||||
"@patternfly/react-code-editor": "5.3.3",
|
||||
|
|
@ -104,7 +102,6 @@
|
|||
"msw": "1.2.3",
|
||||
"npm-run-all": "4.1.5",
|
||||
"postcss-scss": "4.0.9",
|
||||
"prop-types": "15.8.1",
|
||||
"react-chartjs-2": "5.2.0",
|
||||
"redux-mock-store": "1.5.4",
|
||||
"sass": "1.77.6",
|
||||
|
|
|
|||
|
|
@ -1,76 +0,0 @@
|
|||
import { useMemo } from 'react';
|
||||
|
||||
import { useFormApi } from '@data-driven-forms/react-form-renderer';
|
||||
|
||||
import { releaseToVersion } from './releaseToVersion';
|
||||
|
||||
import { useListRepositoriesQuery } from '../store/contentSourcesApi';
|
||||
|
||||
/**
|
||||
* This checks the list of the payload repositories against a list of repos freshly
|
||||
* fetched from content source API and returns true whether there are some
|
||||
* repositories that are no longer available in the Repositories service.
|
||||
*
|
||||
* (The payload repositories are comming from the useFormApi hook).
|
||||
*/
|
||||
export const useCheckRepositoriesAvailability = () => {
|
||||
const { getState } = useFormApi();
|
||||
|
||||
const arch = getState().values?.arch;
|
||||
const release = getState().values?.release;
|
||||
const version = releaseToVersion(release);
|
||||
|
||||
// There needs to be two requests because the default limit for the
|
||||
// useListRepositoriesQuery is a 100 elements, and a first request is
|
||||
// necessary to know the total amount of elements to fetch.
|
||||
const firstRequest = useListRepositoriesQuery({
|
||||
availableForArch: arch,
|
||||
availableForVersion: version,
|
||||
contentType: 'rpm',
|
||||
origin: 'external',
|
||||
});
|
||||
|
||||
const skip =
|
||||
firstRequest?.data?.meta?.count === undefined ||
|
||||
firstRequest?.data?.meta?.count <= 100;
|
||||
|
||||
// Fetch *all* repositories if there are more than 100
|
||||
const followupRequest = useListRepositoriesQuery(
|
||||
{
|
||||
availableForArch: arch,
|
||||
availableForVersion: version,
|
||||
contentType: 'rpm',
|
||||
origin: 'external',
|
||||
limit: firstRequest?.data?.meta?.count,
|
||||
offset: 0,
|
||||
},
|
||||
{
|
||||
skip: skip,
|
||||
}
|
||||
);
|
||||
|
||||
const { data: freshRepos, isSuccess } = useMemo(() => {
|
||||
if (firstRequest?.data?.meta?.count) {
|
||||
if (firstRequest?.data?.meta?.count > 100) {
|
||||
return { ...followupRequest };
|
||||
}
|
||||
}
|
||||
return { ...firstRequest };
|
||||
}, [firstRequest, followupRequest]);
|
||||
|
||||
const payloadRepositories = getState()?.values?.['payload-repositories'];
|
||||
// payloadRepositories existing === we came here from Recreate
|
||||
if (isSuccess && payloadRepositories) {
|
||||
// Transform the fresh repos array into a Set to access its elements in O(1)
|
||||
// complexity later in the for loop.
|
||||
const freshReposUrls = new Set(
|
||||
freshRepos.data?.map((freshRepo) => freshRepo.url)
|
||||
);
|
||||
for (const payloadRepo of payloadRepositories) {
|
||||
if (!freshReposUrls.has(payloadRepo.baseurl)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
45
src/api.js
45
src/api.js
|
|
@ -1,45 +0,0 @@
|
|||
import axios from 'axios';
|
||||
|
||||
import { CONTENT_SOURCES_API, IMAGE_BUILDER_API } from './constants';
|
||||
|
||||
const postHeaders = { headers: { 'Content-Type': 'application/json' } };
|
||||
|
||||
async function getPackages(distribution, architecture, search, limit) {
|
||||
const params = new URLSearchParams({
|
||||
distribution,
|
||||
architecture,
|
||||
search,
|
||||
});
|
||||
limit && params.append('limit', limit);
|
||||
const path = '/packages?' + params.toString();
|
||||
const request = await axios.get(IMAGE_BUILDER_API.concat(path));
|
||||
return request.data;
|
||||
}
|
||||
|
||||
async function getPackagesContentSources(repoUrls, search) {
|
||||
// content-sources expects an array of urls but we store the whole repo object
|
||||
// so map the urls into an array to send to the content-sources api
|
||||
const body = {
|
||||
urls: repoUrls,
|
||||
search,
|
||||
};
|
||||
const path = '/rpms/names';
|
||||
const request = await axios.post(
|
||||
CONTENT_SOURCES_API.concat(path),
|
||||
body,
|
||||
postHeaders
|
||||
);
|
||||
// map `package_name` key to just `name` since that's what we use across the UI
|
||||
const packages = request.data.map(({ package_name: name, ...rest }) => ({
|
||||
name,
|
||||
...rest,
|
||||
}));
|
||||
return packages;
|
||||
}
|
||||
|
||||
const apiCalls = {
|
||||
getPackages,
|
||||
getPackagesContentSources,
|
||||
};
|
||||
|
||||
export default apiCalls;
|
||||
Loading…
Add table
Add a link
Reference in a new issue