-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add script to ease adding information banners
- Loading branch information
Showing
6 changed files
with
89 additions
and
2 deletions.
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
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,49 @@ | ||
import { Script } from '../../src/shared/application/scripts/script.js'; | ||
import { ScriptRunner } from '../../src/shared/application/scripts/script-runner.js'; | ||
import { | ||
informationBannersStorage, | ||
quitAllStorages, | ||
} 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, | ||
}, | ||
severity: { | ||
type: 'string', | ||
describe: "severity of the message among 'error', 'warning' and 'information'", | ||
required: true, | ||
}, | ||
message_fr: { | ||
type: 'string', | ||
describe: 'message content in French', | ||
required: true, | ||
}, | ||
message_en: { | ||
type: 'string', | ||
describe: 'message content in English', | ||
required: 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 quitAllStorages(); | ||
} | ||
} | ||
|
||
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,31 @@ | ||
import { Script } from '../../src/shared/application/scripts/script.js'; | ||
import { ScriptRunner } from '../../src/shared/application/scripts/script-runner.js'; | ||
import { | ||
informationBannersStorage, | ||
quitAllStorages, | ||
} 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, | ||
}, | ||
}, | ||
}); | ||
} | ||
|
||
async handle({ options }) { | ||
const { target } = options; | ||
|
||
await informationBannersStorage.delete(target); | ||
await quitAllStorages(); | ||
} | ||
} | ||
|
||
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