Skip to content

Commit

Permalink
Merge pull request #3260 from responsible-ai-collaborative/staging
Browse files Browse the repository at this point in the history
Deploy to Production
  • Loading branch information
cesarvarela authored Dec 12, 2024
2 parents 40e52fa + 05b7f1c commit cce74c7
Show file tree
Hide file tree
Showing 89 changed files with 12,297 additions and 3,982 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ jobs:
continue-on-error: true
run: |
# Extract branch name from ref (removes refs/heads/ prefix)
BRANCH_NAME=$(echo $GITHUB_HEAD_REF | sed 's/refs\/heads\///')
if [[ ! -z "${{ inputs.netlify-alias }}" ]]; then
netlify env:set NEXTAUTH_URL ${{ inputs.site-url || vars.SITE_URL }} --context "branch:${BRANCH_NAME}"
netlify env:set NEXTAUTH_URL ${{ inputs.site-url || vars.SITE_URL }} --context "branch:${{ inputs.netlify-alias }}"
fi
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/realm-empty-env.yml

This file was deleted.

8 changes: 7 additions & 1 deletion site/gatsby-site/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ cloudinary.config({ cloud_name: config.cloudinary.cloudName });

const adapter = require('gatsby-adapter-netlify').default;

let googleTrackingIds = [];

if (process.env.SITE_URL === config.gatsby.siteUrl) {
googleTrackingIds.push(config.gatsby.gaTrackingId);
}

