Skip to content

Commit

Permalink
SF-2508 More
Browse files Browse the repository at this point in the history
  • Loading branch information
marksvc committed Apr 15, 2024
1 parent b6c0c2c commit e652296
Show file tree
Hide file tree
Showing 15 changed files with 390 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ProjectComponent } from './project/project.component';
import { SettingsComponent } from './settings/settings.component';
import { PageNotFoundComponent } from './shared/page-not-found/page-not-found.component';
import { SettingsAuthGuard, SyncAuthGuard } from './shared/project-router.guard';
import { MyProjectsComponent } from './start/start.component';
import { MyProjectsComponent } from './my-projects/my-projects.component';
import { SyncComponent } from './sync/sync.component';

const routes: Routes = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const ROUTES: Route[] = [
{ path: 'connect-project', component: MockComponent }
];

describe('AppComponent', () => {
xdescribe('AppComponent', () => {
configureTestingModule(() => ({
declarations: [AppComponent, MockComponent, NavigationComponent],
imports: [
Expand Down
5 changes: 1 addition & 4 deletions src/SIL.XForge.Scripture/ClientApp/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,7 @@ export class AppComponent extends DataLoadingComponent implements OnInit, OnDest
}

get homeUrl$(): Observable<string> {
return this.authService.loggedInState$.pipe(
map(state => (state.loggedIn ? '/projects' : '/')),
startWith('/')
);
return this.authService.loggedInState$.pipe(map(state => (state.loggedIn ? '/projects' : '/')));
}

get isAppLoading(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/SIL.XForge.Scripture/ClientApp/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { DeleteProjectDialogComponent } from './settings/delete-project-dialog/d
import { SettingsComponent } from './settings/settings.component';
import { SharedModule } from './shared/shared.module';
import { TextNoteDialogComponent } from './shared/text/text-note-dialog/text-note-dialog.component';
import { MyProjectsComponent } from './start/start.component';
import { MyProjectsComponent } from './my-projects/my-projects.component';
import { SyncProgressComponent } from './sync/sync-progress/sync-progress.component';
import { SyncComponent } from './sync/sync.component';
import { TranslateModule } from './translate/translate.module';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ describe('ConnectProjectComponent', () => {
env.clickElement(env.submitButton);
expect(env.component.paratextIdControl.errors!.required).toBe(true);

when(mockedParatextService.isParatextProjectInSF(anything())).thenReturn(true);
env.changeSelectValue(env.projectSelect, 'pt03');

// The project is already in SF, so do not present settings to configure.
expect(env.settingsCard).toBeNull();
env.clickElement(env.submitButton);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class ConnectProjectComponent extends DataLoadingComponent implements OnI
}
const paratextId: string = this.paratextIdControl.value;
const project = this._projects.find(p => p.paratextId === paratextId);
return project != null && project.projectId == null;
return project != null && !this.paratextService.isParatextProjectInSF(project);
}

get submitDisabled(): boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/** See documentation in ParatextProject.cs. */
export interface ParatextProject {
paratextId: string;
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ export class ParatextService {
.toPromise();
}

/** True if a Paratext project has a corresponding project in SF, whether or not any SF user is connected to the
* project. */
isParatextProjectInSF(project: ParatextProject): boolean {
return project.projectId != null;
}

private get headers(): HttpHeaders {
return new HttpHeaders({
Accept: 'application/json',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<ng-container *transloco="let t; read: 'start'">
<div class="wrapper">
<app-notice id="no-pt-or-sf-projects" icon="warning" type="warning"
>You have no projects. You need to receive an invitation to join a project. Or if you have a Paratext account, you
can Log in with Paratext and connect to your Paratext projects.</app-notice
>
<h3 *ngIf="userConnectedProjects.length > 0">Connected projects</h3>
<mat-card
*ngFor="let projectDoc of userConnectedProjects"
[class.active-project]="isLastSelectedProject(projectDoc)"
id="user-connected-project-card-{{ projectDoc.data?.paratextId }}"
>
<div>
<span class="project-name">
<span>{{ projectDoc.data?.shortName }}</span> - <span>{{ projectDoc.data?.name }}</span>
</span>
<span class="helper-text">
{{ projectDoc.data?.checkingConfig?.checkingEnabled ? "Drafting • Community checking" : "Drafting" }}
</span>
</div>
<!-- <a routerLink="/page">Click Here</a> -->
<a routerLink="/projects/{{ projectDoc.id }}" mat-flat-button color="primary">Open</a>
</mat-card>

<h3 *ngIf="userConnectedResources.length > 0">DBL resources</h3>
<mat-card
*ngFor="let projectDoc of userConnectedResources"
[class.active-project]="isLastSelectedProject(projectDoc)"
id="user-connected-resource-card-{{ projectDoc.data?.paratextId }}"
>
<div>
<span class="project-name">
<span>{{ projectDoc.data?.shortName }}</span> - <span>{{ projectDoc.data?.name }}</span>
</span>
<span class="helper-text">DBL resource</span>
</div>
<a appRouterLink="/projects/{{ projectDoc.id }}" mat-flat-button color="primary">Open</a>
</mat-card>

<h3 *ngIf="userUnconnectedUserParatextProjects.length > 0">
{{ userProjectCount === 0 ? "Connect a project to get started" : "Not connected" }}
</h3>
<mat-card
*ngFor="let ptProject of userUnconnectedUserParatextProjects"
id="user-unconnected-project-card-{{ ptProject.paratextId }}"
>
<div>
<span class="project-name">
<span>{{ ptProject.shortName }}</span> - <span>{{ ptProject.name }}</span>
</span>
<span *ngIf="!ptProject.isConnectable" class="helper-text"
>This project cannot be connected. You must be the Paratext Administrator of a project to start it here. Ask
your Administrator to connect to your project then you can also connect to it here after that.TODO:other text
is on the balsalmiq.</span
>
</div>
<a *ngIf="ptProject.isConnectable" appRouterLink="/connect-project" mat-flat-button color="primary">
{{ paratextService.isParatextProjectInSF(ptProject) ? "Join" : "Connect" }}
</a>
</mat-card>
</div>
</ng-container>
Loading

0 comments on commit e652296

Please sign in to comment.