Skip to content

Commit

Permalink
Merge pull request #47 from thefrontside/pc/parse-task-label
Browse files Browse the repository at this point in the history
split task name into friendly name
  • Loading branch information
RichardW98 authored Mar 14, 2023
2 parents bc9d5e0 + 7e67e62 commit b71825d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion plugins/parodos/src/components/Form/Form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ describe('<Form />', () => {
it('can submit the multi-step form', async () => {
const onSubmit = jest.fn();

const { getByRole } = render(
const { getByRole, getByText } = render(
<Form formSchema={formSchema} onSubmit={onSubmit} />,
);

expect(getByText('Ad Group Work Flow Task')).toBeInTheDocument();

await fireEvent.change(getByRole('textbox', { name: 'api-server' }), {
target: { value: 'https://someurl.com' },
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export function FluidObjectFieldTemplate<
properties.length === 1 &&
uiSchema?.[properties[0].content.key as string]['ui:hidden'] === true;

const showTitle = uiSchema?.['ui:show-title'];
// TODO: reinstate when there is a task description
const showTitle = false; // uiSchema?.['ui:show-title'];

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import set from 'lodash.set';
import get from 'lodash.get';
import { type UiSchema } from '@rjsf/core';
import type { JsonObject } from '@backstage/types';
import { capitalize } from '../utils/string';

export function getJsonSchemaType(type: WorkFlowTaskParameterType) {
switch (type) {
Expand Down Expand Up @@ -93,7 +94,11 @@ export function jsonSchemaFromWorkflowDefinition(
for (const task of workflowDefinition.tasks) {
const schema: Record<string, any> = {
type: 'object',
title: task.name,
title: task.name
.replace(/([a-z])([A-Z])/g, '$1 $2')
.split(' ')
.map(capitalize)
.join(' '), // TODO: task label would be good here
properties: {},
required: [],
};
Expand Down
3 changes: 3 additions & 0 deletions plugins/parodos/src/utils/string.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function capitalize(text: string): string {
return `${text.charAt(0).toUpperCase()}${text.slice(1).toLowerCase()}`;
}

0 comments on commit b71825d

Please sign in to comment.