const plugins = [
'layout',
{
Expand Down Expand Up @@ -65,7 +71,7 @@ const plugins = [
{
resolve: `gatsby-plugin-google-gtag`,
options: {
trackingIds: [config.gatsby.gaTrackingId],
trackingIds: googleTrackingIds,
},
},
{
Expand Down
4 changes: 4 additions & 0 deletions site/gatsby-site/i18n/locales/en/popovers.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
"title": "Quiet",
"text": "Quiet reports are those that will not be published in the 'Latest Reports' section of the homepage. Quiet reports are used for reports that are useful for internal data but do not need to be promoted. If you are unsure, leave this field blank."
},
"implicated_systems": {
"title": "Implicated Systems",
"text": "The AI systems involved in the incident. If multiple, press “enter” to begin a new item."
},
"similarIncidentSearch": {
"title": "Search for similar incidents",
"text": "Search for a similar or dissimilar incident by typing an incident ID. If the resulting incident is similar click 'Yes', if it's dissimilar click 'No'. If you're not sure click 'Not sure'. Once selected, the incident will be added to the 'Manually-selected similar and dissimilar incidents' section of the form. Once added, if you want to remove it, click the 'Not Sure' button."
Expand Down
4 changes: 3 additions & 1 deletion site/gatsby-site/i18n/locales/es/entities.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"{{count}} Report_plural": "{{count}} Reportes",
"Incidents involved as both Developer and Deployer": "Incidentes involucrados como desarrollador e implementador",
"Incidents Harmed By": "Afectado por Incidentes",
"Alleged: <2></2> developed and deployed an AI system, which harmed <5></5>.": "Presunto: un sistema de IA desarrollado e implementado por <2></2>, perjudicó a <5></5>.",
"Alleged: <2></2> developed and deployed an AI system, which harmed <6></6>.": "Presunto: un sistema de IA desarrollado e implementado por <2></2>, perjudicó a <6></6>.",
"Implicated AI system:": "Sistema de IA implicado:",
"Implicated AI systems:": "Sistemas de IA implicados:",
"Alleged: <1></1> developed an AI system deployed by <4></4>, which harmed <6></6>.": "Presunto: un sistema de IA desarrollado por <1></1> e implementado por <4></4>, perjudicó a <6></6>.",
"Entities involved in AI Incidents": "^Entities involved in AI Incidents",
"{{count}} Incident responses": "{{count}} respuestas de incidentes",
Expand Down
4 changes: 4 additions & 0 deletions site/gatsby-site/i18n/locales/es/popovers.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
"title": "¿Es un informe silencioso?",
"text": "Los informes silenciosos son aquellos que no se publicarán en la sección 'Últimos informes' de la página de inicio. Los informes silenciosos se utilizan para informes que son útiles para datos internos pero que no necesitan promocionarse. Si no está seguro, deje este campo en blanco."
},
"implicated_systems": {
"title": "Sistemas implicados",
"text": "Los sistemas de IA involucrados en el incidente. Si son múltiples, presione “enter” después del elemento para ingresar uno nuevo."
},
"similarIncidentSearch": {
"title": "Buscar incidentes similares",
"text": "Busque un incidente similar o diferente escribiendo un ID de incidente. Si el incidente resultante es similar, haga clic en 'Sí', si es diferente, haga clic en 'No'. Si no está seguro, haga clic en 'No estoy seguro'. Una vez seleccionado, el incidente se agregará a la sección del formulario 'Incidentes similares y diferentes seleccionados manualmente'. Una vez agregado, si desea eliminarlo, haga clic en el botón “No estoy seguro”."
Expand Down
2 changes: 2 additions & 0 deletions site/gatsby-site/i18n/locales/es/submit.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@
"Submit a new incident report to the Artificial Intelligence Incident Database": "Enviar un nuevo informe de incidente a la Base de Datos de Incidentes de Inteligencia Artificial",
"Draft saved": "Borrador guardado",
"Saving as draft...": "Guardando como borrador...",
"Implicated Systems": "Sistemas Implicados",
"What systems were involved in the incident?": "¿Qué sistemas estuvieron involucrados en el incidente?",
"Please confirm you are ready to submit this report. Report details cannot be changed after submission.": "Por favor confirma que estás listo para enviar este informe. Los detalles del informe no se pueden cambiar después de la presentación."
}
1 change: 1 addition & 0 deletions site/gatsby-site/i18n/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@
"Redirecting...": "Redirigiendo",
"Random Incident": "Incidente aleatorio",
"Risk Checklists": "Control de Riesgos",
"Implicated Systems": "Sistemas Implicados",
"Manually-selected similar and dissimilar incidents": "Incidentes similares y disímiles seleccionados manualmente",
"Search similar/dissimilar Incident Id": "Buscar incidente similar/disímil por ID",
"Assigned similar/dissimilar incidents": "Incidentes similares/disímiles asignados",
Expand Down
4 changes: 3 additions & 1 deletion site/gatsby-site/i18n/locales/es/validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@
"*Description is required": "*La descripción es obligatoria",
"*Incident Date is required": "*Fecha del incidente es obligatoria",
"*Incident Date required": "*Fecha del incidente es obligatoria",
"*Incident ID(s) must be a number": "*El ID del incidente debe ser un número"
"*Incident ID(s) must be a number": "*El ID del incidente debe ser un número",
"Implicated Systems must have at least 3 characters": "Los sistemas implicados deben tener al menos 3 caracteres",
"Implicated Systems can't be longer than 200 characters": "Los sistemas implicados no pueden tener más de 200 caracteres"
}
4 changes: 3 additions & 1 deletion site/gatsby-site/i18n/locales/fr/entities.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@
"Editing Entity": "Modification de l'entité",
"Back to Entity: {{name}}": "Retour à l'entité: {{name}}",
"Entity updated successfully.": "Entité mise à jour avec succès.",
"Error updating Entity.": "Erreur lors de la mise à jour de l'entité."
"Error updating Entity.": "Erreur lors de la mise à jour de l'entité.",
"Implicated AI system:": "Système de l'IA impliqué:",
"Implicated AI systems:": "Systèmes de l'IA impliqués:"
}
4 changes: 4 additions & 0 deletions site/gatsby-site/i18n/locales/fr/popovers.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
"title": "Est-ce un rapport silencieux ?",
"text": "Les rapports silencieux sont ceux qui ne seront pas publiés dans la section « Derniers rapports » de la page d'accueil. Les rapports silencieux sont utilisés pour les rapports utiles pour les données internes mais qui n'ont pas besoin d'être promus. Si vous n'êtes pas sûr, laissez ce champ vide."
},
"implicated_systems": {
"title": "Systèmes d'IA impliqués dans l'incident",
"text": "Si plusieurs, appuyez sur « entrée » pour commencer un nouvel élément"
},
"similarIncidentSearch": {
"title": "Rechercher des incidents similaires",
"text": "Recherchez un incident similaire ou différent en saisissant un ID d'incident. Si l'incident qui en résulte est similaire, cliquez sur « Oui », s'il est différent, cliquez sur « Non ». Si vous n'êtes pas sûr, cliquez sur « Pas sûr ». Une fois sélectionné, l'incident sera ajouté à la section « Incidents similaires et différents sélectionnés manuellement » du formulaire. Une fois ajouté, si vous souhaitez le supprimer, cliquez sur le bouton « Pas sûr »."
Expand Down
2 changes: 2 additions & 0 deletions site/gatsby-site/i18n/locales/fr/submit.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@
"Submit a new incident report to the Artificial Intelligence Incident Database.": "Soumettre un nouveau rapport d'incident à la base de données des incidents d'intelligence artificielle.",
"Draft saved": "Brouillon enregistré",
"Saving as draft...": "Enregistrement en tant que brouillon...",
"Implicated Systems": "Systèmes impliqués",
"What systems were involved in the incident?": "Quels systèmes étaient impliqués dans l'incident ?",
"Please confirm you are ready to submit this report. Report details cannot be changed after submission.": "Veuillez confirmer que vous êtes prêt à soumettre ce rapport. Les détails du rapport ne peuvent pas être modifiés après la soumission."
}
2 changes: 2 additions & 0 deletions site/gatsby-site/i18n/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,8 @@
"Random Incident": "Incident au hasard",
"Read the Source": "Lire la source",
"Risk Checklists": "Contrôle des risques",
"Implicated Systems": "Systèmes impliqués",
"and": "et",
"Manually-selected similar and dissimilar incidents": "Incidents similaires et dissemblables sélectionnés manuellement",
"Search similar/dissimilar Incident Id": "Rechercher un incident similaire/dissimilaire",
"Assigned similar/dissimilar incidents": "Incidents similaires/dissimilaires attribués",
Expand Down
4 changes: 3 additions & 1 deletion site/gatsby-site/i18n/locales/fr/validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@
"*Description is required": "*La description est requise",
"*Incident Date is required": "*Date de l'incident requise",
"*Incident Date required": "*Date de l'incident requise",
"*Incident ID(s) must be a number": "*L'ID de l'incident doit être un nombre"
"*Incident ID(s) must be a number": "*L'ID de l'incident doit être un nombre",
"Implicated Systems must have at least 3 characters": "Les systèmes impliqués doivent comporter au moins 3 caractères",
"Implicated Systems can't be longer than 200 characters": "Les systèmes impliqués ne peuvent pas comporter plus de 200 caractères"
}
4 changes: 3 additions & 1 deletion site/gatsby-site/i18n/locales/ja/entities.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@
"Editing Entity": "組織の編集",
"Back to Entity: {{name}}": "組織に戻る: {{name}}",
"Entity updated successfully.": "組織が正常に更新されました。",
"Error updating Entity.": "組織の更新中にエラーが発生しました。"
"Error updating Entity.": "組織の更新中にエラーが発生しました。",
"Implicated AI system:": "AI関連システム:",
"Implicated AI systems:": "AI関連システム:"
}
4 changes: 4 additions & 0 deletions site/gatsby-site/i18n/locales/ja/popovers.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
"title": "あなたです!",
"text": "現在ログイン中なのでこの投稿は自動的にあなたのアカウントに関連づけられます。匿名で投稿するには、ブラウザウィンドウを匿名モードで開いて投稿してください。"
},
"implicated_systems": {
"title": "インシデントに関与したAIシステム",
"text": "複数ある場合は、新しい項目を入力するためにEnterキーを押してください"
},
"similarIncidentSearch": {
"title": "類似の事件を検索",
"text": "インシデント ID を入力して、類似または非類似のインシデントを検索します。結果のインシデントが類似している場合は「はい」をクリックし、非類似の場合は「いいえ」をクリックします。不明な場合は「不明」をクリックします。選択すると、インシデントはフォームの「手動で選択された類似および非類似のインシデント」セクションに追加されます。追加した後で削除したい場合は、「わからない」ボタンをクリックします。"
Expand Down
2 changes: 2 additions & 0 deletions site/gatsby-site/i18n/locales/ja/submit.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,7 @@
"Saving changes...": "変更を保存中...",
"Draft saved": "下書きが保存されました",
"Saving as draft...": "下書きとして保存中...",
"Implicated Systems": "関連システム",
"What systems were involved in the incident?": "このインシデントに関わるシステムは何ですか?",
"Please confirm you are ready to submit this report. Report details cannot be changed after submission.": "このレポートを送信する準備ができていることを確認してください。送信後にレポートの詳細を変更することはできません"
}
4 changes: 3 additions & 1 deletion site/gatsby-site/i18n/locales/ja/validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
"Please review report. Some data is missing.": "レポートを確認してください。足りない情報があります",
"Please review submission. Some data is missing.": "投稿を確認してください。足りない情報があります",
"Some data is missing.": "足りない情報があります",
"Please review. Some data is missing.": "確認してください。足りない情報があります"
"Please review. Some data is missing.": "確認してください。足りない情報があります",
"Implicated Systems must have at least 3 characters": "関連システムは3文字以上でなければいけません",
"Implicated Systems can't be longer than 200 characters": "関連システムは200文字を超えることはできません"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const config = require('../config');
/**
*
* @param {{context: {client: import('mongodb').MongoClient}}} context
*/

