breaking: some more changes in the frontend. removing support for v1alpha1
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -6,4 +6,4 @@ metadata:
|
||||
spec:
|
||||
type: url
|
||||
targets:
|
||||
# - https://github.com/spotify/cookiecutter-golang/blob/master/template.yaml
|
||||
- https://github.com/spotify/cookiecutter-golang/blob/master/template.yaml
|
||||
|
||||
@@ -14,7 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { EntityMeta, TemplateEntityV1alpha1 } from '@backstage/catalog-model';
|
||||
import { EntityMeta, TemplateEntityV1beta2 } from '@backstage/catalog-model';
|
||||
import {
|
||||
Content,
|
||||
ContentHeader,
|
||||
Header,
|
||||
ItemCardGrid,
|
||||
Lifecycle,
|
||||
Page,
|
||||
Progress,
|
||||
SupportButton,
|
||||
} from '@backstage/core-components';
|
||||
import { useStarredEntities } from '@backstage/plugin-catalog-react';
|
||||
import { Button, Link, makeStyles, Typography } from '@material-ui/core';
|
||||
import StarIcon from '@material-ui/icons/Star';
|
||||
@@ -30,18 +40,6 @@ import { TemplateCard } from '../TemplateCard';
|
||||
|
||||
import { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';
|
||||
|
||||
import {
|
||||
Content,
|
||||
ContentHeader,
|
||||
Header,
|
||||
ItemCardGrid,
|
||||
Lifecycle,
|
||||
Page,
|
||||
Progress,
|
||||
SupportButton,
|
||||
WarningPanel,
|
||||
} from '@backstage/core-components';
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
contentWrapper: {
|
||||
display: 'grid',
|
||||
@@ -90,7 +88,7 @@ export const ScaffolderPageContents = () => {
|
||||
);
|
||||
const [search, setSearch] = useState('');
|
||||
const [matchingEntities, setMatchingEntities] = useState(
|
||||
[] as TemplateEntityV1alpha1[],
|
||||
[] as TemplateEntityV1beta2[],
|
||||
);
|
||||
|
||||
const matchesQuery = (metadata: EntityMeta, query: string) =>
|
||||
@@ -175,11 +173,7 @@ export const ScaffolderPageContents = () => {
|
||||
{matchingEntities &&
|
||||
matchingEntities?.length > 0 &&
|
||||
matchingEntities.map((template, i) => (
|
||||
<TemplateCard
|
||||
key={i}
|
||||
template={template}
|
||||
deprecated={template.apiVersion === 'backstage.io/v1alpha1'}
|
||||
/>
|
||||
<TemplateCard key={i} template={template} />
|
||||
))}
|
||||
</ItemCardGrid>
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
import { JsonObject, JsonValue } from '@backstage/config';
|
||||
import { LinearProgress } from '@material-ui/core';
|
||||
import { FieldValidation, FormValidation, IChangeEvent } from '@rjsf/core';
|
||||
import parseGitUrl from 'git-url-parse';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import { generatePath, Navigate, useNavigate } from 'react-router';
|
||||
import { useParams } from 'react-router-dom';
|
||||
@@ -99,39 +98,6 @@ export const createValidator = (
|
||||
};
|
||||
};
|
||||
|
||||
const storePathValidator = (
|
||||
formData: { storePath?: string },
|
||||
errors: FormValidation,
|
||||
) => {
|
||||
const { storePath } = formData;
|
||||
if (!storePath) {
|
||||
errors.storePath.addError('Store path is required and not present');
|
||||
return errors;
|
||||
}
|
||||
|
||||
try {
|
||||
const parsedUrl = parseGitUrl(storePath);
|
||||
|
||||
if (!parsedUrl.resource || !parsedUrl.owner || !parsedUrl.name) {
|
||||
if (parsedUrl.resource === 'dev.azure.com') {
|
||||
errors.storePath.addError(
|
||||
"The store path should be formatted like https://dev.azure.com/{org}/{project}/_git/{repo} for Azure URL's",
|
||||
);
|
||||
} else {
|
||||
errors.storePath.addError(
|
||||
'The store path should be a complete Git URL to the new repository location. For example: https://github.com/{owner}/{repo}',
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (ex) {
|
||||
errors.storePath.addError(
|
||||
`Failed validation of the store path with message ${ex.message}`,
|
||||
);
|
||||
}
|
||||
|
||||
return errors;
|
||||
};
|
||||
|
||||
export const TemplatePage = ({
|
||||
customFieldExtensions = [],
|
||||
}: {
|
||||
@@ -203,15 +169,6 @@ export const TemplatePage = ({
|
||||
onReset={handleFormReset}
|
||||
onFinish={handleCreate}
|
||||
steps={schema.steps.map(step => {
|
||||
// TODO: Can delete this function when the migration from v1 to v2 beta is completed
|
||||
// And just have the default validator for all fields.
|
||||
if ((step.schema as any)?.properties?.storePath) {
|
||||
return {
|
||||
...step,
|
||||
validate: (a, b) => storePathValidator(a, b),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
...step,
|
||||
validate: createValidator(step.schema, customFieldValidators),
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TemplateEntityV1alpha1 } from '@backstage/catalog-model';
|
||||
import { TemplateEntityV1beta2 } from '@backstage/catalog-model';
|
||||
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useAsyncFn } from 'react-use';
|
||||
@@ -50,7 +50,7 @@ function useProvideEntityFilters(): FilterGroupsContext {
|
||||
const response = await catalogApi.getEntities({
|
||||
filter: { kind: 'Template' },
|
||||
});
|
||||
return response.items as TemplateEntityV1alpha1[];
|
||||
return response.items as TemplateEntityV1beta2[];
|
||||
});
|
||||
|
||||
const filterGroups = useRef<{
|
||||
@@ -64,7 +64,7 @@ function useProvideEntityFilters(): FilterGroupsContext {
|
||||
[filterGroupId: string]: FilterGroupStates;
|
||||
}>({});
|
||||
const [filteredEntities, setFilteredEntities] = useState<
|
||||
TemplateEntityV1alpha1[]
|
||||
TemplateEntityV1beta2[]
|
||||
>([]);
|
||||
const [availableCategories, setAvailableCategories] = useState<string[]>([]);
|
||||
const [isCatalogEmpty, setCatalogEmpty] = useState<boolean>(false);
|
||||
@@ -161,7 +161,7 @@ function buildStates(
|
||||
filterGroups: { [filterGroupId: string]: FilterGroup },
|
||||
selectedFilterKeys: { [filterGroupId: string]: Set<string> },
|
||||
selectedCategories: string[],
|
||||
entities?: TemplateEntityV1alpha1[],
|
||||
entities?: TemplateEntityV1beta2[],
|
||||
error?: Error,
|
||||
): { [filterGroupId: string]: FilterGroupStates } {
|
||||
// On error - all entries are an error state
|
||||
@@ -208,7 +208,7 @@ function buildStates(
|
||||
}
|
||||
|
||||
// Given all entites, find all possible categories and provide them in a sorted list.
|
||||
function collectCategories(entities?: TemplateEntityV1alpha1[]): string[] {
|
||||
function collectCategories(entities?: TemplateEntityV1beta2[]): string[] {
|
||||
const categories = new Set<string>();
|
||||
(entities || []).forEach(e => {
|
||||
if (e.spec?.type) {
|
||||
@@ -224,9 +224,9 @@ function buildMatchingEntities(
|
||||
filterGroups: { [filterGroupId: string]: FilterGroup },
|
||||
selectedFilterKeys: { [filterGroupId: string]: Set<string> },
|
||||
selectedCategories: string[],
|
||||
entities?: TemplateEntityV1alpha1[],
|
||||
entities?: TemplateEntityV1beta2[],
|
||||
excludeFilterGroupId?: string,
|
||||
): TemplateEntityV1alpha1[] {
|
||||
): TemplateEntityV1beta2[] {
|
||||
// Build one filter fn per filter group
|
||||
const allFilters: EntityFilterFn[] = [];
|
||||
for (const [filterGroupId, filterGroup] of Object.entries(filterGroups)) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TemplateEntityV1alpha1 } from '@backstage/catalog-model';
|
||||
import { TemplateEntityV1beta2 } from '@backstage/catalog-model';
|
||||
import { createContext } from 'react';
|
||||
import { FilterGroup, FilterGroupStates } from './types';
|
||||
|
||||
@@ -32,7 +32,7 @@ export type FilterGroupsContext = {
|
||||
loading: boolean;
|
||||
error?: Error;
|
||||
filterGroupStates: { [filterGroupId: string]: FilterGroupStates };
|
||||
filteredEntities: TemplateEntityV1alpha1[];
|
||||
filteredEntities: TemplateEntityV1beta2[];
|
||||
availableCategories: string[];
|
||||
isCatalogEmpty: boolean;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user