diff --git a/site/gatsby-site/cypress/e2e/integration/entityEdit.cy.js b/site/gatsby-site/cypress/e2e/integration/entityEdit.cy.js deleted file mode 100644 index 08ae036394..0000000000 --- a/site/gatsby-site/cypress/e2e/integration/entityEdit.cy.js +++ /dev/null @@ -1,122 +0,0 @@ -import { conditionalIt } from '../../support/utils'; -import entity from '../../fixtures/entities/entity.json'; -import updateOneEntity from '../../fixtures/entities/updateOneEntity.json'; - -describe('Edit Entity', () => { - const entity_id = 'google'; - - const url = `/entities/edit?entity_id=${entity_id}`; - - conditionalIt( - !Cypress.env('isEmptyEnvironment') && Cypress.env('e2eUsername') && Cypress.env('e2ePassword'), - 'Should successfully edit Entity fields', - () => { - cy.login(Cypress.env('e2eUsername'), Cypress.env('e2ePassword')); - - cy.visit(url); - - cy.conditionalIntercept( - '**/graphql', - (req) => req.body.operationName == 'FindEntity', - 'FindEntity', - entity - ); - - cy.wait(['@FindEntity']); - - const values = { - name: 'Google new', - }; - - Object.keys(values).forEach((key) => { - cy.get(`[name=${key}]`).clear().type(values[key]); - }); - - cy.conditionalIntercept( - '**/graphql', - (req) => req.body.operationName == 'UpdateEntity', - 'UpdateEntity', - updateOneEntity - ); - - const now = new Date(); - - cy.clock(now); - - cy.contains('button', 'Save').click(); - - const updatedEntity = { - name: values.name, - date_modified: now.toISOString(), - }; - - cy.wait('@UpdateEntity').then((xhr) => { - expect(xhr.request.body.operationName).to.eq('UpdateEntity'); - expect(xhr.request.body.variables.query.entity_id).to.eq(entity_id); - expect(xhr.request.body.variables.set).to.deep.eq(updatedEntity); - }); - - cy.get('.tw-toast').contains('Entity updated successfully.').should('exist'); - } - ); - - conditionalIt( - !Cypress.env('isEmptyEnvironment') && Cypress.env('e2eUsername') && Cypress.env('e2ePassword'), - 'Should display an error message when editing Entity fails', - () => { - cy.login(Cypress.env('e2eUsername'), Cypress.env('e2ePassword')); - - cy.visit(url); - - cy.conditionalIntercept( - '**/graphql', - (req) => req.body.operationName == 'FindEntity', - 'FindEntity', - entity - ); - - cy.wait(['@FindEntity']); - - const values = { - name: 'Google new', - }; - - Object.keys(values).forEach((key) => { - cy.get(`[name=${key}]`).clear().type(values[key]); - }); - - cy.conditionalIntercept( - '**/graphql', - (req) => req.body.operationName == 'UpdateEntity', - 'UpdateEntity', - { - data: null, - errors: [ - { - message: 'Dummy error message', - }, - ], - } - ); - - const now = new Date(); - - cy.clock(now); - - cy.contains('button', 'Save').click(); - - const updatedEntity = { - name: values.name, - date_modified: now.toISOString(), - }; - - cy.wait('@UpdateEntity').then((xhr) => { - expect(xhr.request.body.operationName).to.eq('UpdateEntity'); - expect(xhr.request.body.variables.query.entity_id).to.eq(entity_id); - expect(xhr.request.body.variables.set).to.deep.eq(updatedEntity); - }); - - cy.get('.tw-toast').contains('Error updating Entity.').should('exist'); - } - ); -}); diff --git a/site/gatsby-site/cypress/fixtures/entities/entity.json b/site/gatsby-site/cypress/fixtures/entities/entity.json deleted file mode 100644 index bf937d338e..0000000000 --- a/site/gatsby-site/cypress/fixtures/entities/entity.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "data": { - "entity": { - "entity_id": "google", - "name": "Google", - "created_at": "2024-03-01T21:52:39.877Z", - "date_modified": "2024-03-21T21:52:39.877Z" - } - } -} diff --git a/site/gatsby-site/cypress/fixtures/entities/updateOneEntity.json b/site/gatsby-site/cypress/fixtures/entities/updateOneEntity.json deleted file mode 100644 index be791e188b..0000000000 --- a/site/gatsby-site/cypress/fixtures/entities/updateOneEntity.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "data": { - "updateOneEntity": { - "entity_id": "google" - } - } -} diff --git a/site/gatsby-site/gatsby-config.js b/site/gatsby-site/gatsby-config.js index 2b9c669233..d3ac502d00 100755 --- a/site/gatsby-site/gatsby-config.js +++ b/site/gatsby-site/gatsby-config.js @@ -32,7 +32,6 @@ const plugins = [ resolve: 'gatsby-remark-images', options: { maxWidth: 1035, - sizeByPixelDensity: true, }, }, { diff --git a/site/gatsby-site/playwright/e2e-full/entityEdit.spec.ts b/site/gatsby-site/playwright/e2e-full/entityEdit.spec.ts new file mode 100644 index 0000000000..251f71aa8f --- /dev/null +++ b/site/gatsby-site/playwright/e2e-full/entityEdit.spec.ts @@ -0,0 +1,106 @@ +import { conditionalIntercept, waitForRequest, test, query } from '../utils'; +import entities from '../seeds/aiidprod/entities'; +import { expect } from '@playwright/test'; +import { init } from '../memory-mongo'; +import gql from 'graphql-tag'; + +test.describe('Edit Entity', () => { + const entity_id = 'entity1'; + const url = `/entities/edit?entity_id=${entity_id}`; + + function isDateApproximatelyEqual(expectedDate, actualDate, toleranceInSeconds = 5) { + const expectedTime = new Date(expectedDate).getTime(); + const actualTime = new Date(actualDate).getTime(); + return Math.abs(expectedTime - actualTime) <= toleranceInSeconds * 1000; + } + + test('Should successfully edit Entity fields', async ({ page, login, skipOnEmptyEnvironment }) => { + + const userId = await login(process.env.E2E_ADMIN_USERNAME, process.env.E2E_ADMIN_PASSWORD); + + await init({ customData: { users: [{ userId, first_name: 'Test', last_name: 'User', roles: ['admin'] }] }, }, { drop: true }); + + await page.goto(url); + + const values = { + name: 'Google new', + }; + + for (const key in values) { + await page.locator(`[name=${key}]`).fill(values[key]); + } + + await page.getByText("Save", { exact: true }).click(); + + const now = new Date(); + + await page.addInitScript(() => { + Date.now = () => now.getTime(); + }); + + await expect(page.locator('.tw-toast')).toContainText('Entity updated successfully.'); + + const { data } = await query({ + query: gql`{ + entity(filter: { entity_id: { EQ: "${entity_id}" } }) { + entity_id + name + created_at + date_modified + } + }`, + }); + + expect(data.entity).toMatchObject({ + entity_id, + created_at: entities[0].created_at, + name: values.name, + }); + + expect(isDateApproximatelyEqual(data.entity.date_modified, now.toISOString())).toBe(true); + + await expect(page.locator('.tw-toast')).toContainText('Entity updated successfully.'); + }); + + + test('Should display an error message when editing Entity fails', + async ({ page, login, skipOnEmptyEnvironment }) => { + const userId = await login(process.env.E2E_ADMIN_USERNAME, process.env.E2E_ADMIN_PASSWORD); + + await init({ customData: { users: [{ userId, first_name: 'Test', last_name: 'User', roles: ['admin'] }] }, }, { drop: true }); + + await page.goto(url); + + const values = { + name: 'Google new', + }; + + for (const key in values) { + await page.locator(`[name=${key}]`).fill(values[key]); + } + + await conditionalIntercept( + page, + '**/graphql', + (req) => req.postDataJSON().operationName === 'UpdateEntity', + { + data: null, + errors: [ + { + message: 'Dummy error message', + }, + ], + }, + 'UpdateEntity' + ); + + await page.getByText("Save", { exact: true }).click(); + + const updateEntityRequest = await waitForRequest('UpdateEntity'); + expect(updateEntityRequest.postDataJSON().variables.filter.entity_id.EQ).toBe(entity_id); + expect(updateEntityRequest.postDataJSON().variables.update.set.name).toBe(values.name); + + await expect(page.locator('.tw-toast')).toContainText('Error updating Entity.'); + } + ); +}); diff --git a/site/gatsby-site/playwright/seeds/aiidprod/entities.ts b/site/gatsby-site/playwright/seeds/aiidprod/entities.ts index bef894b364..c63ddbffef 100644 --- a/site/gatsby-site/playwright/seeds/aiidprod/entities.ts +++ b/site/gatsby-site/playwright/seeds/aiidprod/entities.ts @@ -6,36 +6,42 @@ const entities: DBEntity[] = [ { entity_id: 'entity1', name: 'Entity 1', - created_at: new Date(1609459200000).toString(), + created_at: new Date(1609459200000).toISOString(), + date_modified: new Date(1609459200000).toISOString(), }, { entity_id: 'entity2', name: 'Entity 2', - created_at: new Date(1609459200000).toString(), + created_at: new Date(1609459200000).toISOString(), + date_modified: new Date(1609459200000).toISOString(), }, { entity_id: 'entity3', name: 'Entity 3', - created_at: new Date(1609459200000).toString(), + created_at: new Date(1609459200000).toISOString(), + date_modified: new Date(1609459200000).toISOString(), }, { entity_id: 'starbucks', name: 'Starbucks', - created_at: new Date(1609459200000).toString(), + created_at: new Date(1609459200000).toISOString(), + date_modified: new Date(1609459200000).toISOString(), }, { entity_id: 'kronos', name: 'Kronos', - created_at: new Date(1609459200000).toString(), + created_at: new Date(1609459200000).toISOString(), + date_modified: new Date(1609459200000).toISOString(), }, { entity_id: 'starbucks-employees', name: 'Starbucks Employees', - created_at: new Date(1609459200000).toString(), + created_at: new Date(1609459200000).toISOString(), + date_modified: new Date(1609459200000).toISOString(), }, ] diff --git a/site/gatsby-site/server/generated/gql.ts b/site/gatsby-site/server/generated/gql.ts index ff87243211..0002fb7b8b 100644 --- a/site/gatsby-site/server/generated/gql.ts +++ b/site/gatsby-site/server/generated/gql.ts @@ -18,7 +18,7 @@ const documents = { "\n mutation InsertDuplicate($duplicate: DuplicateInsertInput!) {\n insertOneDuplicate(data: $duplicate) {\n duplicate_incident_number\n true_incident_number\n }\n }\n": types.InsertDuplicateDocument, "\n mutation UpsertEntity($filter: EntityFilterType!, $update: EntityInsertType!) {\n upsertOneEntity(filter: $filter, update: $update) {\n entity_id\n name\n }\n }\n": types.UpsertEntityDocument, "\n query FindEntities {\n entities {\n entity_id\n name\n }\n }\n": types.FindEntitiesDocument, - "\n query FindEntity($filter: EntityFilterType) {\n entity(filter: $filter) {\n entity_id\n name\n created_at\n }\n }\n": types.FindEntityDocument, + "\n query FindEntity($filter: EntityFilterType) {\n entity(filter: $filter) {\n entity_id\n name\n created_at\n date_modified\n }\n }\n": types.FindEntityDocument, "\n mutation UpdateEntity($filter: EntityFilterType!, $update: EntityUpdateType!) {\n updateOneEntity(filter: $filter, update: $update) {\n entity_id\n }\n }\n": types.UpdateEntityDocument, "\n query FindIncident($filter: IncidentFilterType) {\n incident(filter: $filter) {\n incident_id\n title\n description\n editors {\n userId\n first_name\n last_name\n }\n date\n AllegedDeployerOfAISystem {\n entity_id\n name\n }\n AllegedDeveloperOfAISystem {\n entity_id\n name\n }\n AllegedHarmedOrNearlyHarmedParties {\n entity_id\n name\n }\n nlp_similar_incidents {\n incident_id\n similarity\n }\n editor_similar_incidents\n editor_dissimilar_incidents\n flagged_dissimilar_incidents\n reports {\n report_number\n }\n embedding {\n from_reports\n vector\n }\n editor_notes\n }\n }\n": types.FindIncidentDocument, "\n query FindIncidentsTable($filter: IncidentFilterType) {\n incidents(filter: $filter) {\n incident_id\n title\n description\n editors {\n userId\n first_name\n last_name\n }\n date\n AllegedDeployerOfAISystem {\n entity_id\n name\n }\n AllegedDeveloperOfAISystem {\n entity_id\n name\n }\n AllegedHarmedOrNearlyHarmedParties {\n entity_id\n name\n }\n reports {\n report_number\n }\n }\n }\n": types.FindIncidentsTableDocument, @@ -108,7 +108,7 @@ export function gql(source: "\n query FindEntities {\n entities {\n ent /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function gql(source: "\n query FindEntity($filter: EntityFilterType) {\n entity(filter: $filter) {\n entity_id\n name\n created_at\n }\n }\n"): (typeof documents)["\n query FindEntity($filter: EntityFilterType) {\n entity(filter: $filter) {\n entity_id\n name\n created_at\n }\n }\n"]; +export function gql(source: "\n query FindEntity($filter: EntityFilterType) {\n entity(filter: $filter) {\n entity_id\n name\n created_at\n date_modified\n }\n }\n"): (typeof documents)["\n query FindEntity($filter: EntityFilterType) {\n entity(filter: $filter) {\n entity_id\n name\n created_at\n date_modified\n }\n }\n"]; /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/site/gatsby-site/server/generated/graphql.ts b/site/gatsby-site/server/generated/graphql.ts index e665091a4c..a283badbcb 100644 --- a/site/gatsby-site/server/generated/graphql.ts +++ b/site/gatsby-site/server/generated/graphql.ts @@ -943,8 +943,10 @@ export type CreateVariantInputVariant = { export type CreateVariantPayload = { __typename?: 'CreateVariantPayload'; - incident_id?: Maybe; - report_number?: Maybe; + /** The unique identifier for the incident. */ + incident_id: Scalars['Int']['output']; + /** The unique report number associated with the incident. */ + report_number: Scalars['Int']['output']; }; /** Filter type for DateTime scalar */ @@ -1133,6 +1135,7 @@ export type EntityFilterType = { OR?: InputMaybe>>; _id?: InputMaybe; created_at?: InputMaybe; + date_modified?: InputMaybe; entity_id?: InputMaybe; name?: InputMaybe; }; @@ -1140,6 +1143,7 @@ export type EntityFilterType = { export type EntityInsertType = { _id?: InputMaybe; created_at?: InputMaybe; + date_modified?: InputMaybe; entity_id: Scalars['String']['input']; name: Scalars['String']['input']; }; @@ -1147,6 +1151,7 @@ export type EntityInsertType = { export type EntitySetType = { _id?: InputMaybe; created_at?: InputMaybe; + date_modified?: InputMaybe; entity_id?: InputMaybe; name?: InputMaybe; }; @@ -1167,6 +1172,7 @@ export enum EntitySortByInput { export type EntitySortType = { _id?: InputMaybe; created_at?: InputMaybe; + date_modified?: InputMaybe; entity_id?: InputMaybe; name?: InputMaybe; }; @@ -3891,12 +3897,6 @@ export type ReportSortType = { url?: InputMaybe; }; -export type ReportTranslation = { - __typename?: 'ReportTranslation'; - text?: Maybe; - title?: Maybe; -}; - export type ReportTranslations = { __typename?: 'ReportTranslations'; text?: Maybe; @@ -5038,9 +5038,9 @@ export type User = { export type UserAdminDatum = { __typename?: 'UserAdminDatum'; - creationDate?: Maybe; - disabled?: Maybe; - email?: Maybe; + creationDate: Scalars['DateTime']['output']; + disabled: Scalars['Boolean']['output']; + email: Scalars['String']['output']; lastAuthenticationDate?: Maybe; }; @@ -5125,7 +5125,7 @@ export type FindEntityQueryVariables = Exact<{ }>; -export type FindEntityQuery = { __typename?: 'Query', entity?: { __typename?: 'Entity', entity_id: string, name: string, created_at?: any | null } | null }; +export type FindEntityQuery = { __typename?: 'Query', entity?: { __typename?: 'Entity', entity_id: string, name: string, created_at?: any | null, date_modified?: any | null } | null }; export type UpdateEntityMutationVariables = Exact<{ filter: EntityFilterType; @@ -5415,7 +5415,7 @@ export type FindUserQueryVariables = Exact<{ }>; -export type FindUserQuery = { __typename?: 'Query', user?: { __typename?: 'User', roles: Array, userId: string, first_name?: string | null, last_name?: string | null, adminData?: { __typename?: 'UserAdminDatum', email?: string | null, disabled?: boolean | null, creationDate?: any | null, lastAuthenticationDate?: any | null } | null } | null }; +export type FindUserQuery = { __typename?: 'Query', user?: { __typename?: 'User', roles: Array, userId: string, first_name?: string | null, last_name?: string | null, adminData?: { __typename?: 'UserAdminDatum', email: string, disabled: boolean, creationDate: any, lastAuthenticationDate?: any | null } | null } | null }; export type FindUsersByRoleQueryVariables = Exact<{ role?: InputMaybe | Scalars['String']['input']>; @@ -5465,7 +5465,7 @@ export type CreateVariantMutationVariables = Exact<{ }>; -export type CreateVariantMutation = { __typename?: 'Mutation', createVariant?: { __typename?: 'CreateVariantPayload', incident_id?: number | null, report_number?: number | null } | null }; +export type CreateVariantMutation = { __typename?: 'Mutation', createVariant?: { __typename?: 'CreateVariantPayload', incident_id: number, report_number: number } | null }; export type UpdateVariantMutationVariables = Exact<{ filter: ReportFilterType; @@ -5488,7 +5488,7 @@ export const UpsertClassificationDocument = {"kind":"Document","definitions":[{" export const InsertDuplicateDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"InsertDuplicate"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"duplicate"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"DuplicateInsertInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"insertOneDuplicate"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"data"},"value":{"kind":"Variable","name":{"kind":"Name","value":"duplicate"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"duplicate_incident_number"}},{"kind":"Field","name":{"kind":"Name","value":"true_incident_number"}}]}}]}}]} as unknown as DocumentNode; export const UpsertEntityDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpsertEntity"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"EntityFilterType"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"update"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"EntityInsertType"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"upsertOneEntity"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}},{"kind":"Argument","name":{"kind":"Name","value":"update"},"value":{"kind":"Variable","name":{"kind":"Name","value":"update"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entity_id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]} as unknown as DocumentNode; export const FindEntitiesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindEntities"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entities"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entity_id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]} as unknown as DocumentNode; -export const FindEntityDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindEntity"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"EntityFilterType"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entity"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entity_id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"created_at"}}]}}]}}]} as unknown as DocumentNode; +export const FindEntityDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindEntity"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"EntityFilterType"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entity"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entity_id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"created_at"}},{"kind":"Field","name":{"kind":"Name","value":"date_modified"}}]}}]}}]} as unknown as DocumentNode; export const UpdateEntityDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateEntity"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"EntityFilterType"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"update"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"EntityUpdateType"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateOneEntity"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}},{"kind":"Argument","name":{"kind":"Name","value":"update"},"value":{"kind":"Variable","name":{"kind":"Name","value":"update"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entity_id"}}]}}]}}]} as unknown as DocumentNode; export const FindIncidentDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindIncident"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"IncidentFilterType"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"incident"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"incident_id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"editors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"first_name"}},{"kind":"Field","name":{"kind":"Name","value":"last_name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"date"}},{"kind":"Field","name":{"kind":"Name","value":"AllegedDeployerOfAISystem"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entity_id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"AllegedDeveloperOfAISystem"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entity_id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"AllegedHarmedOrNearlyHarmedParties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entity_id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"nlp_similar_incidents"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"incident_id"}},{"kind":"Field","name":{"kind":"Name","value":"similarity"}}]}},{"kind":"Field","name":{"kind":"Name","value":"editor_similar_incidents"}},{"kind":"Field","name":{"kind":"Name","value":"editor_dissimilar_incidents"}},{"kind":"Field","name":{"kind":"Name","value":"flagged_dissimilar_incidents"}},{"kind":"Field","name":{"kind":"Name","value":"reports"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"report_number"}}]}},{"kind":"Field","name":{"kind":"Name","value":"embedding"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"from_reports"}},{"kind":"Field","name":{"kind":"Name","value":"vector"}}]}},{"kind":"Field","name":{"kind":"Name","value":"editor_notes"}}]}}]}}]} as unknown as DocumentNode; export const FindIncidentsTableDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindIncidentsTable"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filter"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"IncidentFilterType"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"incidents"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"filter"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filter"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"incident_id"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"editors"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"first_name"}},{"kind":"Field","name":{"kind":"Name","value":"last_name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"date"}},{"kind":"Field","name":{"kind":"Name","value":"AllegedDeployerOfAISystem"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entity_id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"AllegedDeveloperOfAISystem"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entity_id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"AllegedHarmedOrNearlyHarmedParties"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"entity_id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"reports"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"report_number"}}]}}]}}]}}]} as unknown as DocumentNode; diff --git a/site/gatsby-site/server/types/entity.ts b/site/gatsby-site/server/types/entity.ts index 53e9561843..a7b78adca2 100644 --- a/site/gatsby-site/server/types/entity.ts +++ b/site/gatsby-site/server/types/entity.ts @@ -9,5 +9,6 @@ export const EntityType = new GraphQLObjectType({ entity_id: { type: new GraphQLNonNull(GraphQLString) }, name: { type: new GraphQLNonNull(GraphQLString) }, created_at: { type: GraphQLDateTime }, + date_modified: { type: GraphQLDateTime }, }, }); diff --git a/site/gatsby-site/src/graphql/entities.js b/site/gatsby-site/src/graphql/entities.js index 11bb7c9a91..e4402279cf 100644 --- a/site/gatsby-site/src/graphql/entities.js +++ b/site/gatsby-site/src/graphql/entities.js @@ -24,12 +24,11 @@ export const FIND_ENTITY = gql(` entity_id name created_at + date_modified } } `); -// TODO: temporarily remove date_modified - export const UPDATE_ENTITY = gql(` mutation UpdateEntity($filter: EntityFilterType!, $update: EntityUpdateType!) { updateOneEntity(filter: $filter, update: $update) { diff --git a/site/gatsby-site/src/pages/apps/newsdigest.js b/site/gatsby-site/src/pages/apps/newsdigest.js index bc8995ab67..9fa0c6f40d 100644 --- a/site/gatsby-site/src/pages/apps/newsdigest.js +++ b/site/gatsby-site/src/pages/apps/newsdigest.js @@ -61,25 +61,41 @@ export default function NewsSearchPage() { const { data: submissionsData } = useQuery( gql` - query ExistingSubmissions($query: SubmissionQueryInput!) { - submissions(query: $query, limit: 9999) { + query ExistingSubmissions($filter: SubmissionFilterType!) { + submissions(filter: $filter) { url } } `, - { variables: { query: { url_in: newsArticleUrls } } } + { + variables: { + filter: { + url: { + IN: newsArticleUrls, + }, + }, + }, + } ); const { data: reportsData } = useQuery( gql` - query ExistingReports($query: ReportQueryInput!) { - reports(query: $query, limit: 9999) { + query ExistingReports($filter: ReportFilterType!) { + reports(filter: $filter) { report_number url } } `, - { variables: { query: { url_in: newsArticleUrls } } } + { + variables: { + filter: { + url: { + IN: newsArticleUrls, + }, + }, + }, + } ); const [updateCandidate] = useMutation(gql` diff --git a/site/gatsby-site/src/pages/entities/edit.js b/site/gatsby-site/src/pages/entities/edit.js index 968edee23f..231b11e90b 100644 --- a/site/gatsby-site/src/pages/entities/edit.js +++ b/site/gatsby-site/src/pages/entities/edit.js @@ -55,7 +55,7 @@ function EditEntityPage(props) { update: { set: { name: values.name, - date_modified: new Date(), + date_modified: new Date().toISOString(), }, }, }, @@ -102,6 +102,7 @@ function EditEntityPage(props) { initialValues={{ ...entity, }} + enableReinitialize > {({ values,