Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workspace startup page improvements #893

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/dashboard-frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ module.exports = {
'vscode-languageserver-protocol/lib/common/utils/is',
'vscode-languageserver-protocol/lib/main': 'vscode-languageserver-protocol/lib/node/main',
},
modulePathIgnorePatterns: [
'__mocks__/index.tsx',
],
globals: {
'ts-jest': {
tsconfig: 'tsconfig.test.json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ function getComponent(store: Store, localState?: Partial<State>): React.ReactEle
const component = (
<CommonStepCheckRunningWorkspacesLimit
distance={0}
hasChildren={false}
history={history}
matchParams={matchParams}
onNextStep={mockOnNextStep}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ class CommonStepCheckRunningWorkspacesLimit extends ProgressStep<Props, State> {
}

protected handleTimeout(redundantWorkspace: Workspace | undefined): void {
// eslint-disable-next-line no-debugger
debugger;
const message = redundantWorkspace
? `The workspace status remains "${redundantWorkspace.status}" in the last ${TIMEOUT_TO_STOP_SEC} seconds.`
: `Could not check running workspaces limit in the last ${TIMEOUT_TO_STOP_SEC} seconds.`;
Expand Down Expand Up @@ -310,7 +308,7 @@ class CommonStepCheckRunningWorkspacesLimit extends ProgressStep<Props, State> {
}

render(): React.ReactNode {
const { distance } = this.props;
const { distance, hasChildren } = this.props;
const { name, lastError } = this.state;

const redundantWorkspace = this.findRedundantWorkspace(this.props, this.state);
Expand All @@ -327,7 +325,12 @@ class CommonStepCheckRunningWorkspacesLimit extends ProgressStep<Props, State> {
onTimeout={() => this.handleTimeout(redundantWorkspace)}
/>
)}
<ProgressStepTitle distance={distance} isError={isError} isWarning={isWarning}>
<ProgressStepTitle
distance={distance}
hasChildren={hasChildren}
isError={isError}
isWarning={isWarning}
>
{name}
</ProgressStepTitle>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ function getComponent(
const component = (
<CreatingStepApplyDevfile
distance={0}
hasChildren={false}
searchParams={searchParams}
history={history}
onNextStep={mockOnNextStep}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export type State = ProgressStepState & {
};

class CreatingStepApplyDevfile extends ProgressStep<Props, State> {
protected readonly name = 'Applying devfile';
protected readonly name = 'Generating a DevWorkspace from the Devfile';

constructor(props: Props) {
super(props);
Expand Down Expand Up @@ -391,7 +391,7 @@ class CreatingStepApplyDevfile extends ProgressStep<Props, State> {
}

render(): React.ReactElement {
const { distance } = this.props;
const { distance, hasChildren } = this.props;
const { name, lastError, warning } = this.state;

const isActive = distance === 0;
Expand All @@ -403,7 +403,12 @@ class CreatingStepApplyDevfile extends ProgressStep<Props, State> {
{isActive && (
<TimeLimit timeLimitSec={TIMEOUT_TO_CREATE_SEC} onTimeout={() => this.handleTimeout()} />
)}
<ProgressStepTitle distance={distance} isError={isError} isWarning={isWarning}>
<ProgressStepTitle
distance={distance}
hasChildren={hasChildren}
isError={isError}
isWarning={isWarning}
>
{name}
</ProgressStepTitle>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ function getComponent(store: Store, searchParams: URLSearchParams): React.ReactE
const component = (
<CreatingStepApplyResources
distance={0}
hasChildren={false}
searchParams={searchParams}
history={history}
onNextStep={mockOnNextStep}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class CreatingStepApplyResources extends ProgressStep<Props, State> {
}

render(): React.ReactElement {
const { distance } = this.props;
const { distance, hasChildren } = this.props;
const { name, lastError, warning } = this.state;

const isActive = distance === 0;
Expand All @@ -266,7 +266,12 @@ class CreatingStepApplyResources extends ProgressStep<Props, State> {
{isActive && (
<TimeLimit timeLimitSec={TIMEOUT_TO_CREATE_SEC} onTimeout={() => this.handleTimeout()} />
)}
<ProgressStepTitle distance={distance} isError={isError} isWarning={isWarning}>
<ProgressStepTitle
distance={distance}
hasChildren={hasChildren}
isError={isError}
isWarning={isWarning}
>
{name}
</ProgressStepTitle>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ function getComponent(store: Store, searchParams: URLSearchParams): React.ReactE
const component = (
<CreatingStepCheckExistingWorkspaces
distance={0}
hasChildren={false}
searchParams={searchParams}
history={history}
onNextStep={mockOnNextStep}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type State = ProgressStepState & {
};

class CreatingStepCheckExistingWorkspaces extends ProgressStep<Props, State> {
protected readonly name = 'Checking existing workspaces';
protected readonly name = 'Checking if a workspace with the same name exists';

constructor(props: Props) {
super(props);
Expand Down Expand Up @@ -204,15 +204,20 @@ class CreatingStepCheckExistingWorkspaces extends ProgressStep<Props, State> {
}

render(): React.ReactElement {
const { distance } = this.props;
const { distance, hasChildren } = this.props;
const { name, lastError } = this.state;

const isError = lastError !== undefined;
const isWarning = false;

return (
<React.Fragment>
<ProgressStepTitle distance={distance} isError={isError} isWarning={isWarning}>
<ProgressStepTitle
distance={distance}
hasChildren={hasChildren}
isError={isError}
isWarning={isWarning}
>
{name}
</ProgressStepTitle>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function getComponent(store: Store, searchParams: URLSearchParams): React.ReactE
<Provider store={store}>
<CreateWorkspace
distance={0}
hasChildren={true}
history={history}
searchParams={searchParams}
onNextStep={mockOnNextStep}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,20 @@ export default class CreatingStepCreateWorkspace extends ProgressStep<Props, Sta
}

render(): React.ReactElement {
const { distance } = this.props;
const { distance, hasChildren } = this.props;
const { name } = this.state;

const isError = false;
const isWarning = false;

return (
<React.Fragment>
<ProgressStepTitle distance={distance} isError={isError} isWarning={isWarning}>
<ProgressStepTitle
distance={distance}
hasChildren={hasChildren}
isError={isError}
isWarning={isWarning}
>
{name}
</ProgressStepTitle>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ describe('Factory flow: step Fetch Devfile', () => {
},
converted: {
isConverted: false,
devfileV2: {} as devfileApi.Devfile,
devfileV2: {
metadata: {
name: 'my-project',
generateName: 'my-project-',
},
} as devfileApi.Devfile,
},
})
.build();
Expand All @@ -54,7 +59,7 @@ describe('Factory flow: step Fetch Devfile', () => {
store.getState().factoryResolver.converted!,
);

expect(newTitle).toEqual(`Devfile loaded from ${factoryUrl}.`);
expect(newTitle).toEqual('Devfile found with name "my-project".');
});

test('devfile not found', async () => {
Expand All @@ -67,7 +72,12 @@ describe('Factory flow: step Fetch Devfile', () => {
},
converted: {
isConverted: false,
devfileV2: {} as devfileApi.Devfile,
devfileV2: {
metadata: {
name: 'my-project',
generateName: 'my-project-',
},
} as devfileApi.Devfile,
},
})
.build();
Expand All @@ -94,7 +104,12 @@ describe('Factory flow: step Fetch Devfile', () => {
},
converted: {
isConverted: false,
devfileV2: {} as devfileApi.Devfile,
devfileV2: {
metadata: {
name: 'my-project',
generateName: 'my-project-',
},
} as devfileApi.Devfile,
},
})
.build();
Expand All @@ -106,7 +121,7 @@ describe('Factory flow: step Fetch Devfile', () => {
store.getState().factoryResolver.converted!,
);

expect(newTitle).toEqual(`Devfile found in repo ${factoryUrl} as 'devfile.yaml'.`);
expect(newTitle).toEqual('Devfile found with name "my-project".');
});

test('devfile converted', async () => {
Expand All @@ -121,6 +136,10 @@ describe('Factory flow: step Fetch Devfile', () => {
isConverted: true, // <-
devfileV2: {
schemaVersion: '2.1.0',
metadata: {
name: 'my-project',
generateName: 'my-project-',
},
} as devfileApi.Devfile,
},
})
Expand All @@ -134,7 +153,7 @@ describe('Factory flow: step Fetch Devfile', () => {
);

expect(newTitle).toEqual(
`Devfile found in repo ${factoryUrl} as 'devfile.yaml'. Devfile version 1 found, converting it to devfile version 2.`,
'Devfile found with name "my-project". Devfile version 1 found, converting it to devfile version 2.',
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ describe('Creating steps, fetching a devfile', () => {
location: factoryUrl,
},
converted: {
devfileV2: {} as devfileApi.Devfile,
devfileV2: {
metadata: {
name: 'my-project',
generateName: 'my-project-',
},
} as devfileApi.Devfile,
},
})
.build();
Expand Down Expand Up @@ -487,7 +492,12 @@ describe('Creating steps, fetching a devfile', () => {
location: factoryUrl,
},
converted: {
devfileV2: {} as devfileApi.Devfile,
devfileV2: {
metadata: {
name: 'my-project',
generateName: 'my-project-',
},
} as devfileApi.Devfile,
},
})
.build();
Expand Down Expand Up @@ -620,7 +630,12 @@ describe('Creating steps, fetching a devfile', () => {
location: factoryUrl,
},
converted: {
devfileV2: {} as devfileApi.Devfile,
devfileV2: {
metadata: {
name: 'my-project',
generateName: 'my-project-',
},
} as devfileApi.Devfile,
},
})
.build();
Expand Down Expand Up @@ -655,6 +670,7 @@ function getComponent(store: Store, searchParams: URLSearchParams): React.ReactE
<Provider store={store}>
<CreatingStepFetchDevfile
distance={0}
hasChildren={false}
history={history}
searchParams={searchParams}
onNextStep={mockOnNextStep}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ export function buildStepName(
// - repo: means no devfile is found and default is generated
// - any other - devfile is found in repository as filename from the value
const { source } = factoryResolver;
const { devfileV2 } = factoryResolverConverted;

const devfileName =
devfileV2.metadata.name !== undefined
? `name "${devfileV2.metadata.name}"`
: `generateName "${devfileV2.metadata.generateName}"`;
let newTitle = '';

if (!source) {
newTitle += `Devfile loaded from ${sourceUrl}.`;
newTitle += `Devfile found with ${devfileName}.`;
} else if (source === 'repo') {
newTitle = `Devfile could not be found in ${sourceUrl}. Applying the default configuration.`;
} else {
newTitle = `Devfile found in repo ${sourceUrl} as '${source}'.`;
newTitle = `Devfile found with ${devfileName}.`;
if (factoryResolverConverted.isConverted) {
newTitle += ` Devfile version 1 found, converting it to devfile version 2.`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,19 @@ export type State = ProgressStepState & {
};

class CreatingStepFetchDevfile extends ProgressStep<Props, State> {
protected readonly name = 'Looking for devfile';
protected readonly name = 'Inspecting repo';

constructor(props: Props) {
super(props);

const factoryParams = buildFactoryParams(props.searchParams);
const name = `Inspecting repo ${factoryParams.sourceUrl} for a devfile`;

this.state = {
factoryParams: buildFactoryParams(props.searchParams),
factoryParams,
shouldResolve: true,
useDefaultDevfile: false,
name: this.name,
name,
};
}

Expand Down Expand Up @@ -374,7 +377,7 @@ class CreatingStepFetchDevfile extends ProgressStep<Props, State> {
}

render(): React.ReactElement {
const { distance } = this.props;
const { distance, hasChildren } = this.props;
const { name, lastError } = this.state;

const isActive = distance === 0;
Expand All @@ -386,7 +389,12 @@ class CreatingStepFetchDevfile extends ProgressStep<Props, State> {
{isActive && (
<TimeLimit timeLimitSec={TIMEOUT_TO_RESOLVE_SEC} onTimeout={() => this.handleTimeout()} />
)}
<ProgressStepTitle distance={distance} isError={isError} isWarning={isWarning}>
<ProgressStepTitle
distance={distance}
hasChildren={hasChildren}
isError={isError}
isWarning={isWarning}
>
{name}
</ProgressStepTitle>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ function getComponent(store: Store, searchParams: URLSearchParams): React.ReactE
<Provider store={store}>
<CreatingStepFetchResources
distance={0}
hasChildren={false}
history={history}
searchParams={searchParams}
onNextStep={mockOnNextStep}
Expand Down
Loading