Skip to content

Commit

Permalink
Add default disabled flow screen (#429)
Browse files Browse the repository at this point in the history
[#185951075]

Co-authored-by: Chibuisi Enyia <cenyia@codeforamerica.org>
  • Loading branch information
spokenbird and enyia21 authored Nov 1, 2023
1 parent cfc3297 commit a8626c9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2402,15 +2402,22 @@ from being able to access a given flow, and will redirect the user to a configur
attempt to reach a page within a disabled flow.

Here are two examples of disabled flows, the first goes to the home page and the second goes to a
unique static page. The default is the home page if no `staticRedirectPage` is configured.
unique static page. If no `staticRedirectScreen` is configured the library will default to the
[disabled feature](https://github.com/codeforamerica/form-flow/tree/main/src/main/resources/templates/disabledFeature.html)
template. This template provides a basic message stating the feature being accessed is currently unavailable
and to try again later if the user believes they have reached this page by mistake.

When disabling a flow, we recommend creating your own page with proper messaging about the disabled flow
to present to clients when they attempt to access the disabled flow. The configured `staticRedirectScreen`
will be used when provided and the default disabled feature template is only meant as a fallback.

```yaml
form-flow:
disabled-flows:
- flow: ubi
staticRedirectPage: '/'
- flow: docUpload
staticRedirectPage: '/disabledFeature'
staticRedirectPage: '/docUploadDisabled'
```

#### Design System
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.springframework.context.annotation.Configuration;

@Configuration
//@ConditionalOnProperty(name = "form-flow.disabled-flows")
@ConfigurationProperties(prefix = "form-flow")
@Getter
@Setter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public boolean preHandle(@NotNull HttpServletRequest request, @NotNull HttpServl
String staticRedirectPage = disabledFlowPropertyConfiguration.getDisabledFlowRedirect(requestedFlow);
if (staticRedirectPage == null || staticRedirectPage.isEmpty()) {
log.warn("Flow %s is disabled but no static redirect page is configured. Going home instead.".formatted(requestedFlow));
staticRedirectPage = "/";
staticRedirectPage = "/disabledFeature";
}
log.info("Flow %s is disabled. Redirecting to %s.".formatted(requestedFlow, staticRedirectPage));

try {
response.sendRedirect(staticRedirectPage);
} catch (IOException e) {
throw new RuntimeException(e);
throw new RuntimeException(e);
}
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/messages-form-flow.properties
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@ language-preferences.preview.second=
language-preferences.link-text.en=English
language-preferences.link-text.es=Español
language-preferences.link-text.vi=Ti?ng Vi?t
#
disabled-feature.header=Sorry, that feature is currently unavailable
disabled-feature.subtext=If you believe this is a mistake or need additional support, please try again later.
disabled-feature.return=Return to the homepage
20 changes: 20 additions & 0 deletions src/main/resources/templates/disabledFeature.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html th:lang="${#locale.language}" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragments/head :: head(title=#{disabled-feature.header})}"></head>
<body>
<div class="page-wrapper">
<div th:replace="~{fragments/toolbar :: toolbar}"></div>
<section class="slab">
<div class="grid">
<main id="content" role="main" class="form-card spacing-above-35">
<th:block th:replace="~{fragments/icons :: error}"></th:block>
<th:block th:replace="~{fragments/cardHeader :: cardHeader(header=#{disabled-feature.header})}"/>
<p th:text="#{disabled-feature.subtext}"></p>
<a href="/" th:text="#{disabled-feature.return}" class="button--primary button"></a>
</main>
</div>
</section>
</div>
<th:block th:replace="~{fragments/footer :: footer}"/>
</body>
</html>

0 comments on commit a8626c9

Please sign in to comment.