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

fix: Minor frontend fixes for T4C instance components #1881

Merged
merged 1 commit into from
Oct 7, 2024
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
1 change: 1 addition & 0 deletions backend/capellacollab/core/database/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ def create_t4c_instance_and_repositories(db):
host="localhost",
port=2036,
cdo_port=12036,
http_port=8080,
license_server=default_license_server,
rest_api="http://localhost:8081/api/v1.0",
username="admin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ <h2 class="text-xl font-medium">
</mat-form-field>
</fieldset>
<mat-form-field subscriptSizing="dynamic" appearance="fill">
<mat-label>Experimental REST API</mat-label>
<mat-label>REST API</mat-label>
<input matInput formControlName="rest_api" />
@if (form.controls.rest_api.errors?.required) {
<mat-error>The REST server URL is required.</mat-error>
<mat-error>The REST API server URL is required.</mat-error>
} @else if (form.controls.rest_api.errors?.pattern) {
<mat-error>The URL should start with "http(s)://"</mat-error>
}
Expand Down Expand Up @@ -207,7 +207,12 @@ <h2 class="text-xl font-medium">
(t4cInstanceWrapperService.t4cInstance$ | async) !== undefined
) {
@if (!isArchived) {
<button mat-flat-button color="primary" (click)="enableEditing()">
<button
mat-flat-button
color="primary"
(click)="enableEditing()"
data-testid="edit-button"
>
Edit
</button>
} @else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ export class EditT4CInstanceComponent implements OnInit, OnDestroy {
const t4cInstance = {
...initialT4CInstance,
password: '***********',
version_id: initialT4CInstance.version.id,
license_server_id: initialT4CInstance.license_server.id,
};
this.isArchived = t4cInstance.is_archived;
this.form.patchValue(t4cInstance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,40 @@
* SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors
* SPDX-License-Identifier: Apache-2.0
*/
import { ActivatedRoute } from '@angular/router';
import { Meta, StoryObj, moduleMetadata } from '@storybook/angular';
import { userEvent, within } from '@storybook/test';
import { T4CInstanceWrapperService } from 'src/app/services/settings/t4c-instance.service';
import { T4CLicenseServerWrapperService } from 'src/app/services/settings/t4c-license-server.service';
import { MockActivedRoute } from 'src/storybook/routes';
import {
MockT4CInstanceWrapperService,
MockT4CLicenseServerWrapperService,
mockT4CInstance,
mockT4CLicenseServer,
} from 'src/storybook/t4c';
import { mockToolVersion } from 'src/storybook/tool';
import { EditT4CInstanceComponent } from './edit-t4c-instance.component';

const meta: Meta<EditT4CInstanceComponent> = {
title: 'Settings Components/Modelsources/T4C/Server Instance',
component: EditT4CInstanceComponent,
args: {
capellaVersions: [mockToolVersion],
},
decorators: [
moduleMetadata({
providers: [
{
provide: T4CLicenseServerWrapperService,
useFactory: () =>
new MockT4CLicenseServerWrapperService(mockT4CLicenseServer, [
mockT4CLicenseServer,
]),
},
],
}),
],
};

export default meta;
Expand All @@ -26,7 +48,6 @@ export const AddInstance: Story = {
export const ExistingInstance: Story = {
args: {
existing: true,
capellaVersions: [mockToolVersion],
},
decorators: [
moduleMetadata({
Expand All @@ -38,17 +59,20 @@ export const ExistingInstance: Story = {
mockT4CInstance,
]),
},
{
provide: ActivatedRoute,
useFactory: () =>
new MockActivedRoute({
instance: -1,
}),
},
],
}),
],
};

export const EditExistingInstance: Story = {
args: {
existing: true,
editing: true,
capellaVersions: [mockToolVersion],
},
args: {},
decorators: [
moduleMetadata({
providers: [
Expand All @@ -59,16 +83,26 @@ export const EditExistingInstance: Story = {
mockT4CInstance,
]),
},
{
provide: ActivatedRoute,
useFactory: () =>
new MockActivedRoute({
instance: -1,
}),
},
],
}),
],
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const editButton = canvas.getByTestId('edit-button');
await userEvent.click(editButton);
},
};

export const ArchivedInstance: Story = {
args: {
existing: true,
isArchived: true,
capellaVersions: [mockToolVersion],
},
decorators: [
moduleMetadata({
Expand All @@ -80,6 +114,13 @@ export const ArchivedInstance: Story = {
mockT4CInstance,
]),
},
{
provide: ActivatedRoute,
useFactory: () =>
new MockActivedRoute({
instance: -1,
}),
},
],
}),
],
Expand Down
Loading