-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support localize scope desc for user app consent screen (#94)
- Loading branch information
Showing
23 changed files
with
523 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { TextInput } from 'flowbite-react' | ||
import { useTranslations } from 'next-intl' | ||
|
||
const LocaleEditor = ({ | ||
supportedLocales, | ||
values, | ||
onChange, | ||
}: { | ||
supportedLocales: string[]; | ||
}) => { | ||
const t = useTranslations() | ||
|
||
const handleSetLocale = ( | ||
targetLocale: string, val: string, | ||
) => { | ||
const isUpdate = values.find((value) => value.locale === targetLocale) | ||
const newLocales = isUpdate | ||
? values.map((value) => value.locale === targetLocale | ||
? ({ | ||
locale: targetLocale, value: val, | ||
}) | ||
: value) | ||
: [...values, { | ||
locale: targetLocale, value: val, | ||
}] | ||
onChange(newLocales) | ||
} | ||
|
||
return ( | ||
<section className='flex flex-col gap-4'> | ||
<p>* {t('scopes.localeNote')}</p> | ||
{supportedLocales.map((locale) => ( | ||
<section | ||
key={locale} | ||
className='flex items-center gap-4'> | ||
<p>{locale.toUpperCase()}</p> | ||
<TextInput | ||
className='w-full' | ||
onChange={(e) => handleSetLocale( | ||
locale, | ||
e.target.value, | ||
)} | ||
value={values.find((value) => value.locale === locale)?.value ?? ''} | ||
/> | ||
</section> | ||
))} | ||
</section> | ||
) | ||
} | ||
|
||
export default LocaleEditor |
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,3 @@ | ||
import { typeTool } from 'tools' | ||
|
||
export const isSystem = (name: string) => Object.values(typeTool.Scope).some((scope) => scope === name) |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * as proxyTool from 'tools/proxy' | ||
export * as routeTool from 'tools/route' | ||
export * as typeTool from 'tools/type' | ||
export * as dataTool from 'tools/data' |
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,13 @@ | ||
CREATE TABLE [scope_locale] ( | ||
"id" integer PRIMARY KEY, | ||
"scopeId" integer NOT NULL, | ||
"locale" text NOT NULL, | ||
"value" text NOT NULL DEFAULT "", | ||
"createdAt" text DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" text DEFAULT CURRENT_TIMESTAMP, | ||
"deletedAt" text DEFAULT null, | ||
FOREIGN KEY(scopeId) REFERENCES scope(id) | ||
); | ||
CREATE UNIQUE INDEX idx_unique_scope_locale ON scope_locale (scopeId, locale) WHERE deletedAt IS NULL; | ||
INSERT INTO scope_locale ("scopeId", "locale", "value") values (2, "en", "Access your basic profile information"); | ||
INSERT INTO scope_locale ("scopeId", "locale", "value") values (2, "fr", "Accéder à vos informations de profil de base"); |
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.