Skip to content
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

[frontend] Fix uri definition variables #1651

Merged
merged 5 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public ExecutionProcess process(@NotNull final Execution execution, @NotNull fin
boolean encrypted = content.isEncrypted();
users.forEach(userInjectContext -> {
try {
// Put the challenges variables in the injection context
// Put the articles variables in the injection context
List<ArticleVariable> articleVariables = articles.stream()
.map(article -> new ArticleVariable(article.getId(), article.getName(),
buildArticleUri(userInjectContext, article)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,9 @@ const UpdateInjectDetails = ({
&& data[field.key]
&& data[field.key].length > 0
) {
const regex = /&lt;#list\s+(\w+)\s+as\s+(\w+)&gt;/g;
finalData[field.key] = data[field.key]
.replaceAll(
'&lt;#list challenges as challenge&gt;',
'<#list challenges as challenge>',
)
.replaceAll(
'&lt;#list articles as article&gt;',
'<#list articles as article>',
)
.replace(regex, (_, listName, identifier) => `<#list ${listName} as ${identifier}>`)
.replaceAll('&lt;/#list&gt;', '</#list>');
} else if (data[field.key] && field.type === 'tuple') {
if (field.cardinality && field.cardinality === '1') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const ScenarioInjects: FunctionComponent<Props> = () => {
teams={teams}
articles={articles}
variables={variables}
uriVariable={`/admin/scenarios/${scenarioId}/definition/variables`}
uriVariable={`/admin/scenarios/${scenarioId}/definition`}
allUsersNumber={scenario.scenario_all_users_number}
usersNumber={scenario.scenario_users_number}
// @ts-expect-error typing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const ExerciseInjects: FunctionComponent<Props> = () => {
teams={teams}
articles={articles}
variables={variables}
uriVariable={`/admin/exercises/${exerciseId}/definition/variables`}
uriVariable={`/admin/exercises/${exerciseId}/definition`}
allUsersNumber={exercise.exercise_all_users_number}
usersNumber={exercise.exercise_users_number}
// @ts-expect-error typing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@ class QuickInject extends Component {
</Form>
</div>
<AvailableVariablesDialog
uriVariable={`/admin/exercises/${exerciseId}/definition/variables`}
uriVariable={`/admin/exercises/${exerciseId}/definition`}
variables={this.props.exerciseVariables}
open={openVariables}
handleClose={this.handleCloseVariables.bind(this)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ AvailableVariablesDialogProps
label={t('Builtin variables')}
value="1"
/>
<Tab
{uriVariable && <Tab
sx={{ textTransform: 'none' }}
label={t('Custom variables')}
value="2"
/>
/>}
</TabList>
<DialogContent>
<TabPanel
Expand Down Expand Up @@ -161,10 +161,10 @@ AvailableVariablesDialogProps
})}
</List>
</TabPanel>
<TabPanel
{uriVariable && <TabPanel
value="2"
style={{ maxHeight: '100%', overflow: 'auto', padding: 0 }}
>
>
<Alert severity="info">
{t('Please follow this link to')}
{/* TODO: validate when migrate to new react router version */}
Expand Down Expand Up @@ -193,7 +193,7 @@ AvailableVariablesDialogProps
</div>
))}
</List>
</TabPanel>
</TabPanel>}
</DialogContent>
</TabContext>

Expand Down