-
Notifications
You must be signed in to change notification settings - Fork 56
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
[FEATURE] Afficher les bannières dynamiquement. #11071
Open
MathieuGilet
wants to merge
7
commits into
dev
Choose a base branch
from
tech/dynamic-banners
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6866904
feat(banner): add information banners stored in Redis
MathieuGilet 0c21ef5
tech(api): extract temporary-storage to key-value-storage
HEYGUL 0b8e767
add script to ease adding information banners
HEYGUL 2df9a88
feat(certif): display information banners dynamically
HEYGUL a40fc5f
feat(mon-pix): display information banners dynamically
HEYGUL c6a5655
feat(orga): display information banners dynamically
HEYGUL 68275fa
tech(api): set 30s cache to banners and feature toggles
HEYGUL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Script } from '../../src/shared/application/scripts/script.js'; | ||
import { ScriptRunner } from '../../src/shared/application/scripts/script-runner.js'; | ||
import { informationBannersStorage } from '../../src/shared/infrastructure/key-value-storages/index.js'; | ||
|
||
export class AddInformationBanners extends Script { | ||
constructor() { | ||
super({ | ||
description: 'Add information banners data to Redis', | ||
permanent: true, | ||
options: { | ||
target: { | ||
type: 'string', | ||
describe: 'application name we want to add information banners to', | ||
required: true, | ||
requiresArg: true, | ||
}, | ||
severity: { | ||
type: 'string', | ||
describe: 'severity of the message', | ||
choices: ['error', 'warning', 'information'], | ||
required: true, | ||
requiresArg: true, | ||
}, | ||
message_fr: { | ||
type: 'string', | ||
describe: 'message content in French', | ||
required: true, | ||
requiresArg: true, | ||
}, | ||
message_en: { | ||
type: 'string', | ||
describe: 'message content in English', | ||
required: true, | ||
requiresArg: true, | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
async handle({ options }) { | ||
const { target, severity, message_fr, message_en } = options; | ||
const banners = (await informationBannersStorage.get(target)) ?? []; | ||
|
||
banners.push({ severity, message: `[fr]${message_fr}[/fr][en]${message_en}[/en]` }); | ||
|
||
await informationBannersStorage.save({ key: target, value: banners }); | ||
} | ||
} | ||
|
||
await ScriptRunner.execute(import.meta.url, AddInformationBanners); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Script } from '../../src/shared/application/scripts/script.js'; | ||
import { ScriptRunner } from '../../src/shared/application/scripts/script-runner.js'; | ||
import { informationBannersStorage } from '../../src/shared/infrastructure/key-value-storages/index.js'; | ||
|
||
export class RemoveInformationBanners extends Script { | ||
constructor() { | ||
super({ | ||
description: 'Remove information banners data from Redis', | ||
permanent: true, | ||
options: { | ||
target: { | ||
type: 'string', | ||
describe: 'application name we want to remove information banners from', | ||
required: true, | ||
requiresArg: true, | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
async handle({ options }) { | ||
const { target } = options; | ||
|
||
await informationBannersStorage.delete(target); | ||
} | ||
} | ||
|
||
await ScriptRunner.execute(import.meta.url, RemoveInformationBanners); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { usecases } from '../domain/usecases/index.js'; | ||
import * as informationBannerSerializer from '../infrastructure/serializers/jsonapi/information-banner-serializer.js'; | ||
|
||
const getInformationBanner = async function (request) { | ||
const { target: id } = request.params; | ||
|
||
const informationBanner = await usecases.getInformationBanner({ id }); | ||
|
||
return informationBannerSerializer.serialize(informationBanner); | ||
}; | ||
|
||
const bannerController = { | ||
getInformationBanner, | ||
}; | ||
|
||
export { bannerController }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { bannerController } from './banner-controller.js'; | ||
|
||
const register = async function (server) { | ||
server.route([ | ||
{ | ||
method: 'GET', | ||
path: '/api/information-banners/{target}', | ||
options: { | ||
auth: false, | ||
handler: bannerController.getInformationBanner, | ||
cache: { | ||
expiresIn: 30 * 1000, | ||
}, | ||
}, | ||
}, | ||
]); | ||
}; | ||
|
||
const name = 'src-banners-api'; | ||
export { name, register }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export class InformationBanner { | ||
constructor({ id, banners }) { | ||
this.id = id; | ||
this.banners = | ||
banners?.map((banner, index) => { | ||
return new Banner({ ...banner, id: `${id}:${index + 1}` }); | ||
}) ?? []; | ||
} | ||
|
||
static empty({ id }) { | ||
return new InformationBanner({ id }); | ||
} | ||
} | ||
|
||
class Banner { | ||
constructor({ id, message, severity }) { | ||
this.id = id; | ||
this.message = message; | ||
this.severity = severity; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const getInformationBanner = async ({ id, informationBannerRepository }) => { | ||
return informationBannerRepository.get({ id }); | ||
}; | ||
|
||
export { getInformationBanner }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// eslint-disable import/no-restricted-paths | ||
import { dirname, join } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
import { injectDependencies } from '../../../shared/infrastructure/utils/dependency-injection.js'; | ||
import { importNamedExportsFromDirectory } from '../../../shared/infrastructure/utils/import-named-exports-from-directory.js'; | ||
import * as informationBannerRepository from '../../infrastructure/repositories/information-banner-repository.js'; | ||
|
||
/** | ||
* | ||
* Using {@link https://jsdoc.app/tags-type "Closure Compiler's syntax"} to document injected dependencies | ||
* | ||
* @typedef {informationBannerRepository} InformationBannerRepository | ||
**/ | ||
const dependencies = { | ||
informationBannerRepository, | ||
}; | ||
|
||
const path = dirname(fileURLToPath(import.meta.url)); | ||
|
||
const usecasesWithoutInjectedDependencies = { | ||
...(await importNamedExportsFromDirectory({ | ||
path: join(path, './'), | ||
ignoredFileNames: 'index.js', | ||
})), | ||
}; | ||
|
||
const usecases = injectDependencies(usecasesWithoutInjectedDependencies, dependencies); | ||
|
||
/** | ||
* @typedef {dependencies} dependencies | ||
*/ | ||
export { usecases }; |
13 changes: 13 additions & 0 deletions
13
api/src/banner/infrastructure/repositories/information-banner-repository.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { informationBannersStorage } from '../../../shared/infrastructure/key-value-storages/index.js'; | ||
import { InformationBanner } from '../../domain/models/information-banner.js'; | ||
|
||
const get = async function ({ id }) { | ||
const banners = await informationBannersStorage.get(id); | ||
if (!banners) { | ||
return InformationBanner.empty({ id }); | ||
} | ||
|
||
return new InformationBanner({ id, banners }); | ||
}; | ||
|
||
export { get }; |
16 changes: 16 additions & 0 deletions
16
api/src/banner/infrastructure/serializers/jsonapi/information-banner-serializer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import jsonapiSerializer from 'jsonapi-serializer'; | ||
|
||
const { Serializer } = jsonapiSerializer; | ||
|
||
const serialize = function (informationBanner) { | ||
return new Serializer('information-banners', { | ||
attributes: ['banners'], | ||
banners: { | ||
included: true, | ||
ref: 'id', | ||
attributes: ['severity', 'message'], | ||
}, | ||
}).serialize(informationBanner); | ||
}; | ||
|
||
export { serialize }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as bannerRoute from './application/banner-route.js'; | ||
|
||
export const bannerRoutes = [bannerRoute]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
api/src/evaluation/infrastructure/repositories/answer-job-repository.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
api/src/identity-access-management/domain/services/authentication-session.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ntity-access-management/infrastructure/repositories/email-validation-demand.repository.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
api/src/identity-access-management/infrastructure/repositories/refresh-token.repository.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
api/src/identity-access-management/infrastructure/repositories/user-email.repository.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion(non-bloquante) : Il manque peut-être de pouvoir choisir le type d'alerte à retirer : Si on a une alerte information pour plusieurs mois et qu'on ajoute une alerte warning, là on retire les deux pour ajouter de nouveau celle de type information, ce qui peut être sujet à faire des erreurs ou ne pas la remettre.
question : On parle de Pix Exploit dans la description, du coup est-ce que ces scripts ne sont pas des doublons ? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je pense que Pix Exploit est uniquement pour la production (pour le moment), les scripts permettent à n'importe qui de réaliser les opérations en local/RA/Integration/Recette