exports.up = async ({ context: { client } }) => {
await client.connect();

// New implicated_systems field on submissions and incidents collections from production db and history db

const submissionsCollection = client
.db(config.realm.production_db.db_name)
.collection('submissions');

const submissionsHistoryCollection = client
.db(config.realm.production_db.db_history_name)
.collection('submissions');

const incidentsCollection = client.db(config.realm.production_db.db_name).collection('incidents');

const incidentsHistoryCollection = client
.db(config.realm.production_db.db_history_name)
.collection('incidents');

const submissionsUpdates = await submissionsCollection.updateMany(
{},
{
$set: {
implicated_systems: [],
},
}
);

console.log(
`Updated ${submissionsUpdates.modifiedCount} submissions with new implicated_systems field`
);

const submissionsHistoryUpdates = await submissionsHistoryCollection.updateMany(
{},
{
$set: {
implicated_systems: [],
},
}
);

console.log(
`Updated ${submissionsHistoryUpdates.modifiedCount} submissions history with new created_at field`
);

const incidentsUpdates = await incidentsCollection.updateMany(
{},
{
$set: {
implicated_systems: [],
},
}
);

console.log(
`Updated ${incidentsUpdates.modifiedCount} incidents with new implicated_systems field`
);

const incidentsHistoryUpdates = await incidentsHistoryCollection.updateMany(
{},
{
$set: {
implicated_systems: [],
},
}
);

console.log(
`Updated ${incidentsHistoryUpdates.modifiedCount} incidents history with new created_at field`
);
};
2 changes: 2 additions & 0 deletions site/gatsby-site/page-creators/createEntitiesPages.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const createEntitiesPages = async (graphql, createPage) => {
Alleged_deployer_of_AI_system
Alleged_developer_of_AI_system
Alleged_harmed_or_nearly_harmed_parties
implicated_systems
reports {
report_number
}
Expand Down Expand Up @@ -55,6 +56,7 @@ const createEntitiesPages = async (graphql, createPage) => {
incidentsAsDeveloper: entity.incidentsAsDeveloper,
incidentsAsBoth: entity.incidentsAsBoth,
incidentsHarmedBy: entity.incidentsHarmedBy,
incidentsImplicatedSystems: entity.incidentsImplicatedSystems,
relatedEntities: entity.relatedEntities,
responses: entity.responses,
},
Expand Down
2 changes: 2 additions & 0 deletions site/gatsby-site/playwright/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ type ConfigType = {
IS_EMPTY_ENVIRONMENT: string;
AVAILABLE_LANGUAGES?: string;
[key: string]: string;
SITE_URL?: string;
};

const config: ConfigType = {
E2E_ADMIN_PASSWORD: process.env.E2E_ADMIN_PASSWORD!,
E2E_ADMIN_USERNAME: process.env.E2E_ADMIN_USERNAME!,
IS_EMPTY_ENVIRONMENT: process.env.IS_EMPTY_ENVIRONMENT ?? '',
AVAILABLE_LANGUAGES: process.env.GATSBY_AVAILABLE_LANGUAGES ?? '',
SITE_URL: process.env.SITE_URL ?? '',
}

Object.keys(config).forEach((key) => {
Expand Down
50 changes: 42 additions & 8 deletions site/gatsby-site/playwright/e2e-full/account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@ test.describe('Account', () => {

await page.goto(url);

const detailsTable = page.locator('[data-cy="details-table"]');

await expect(detailsTable.locator(`td:text-is("${config.E2E_ADMIN_USERNAME}")`)).toBeVisible();
await expect(detailsTable.locator('td:text-is("Test")')).toBeVisible();
await expect(detailsTable.locator('td:text-is("User")')).toBeVisible();
await expect(detailsTable.locator('span:text-is("admin")')).toBeVisible();
await expect(page.locator('[data-cy="user-email"]').locator(`td:text-is("${config.E2E_ADMIN_USERNAME}")`)).toBeVisible();
await expect(page.locator('[data-cy="user-first-name"]').locator('td:text-is("Test")')).toBeVisible();
await expect(page.locator('[data-cy="user-last-name"]').locator('td:text-is("User")')).toBeVisible();
await expect(page.locator('[data-cy="user-role"]').locator('span:text-is("admin")')).toBeVisible();

await expect(page.locator('a:text-is("Log out")')).toBeVisible();
});

test('Should allow editing user data', async ({ page, login }) => {
test('Should allow editing user role data (admin user)', async ({ page, login }) => {

await login(config.E2E_ADMIN_USERNAME, config.E2E_ADMIN_PASSWORD, { customData: { roles: ['admin'], first_name: 'Test', last_name: 'User' } });

await page.goto(url);


await page.locator('button:has-text("Edit")').click();

const editUserModal = page.getByTestId('edit-user-modal');
Expand All @@ -52,4 +49,41 @@ test.describe('Account', () => {

await expect(page.getByTestId('edit-user-modal')).toBeVisible();
});

test('Should allow editing their own first and last name (subscriber user)', async ({ page, login }) => {

await login(config.E2E_ADMIN_USERNAME, config.E2E_ADMIN_PASSWORD, { customData: { roles: ['subscriber'], first_name: 'Test', last_name: 'User' } });

await page.goto(url);

await page.locator('button:has-text("Edit")').click();

const editUserModal = page.getByTestId('edit-user-modal');

await editUserModal.locator('[id="first_name"]').fill('New first name');
await editUserModal.locator('[id="last_name"]').fill('New last name');
await editUserModal.locator('button:has-text("Submit")').click();

await expect(editUserModal).not.toBeVisible();

await expect(page.locator('[data-cy="toast"]')).toContainText('User updated.', { timeout: 60000 });

await expect(page.locator('[data-cy="user-first-name"]').locator('td:text-is("New first name")')).toBeVisible();
await expect(page.locator('[data-cy="user-last-name"]').locator('td:text-is("New last name")')).toBeVisible();
});

test('Should not allow to edit roles (subscriber user)', async ({ page, login }) => {

await login(config.E2E_ADMIN_USERNAME, config.E2E_ADMIN_PASSWORD, { customData: { roles: ['subscriber'], first_name: 'Test', last_name: 'User' } });

await page.goto(url);

await page.locator('button:has-text("Edit")').click();

const editUserModal = page.getByTestId('edit-user-modal');

const rolesInput = editUserModal.locator('[id="roles"]');

await expect(rolesInput).toBeDisabled({ timeout: 3000 });
});
});
Loading

0 comments on commit cce74c7

Please sign in to comment.