Skip to content

Commit

Permalink
Resolved conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
ronitjadhav committed May 6, 2024
2 parents 479a656 + 2b8cc03 commit dbdf6b7
Show file tree
Hide file tree
Showing 43 changed files with 625 additions and 132 deletions.
8 changes: 5 additions & 3 deletions apps/datahub-e2e/src/e2e/datasetDetailPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,14 +641,16 @@ describe('api form', () => {
cy.get('@secondInput').clear()
cy.get('@secondInput').type('87')

cy.get('@apiForm').find('gn-ui-dropdown-selector').click()
cy.get('button[data-cy-value="csv"]').click()
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(3000)
cy.get('@apiForm').find('gn-ui-dropdown-selector').as('dropdown')
cy.get('@dropdown').eq(0).selectDropdownOption('geojson')

cy.get('@apiForm')
.find('gn-ui-copy-text-button')
.find('input')
.invoke('val')
.should('include', 'offset=87&limit=54&f=csv')
.should('include', 'offset=87&limit=54&f=geojson')

cy.get('@apiForm').children('div').first().find('button').first().click()

Expand Down
4 changes: 3 additions & 1 deletion docs/guide/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ Then run the following script with the appropriate options:
node tools/pipelines/register-es-pipelines.js register --host=http://localhost:9090
```

The `--host` option is used to point to the ElasticSearch instance. Additionally, the `--records-index` option can be used if the index containing the metadata records is not called `gn-records`.
The `--host` option is used to point to the ElasticSearch instance.
If ElasticSearch is secured, `--username` and `--password` can be used to pass HTTP Authentication.
Additionally, the `--records-index` option can be used if the index containing the metadata records is not called `gn-records`.

### Option B: Running a docker image

Expand Down
4 changes: 2 additions & 2 deletions libs/common/fixtures/src/lib/records.fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export const DATASET_RECORDS: DatasetRecord[] = deepFreeze([
status: 'ongoing',
recordCreated: new Date('2022-02-01T15:12:00'),
recordUpdated: new Date('2022-02-01T15:12:00'),
datasetCreated: new Date('2022-09-01T14:18:19'),
datasetUpdated: new Date('2022-12-04T15:12:00'),
resourceCreated: new Date('2022-09-01T14:18:19'),
resourceUpdated: new Date('2022-12-04T15:12:00'),
title: 'A very interesting dataset (un jeu de données très intéressant)',
abstract: `# Introduction
This dataset has been established for testing purposes.
Expand Down
8 changes: 8 additions & 0 deletions libs/feature/editor/src/lib/+state/editor.selectors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ describe('Editor Selectors', () => {
config: DEFAULT_FIELDS[3],
value: DATASET_RECORDS[0].recordUpdated,
},
{
config: DEFAULT_FIELDS[4],
value: DATASET_RECORDS[0].licenses,
},
{
config: DEFAULT_FIELDS[5],
value: DATASET_RECORDS[0].resourceUpdated,
},
])
})
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<gn-ui-dropdown-selector
[title]="label"
[showTitle]="false"
[choices]="choices"
[selected]="selected"
(selectValue)="onSelectValue($event)"
>
</gn-ui-dropdown-selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'

import { FormFieldLicenseComponent } from './form-field-license.component'
import { FormControl } from '@angular/forms'
import { TranslateModule } from '@ngx-translate/core'

describe('FormFieldLicenseComponent', () => {
let component: FormFieldLicenseComponent
let fixture: ComponentFixture<FormFieldLicenseComponent>

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [FormFieldLicenseComponent, TranslateModule.forRoot()],
}).compileComponents()

fixture = TestBed.createComponent(FormFieldLicenseComponent)
component = fixture.componentInstance
const control = new FormControl()
control.setValue([{ text: 'cc-by' }])
component.control = control
component.label = 'License'
fixture.detectChanges()
})

