Skip to content

Commit

Permalink
Remove UI references to base-client (#76)
Browse files Browse the repository at this point in the history
* Remove references to base client

* handle baseClientId UI side

* Tidy templates

* fix lint errors
  • Loading branch information
thomasridd authored Mar 13, 2024
1 parent 156be0d commit 5539d6f
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 27 deletions.
4 changes: 2 additions & 2 deletions server/mappers/baseClientApi/listBaseClients.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request } from 'express'
import { ListBaseClientsResponse } from '../../interfaces/baseClientApi/baseClientResponse'
import { BaseClient, BaseClientListFilter } from '../../interfaces/baseClientApi/baseClient'
import { kebab, multiSeparatorSplit, snake } from '../../utils/utils'
import { kebab, multiSeparatorSplit, snake, toBaseClientId } from '../../utils/utils'
import { GrantTypes } from '../../data/enums/grantTypes'
import { ClientType } from '../../data/enums/clientTypes'

Expand Down Expand Up @@ -69,7 +69,7 @@ export default (response: ListBaseClientsResponse): BaseClient[] => {
return clients.map(
client =>
({
baseClientId: client.baseClientId,
baseClientId: toBaseClientId(client.baseClientId),
accessTokenValidity: 24000,
scopes: [],
grantType: snake(client.grantType),
Expand Down
12 changes: 12 additions & 0 deletions server/utils/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
dateFormat,
dateTimeFormatFromString,
snakeUpper,
toBaseClientId,
} from './utils'

describe('convert to title case', () => {
Expand Down Expand Up @@ -171,3 +172,14 @@ describe('dateTimeStringFormat', () => {
expect(dateTimeFormatFromString(input)).toEqual(expectedOutput)
})
})

describe('toBaseId', () => {
it.each([
['an id without a trailing -digit', 'base_id', 'base_id'],
['an id with an internal -digit', 'base-1-id', 'base-1-id'],
['an id with a trailing -digit', 'base_id-1', 'base_id'],
['an id with trailing -multiple_digits', 'base_id-10', 'base_id'],
])('handles %s: %s -> %s', (_inputType: string, input: string, expectedOutput: string) => {
expect(toBaseClientId(input)).toEqual(expectedOutput)
})
})
6 changes: 6 additions & 0 deletions server/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,9 @@ export const dateTimeFormatFromString = (date: string): string => {

return format(new Date(date), 'dd-MM-yyyy HH:mm', { locale: enGB })
}

export const toBaseClientId = (id: string): string => {
// remove any trailing hyphen and number
if (!id) return id
return id.replace(/-\d+$/, '')
}
14 changes: 7 additions & 7 deletions server/views/pages/base-client.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "../partials/layout.njk" %}

{% set pageTitle = applicationName + " - Home" %}
{% set pageTitle = applicationName + " - Client" %}
{% set mainClasses = "app-container govuk-body" %}

{% set pageName="Home" %}
Expand Down Expand Up @@ -54,9 +54,9 @@

<form class="govuk-grid-row" action="/base-clients/{{ baseClient.baseClientId }}/clients" method="POST">
<input type="hidden" name="_csrf" value="{{ csrfToken }}">
<div class="govuk-grid-column-one-quarter">
<div class="govuk-grid-column-one-half">
{{ govukButton({
text: "Add new client",
text: "Add client instance",
attributes: {
"data-qa": "add-new-client-button"
}
Expand All @@ -66,9 +66,9 @@

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l">Base client details</h2>
<h2 class="govuk-heading-l">Client details</h2>
</div>
<div class="govuk-grid-column-one-third">
<div class="govuk-grid-column-one-third govuk-!-text-align-right">
<a class="govuk-link" href="/base-clients/{{ baseClient.baseClientId }}/edit" data-qa='change-client-details-link'>Change
client details</a>
</div>
Expand All @@ -78,7 +78,7 @@
firstCellIsHeader: false,
head: [
{
text: "Base client",
text: "Client",
classes: "govuk-!-width-one-half"
},{
text: baseClient.baseClientId
Expand Down Expand Up @@ -324,7 +324,7 @@
<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-l">Deployment details</h2>
</div>
<div class="govuk-grid-column-one-third">
<div class="govuk-grid-column-one-third govuk-!-text-align-right">
<a class="govuk-link" href="/base-clients/{{ baseClient.baseClientId }}/deployment" data-qa='change-deployment-details-link'>Change
deployment details</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion server/views/pages/delete-client-instance.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "../partials/layout.njk" %}

{% set pageTitle = applicationName + " - Home" %}
{% set pageTitle = applicationName + " - Delete client" %}
{% set mainClasses = "app-container govuk-body" %}

{% set pageName="Delete client?" %}
Expand Down
4 changes: 2 additions & 2 deletions server/views/pages/edit-base-client-deployment.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "../partials/layout.njk" %}

{% set pageTitle = applicationName + " - Add base client" %}
{% set pageTitle = applicationName + " - Add client" %}
{% set mainClasses = "app-container govuk-body" %}

{% set pageName="Home" %}
Expand Down Expand Up @@ -38,7 +38,7 @@
rows: [
{
key: {
text: "Base client id"
text: "Client id"
},
value: {
text: baseClient.baseClientId
Expand Down
2 changes: 1 addition & 1 deletion server/views/pages/edit-base-client-details.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "../partials/layout.njk" %}

{% set pageTitle = applicationName + " - Add base client" %}
{% set pageTitle = applicationName + " - Edit client" %}
{% set mainClasses = "app-container govuk-body" %}

{% set pageName="Home" %}
Expand Down
11 changes: 0 additions & 11 deletions server/views/pages/index.njk

This file was deleted.

2 changes: 1 addition & 1 deletion server/views/pages/new-base-client-details.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "../partials/layout.njk" %}

{% set pageTitle = applicationName + " - Add base client" %}
{% set pageTitle = applicationName + " - Add client" %}
{% set mainClasses = "app-container govuk-body" %}

{% set pageName="Home" %}
Expand Down
2 changes: 1 addition & 1 deletion server/views/pages/new-base-client-grant.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "../partials/layout.njk" %}

{% set pageTitle = applicationName + " - Add base client" %}
{% set pageTitle = applicationName + " - Add client" %}
{% set mainClasses = "app-container govuk-body" %}

{% set pageName="Home" %}
Expand Down
2 changes: 1 addition & 1 deletion server/views/pages/new-base-client-success.njk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "../partials/layout.njk" %}

{% set pageTitle = applicationName + " - Add base client" %}
{% set pageTitle = applicationName + " - Credentials" %}
{% set mainClasses = "app-container govuk-body" %}

{% set pageName="Home" %}
Expand Down

0 comments on commit 5539d6f

Please sign in to comment.