it('should create', () => {
expect(component).toBeTruthy()
})
describe('#selected', () => {
it('should get the selected value', () => {
expect(component.selected).toBe('cc-by')
})
})
describe('#onSelectValue', () => {
it('should set the selected value', () => {
component.onSelectValue('cc-by-sa')
expect(component.control.value).toEqual([{ text: 'cc-by-sa' }])
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
import { FormControl } from '@angular/forms'
import { marker } from '@biesbjerg/ngx-translate-extract-marker'
import { DropdownSelectorComponent } from '@geonetwork-ui/ui/inputs'

@Component({
selector: 'gn-ui-form-field-license',
templateUrl: './form-field-license.component.html',
styleUrls: ['./form-field-license.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [DropdownSelectorComponent],
})
export class FormFieldLicenseComponent {
@Input() control!: FormControl
@Input() label: string

get selected() {
return this.control.value[0]?.text
}

onSelectValue(value: unknown) {
this.control.setValue([{ text: value }])
}

choices = [
{
value: 'cc-by',
label: marker('editor.record.form.license.cc-by'),
},
{
value: 'cc-by-sa',
label: marker('editor.record.form.license.cc-by-sa'),
},
{
value: 'cc-zero',
label: marker('editor.record.form.license.cc-zero'),
},
{
value: 'etalab',
label: marker('editor.record.form.license.etalab'),
},
{
value: 'etalab-v2',
label: marker('editor.record.form.license.etalab-v2'),
},
{
value: 'odbl',
label: marker('editor.record.form.license.odbl'),
},
{
value: 'odc-by',
label: marker('editor.record.form.license.odc-by'),
},
{
value: 'pddl',
label: marker('editor.record.form.license.pddl'),
},
{
value: 'unknown',
label: marker('editor.record.form.license.unknown'),
},
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<gn-ui-date-picker
[date]="control.value"
(dateChange)="control.setValue($event)"
></gn-ui-date-picker>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { FormControl } from '@angular/forms'
import { FormFieldResourceUpdatedComponent } from './form-field-resource-updated.component'

describe('FormFieldResourceUpdatedComponent', () => {
let component: FormFieldResourceUpdatedComponent
let fixture: ComponentFixture<FormFieldResourceUpdatedComponent>

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [FormFieldResourceUpdatedComponent],
}).compileComponents()

fixture = TestBed.createComponent(FormFieldResourceUpdatedComponent)
component = fixture.componentInstance
const control = new FormControl()
control.setValue(new Date())
component.control = control
fixture.detectChanges()
})

it('should create', () => {
expect(component).toBeTruthy()
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
import { FormControl } from '@angular/forms'
import { DatePickerComponent } from '@geonetwork-ui/ui/inputs'

@Component({
selector: 'gn-ui-form-field-resource-updated',
templateUrl: './form-field-resource-updated.component.html',
styleUrls: ['./form-field-resource-updated.component.css'],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [DatePickerComponent],
})
export class FormFieldResourceUpdatedComponent {
@Input() control!: FormControl
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
<div class="flex flex-col h-full">
<div class="mb-2 flex flex-row">
<label class="grow">
<span class="font-medium field-label">{{
config.labelKey | translate
}}</span>
<span *ngIf="config.hintKey" class="text-gray-900 text-sm">
- {{ config.hintKey | translate }}
</span>
</label>
<mat-icon
*ngIf="isFieldOk"
class="material-symbols-outlined text-[#c6d950] icon-ok"
>check_circle</mat-icon
>
<mat-icon
*ngIf="isFieldLocked"
class="material-symbols-outlined text-blue-400 icon-locked"
>lock</mat-icon
>
<mat-icon
*ngIf="isFieldInvalid"
class="material-symbols-outlined text-pink-500 icon-invalid"
>cancel</mat-icon
<ng-container *ngIf="withoutWrapper; else withGenericWrapper">
<ng-container *ngTemplateOutlet="fieldContent"></ng-container>
</ng-container>
<ng-template #withGenericWrapper>
<gn-ui-form-field-wrapper
[label]="config.labelKey | translate"
[hint]="config.hintKey | translate"
>
</div>
<ng-container *ngTemplateOutlet="fieldContent"></ng-container>
</gn-ui-form-field-wrapper>
</ng-template>
</div>

<ng-template #fieldContent>
<ng-container *ngIf="isTitle">
<div class="flex justify-between items-center gap-3">
<h2
Expand All @@ -48,6 +37,25 @@
</span>
</div>
</ng-container>
<ng-container *ngIf="isAbstract">
<gn-ui-form-field-rich
class="h-[8rem]"
[control]="formControl"
[label]="config.labelKey | translate"
[hint]="config.hintKey | translate"
></gn-ui-form-field-rich>
</ng-container>
<ng-container *ngIf="isLicenses">
<gn-ui-form-field-license
[control]="formControl"
[label]="config.labelKey | translate"
></gn-ui-form-field-license>
</ng-container>
<ng-container *ngIf="isResourceUpdated">
<gn-ui-form-field-resource-updated
[control]="formControl"
></gn-ui-form-field-resource-updated>
</ng-container>
<ng-container *ngIf="isSimpleField">
<gn-ui-form-field-simple
[type]="simpleType"
Expand All @@ -63,14 +71,6 @@
[invalid]="isFieldInvalid"
></gn-ui-form-field-file>
</ng-container>
<ng-container *ngIf="isAbstract">
<gn-ui-form-field-rich
class="h-[8rem]"
[control]="formControl"
[label]="config.labelKey | translate"
[hint]="config.hintKey | translate"
></gn-ui-form-field-rich>
</ng-container>
<ng-container *ngIf="isArrayField">
<gn-ui-form-field-array></gn-ui-form-field-array>
</ng-container>
Expand All @@ -89,4 +89,4 @@
>
{{ config.invalidHintKey | translate }}
</div>
</div>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { FormFieldSimpleComponent } from './form-field-simple/form-field-simple.
import { FormFieldSpatialExtentComponent } from './form-field-spatial-extent/form-field-spatial-extent.component'
import { FormFieldTemporalExtentComponent } from './form-field-temporal-extent/form-field-temporal-extent.component'
import { FormFieldComponent } from './form-field.component'
import { FormFieldWrapperComponent } from '@geonetwork-ui/ui/layout'
import { EditableLabelDirective } from '@geonetwork-ui/ui/inputs'

describe('FormFieldComponent', () => {
let component: FormFieldComponent
Expand All @@ -32,12 +34,30 @@ describe('FormFieldComponent', () => {
expect(component).toBeTruthy()
})

describe('abstract field', () => {
let formField
beforeEach(() => {
component.model = 'abstract'
component.value = 'Some rich abstract value'
fixture.detectChanges()
formField = fixture.debugElement.query(
By.directive(FormFieldRichComponent)
).componentInstance
})
it('creates a rich text form field', () => {
expect(formField).toBeTruthy()
})
})
describe('simple field', () => {
let fieldWrapper
let formField
beforeEach(async () => {
component.config.type = 'url'
fixture.detectChanges()
await fixture.whenStable()
fieldWrapper = fixture.debugElement.query(
By.directive(FormFieldWrapperComponent)
).componentInstance
formField = fixture.debugElement.query(
By.directive(FormFieldSimpleComponent)
).componentInstance
Expand All @@ -48,13 +68,8 @@ describe('FormFieldComponent', () => {
expect(formField.readonly).toEqual(component.config.locked)
expect(formField.invalid).toEqual(component.config.invalid)
})
it('shows the label', () => {
const label = fixture.debugElement.query(By.css('.field-label'))
expect(label.nativeElement.textContent).toEqual(component.config.labelKey)
})
it('shows the ok icon', () => {
const icon = fixture.debugElement.query(By.css('.icon-ok'))
expect(icon).toBeTruthy()
it('creates a form field wrapper', () => {
expect(fieldWrapper).toBeTruthy()
})
})
describe('simple field (invalid)', () => {
Expand All @@ -74,10 +89,6 @@ describe('FormFieldComponent', () => {
expect(formField.type).toEqual(component.config.type)
expect(formField.invalid).toEqual(true)
})
it('shows the invalid icon', () => {
const icon = fixture.debugElement.query(By.css('.icon-invalid'))
expect(icon).toBeTruthy()
})
it('shows the invalid hint key', () => {
const hint = fixture.debugElement.query(By.css('.field-invalid-hint'))
expect(hint.nativeElement.textContent).toContain(
Expand All @@ -103,24 +114,6 @@ describe('FormFieldComponent', () => {
expect(formField.readonly).toEqual(true)
expect(formField.invalid).toEqual(false)
})
it('shows the locked icon', () => {
const icon = fixture.debugElement.query(By.css('.icon-locked'))
expect(icon).toBeTruthy()
})
})
describe('abstract field', () => {
let formField
beforeEach(() => {
component.model = 'abstract'
component.value = 'Some rich abstract value'
fixture.detectChanges()
formField = fixture.debugElement.query(
By.directive(FormFieldRichComponent)
).componentInstance
})
it('creates a rich text form field', () => {
expect(formField).toBeTruthy()
})
})
describe('file field', () => {
let formField
Expand Down
Loading

0 comments on commit dbdf6b7

Please sign in to comment.