Skip to content

Commit

Permalink
469941: Replace appEntitiyList with appEntityTable
Browse files Browse the repository at this point in the history
component
  • Loading branch information
feedmypixel committed Jan 20, 2025
1 parent f774e96 commit 3f3d808
Show file tree
Hide file tree
Showing 64 changed files with 2,069 additions and 973 deletions.
39 changes: 15 additions & 24 deletions src/__fixtures__/libraries.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
import { config } from '~/src/config/config.js'

const githubOrg = config.get('githubOrg')

// TODO update fixture once we have libraries
// Response from portalBackendApi/libraries
const librariesFixture = {
message: 'success',
libraries: [
{
id: 'cdp-node-frontend-library',
description: 'Core delivery platform npm library',
primaryLanguage: 'JavaScript',
url: `https://github.com/${githubOrg}/cdp-npm-library`,
isArchived: false,
isLibrary: true,
isPrivate: true,
createdAt: '2023-04-26T15:27:09+00:00',
teams: ['cdp-platform']
},
repositories: [
{
id: 'cdp-node-auth-library',
description: 'Core delivery platform auth library',
id: 'hapi-tracing',
description: 'Git repository for hapi-tracing',
primaryLanguage: 'JavaScript',
url: `https://github.com/${githubOrg}/cdp-auth-library`,
url: 'https://github.com/DEFRA/hapi-tracing',
isArchived: false,
isLibrary: true,
isPrivate: true,
createdAt: '2022-04-26T15:27:10+00:00',
teams: ['cdp-platform']
isTemplate: false,
isPrivate: false,
createdAt: '2024-12-09T13:08:51+00:00',
teams: [
{
github: 'cdp-platform',
teamId: 'aabe63e7-87ef-4beb-a596-c810631fc474',
name: 'Platform'
}
],
topics: ['cdp', 'repository', 'library']
}
]
}
Expand Down
30 changes: 16 additions & 14 deletions src/__fixtures__/library.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { config } from '~/src/config/config.js'

const githubOrg = config.get('githubOrg')

// TODO update fixture once we have libraries
// Response from portalBackendApi/libraries/cdp-node-frontend-library
// Response from portalBackendApi/libraries/hapi-tracing
const libraryFixture = {
message: 'success',
library: {
id: 'cdp-node-frontend-library',
description: 'Core delivery platform npm library',
repository: {
id: 'hapi-tracing',
description: 'Git repository for hapi-tracing',
primaryLanguage: 'JavaScript',
url: `https://github.com/${githubOrg}/cdp-npm-library`,
url: 'https://github.com/DEFRA/hapi-tracing',
isArchived: false,
isLibrary: true,
isPrivate: true,
createdAt: '2023-04-26T15:27:09+00:00',
teams: ['cdp-platform']
isTemplate: false,
isPrivate: false,
createdAt: '2024-12-09T13:08:51+00:00',
teams: [
{
github: 'cdp-platform',
teamId: 'aabe63e7-87ef-4beb-a596-c810631fc474',
name: 'Platform'
}
],
topics: ['cdp', 'repository', 'library']
}
}

Expand Down
26 changes: 12 additions & 14 deletions src/__fixtures__/template.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import { config } from '~/src/config/config.js'

const githubOrg = config.get('githubOrg')

// Response from portalBackendApi/templates/cdp-portal-frontend
// Response from portalBackendApi/templates/cdp-dotnet-backend-template
const templateFixture = {
message: 'success',
template: {
id: 'cdp-portal-frontend',
description: 'The Core Delivery Platform Portal.',
primaryLanguage: 'JavaScript',
url: `https://github.com/${githubOrg}/cdp-portal-frontend`,
repository: {
id: 'cdp-dotnet-backend-template',
description:
'C# ASP.NET Minimial API template with MongoDB, FluentValidation, Swagger and Serilog logging',
primaryLanguage: 'C#',
url: 'https://github.com/DEFRA/cdp-dotnet-backend-template',
isArchived: false,
isTemplate: false,
isPrivate: true,
createdAt: '2023-04-12T17:16:48+00:00',
isTemplate: true,
isPrivate: false,
createdAt: '2023-08-24T07:08:56+00:00',
teams: [
{
github: 'cdp-platform',
teamId: 'aabe63e7-87ef-4beb-a596-c810631fc474',
name: 'Platform'
}
]
],
topics: ['backend', 'cdp', 'dotnet', 'template']
}
}

Expand Down
73 changes: 54 additions & 19 deletions src/__fixtures__/templates.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,49 @@
import { config } from '~/src/config/config.js'

const githubOrg = config.get('githubOrg')

// Response from portalBackendApi/templates
const templatesFixture = {
message: 'success',
templates: [
repositories: [
{
id: 'cdp-dotnet-backend-template',
description:
'C# ASP.NET Minimial API template with MongoDB, FluentValidation, Swagger and Serilog logging',
primaryLanguage: 'C#',
url: 'https://github.com/DEFRA/cdp-dotnet-backend-template',
isArchived: false,
isTemplate: true,
isPrivate: false,
createdAt: '2023-08-24T07:08:56+00:00',
teams: [
{
github: 'cdp-platform',
teamId: 'aabe63e7-87ef-4beb-a596-c810631fc474',
name: 'Platform'
}
],
topics: ['backend', 'cdp', 'dotnet', 'template']
},
{
id: 'cdp-node-backend-template',
description: 'Core delivery platform Node.js Backend Template',
primaryLanguage: 'JavaScript',
url: 'https://github.com/DEFRA/cdp-node-backend-template',
isArchived: false,
isTemplate: true,
isPrivate: false,
createdAt: '2023-06-20T12:10:50+00:00',
teams: [
{
github: 'cdp-platform',
teamId: 'aabe63e7-87ef-4beb-a596-c810631fc474',
name: 'Platform'
}
],
topics: ['cdp', 'template', 'backend', 'node']
},
{
id: 'cdp-node-frontend-template',
description: 'Core delivery platform Node.js Frontend Template',
primaryLanguage: 'JavaScript',
url: `https://github.com/${githubOrg}/cdp-node-frontend-template`,
url: 'https://github.com/DEFRA/cdp-node-frontend-template',
isArchived: false,
isTemplate: true,
isPrivate: false,
Expand All @@ -21,42 +54,44 @@ const templatesFixture = {
teamId: 'aabe63e7-87ef-4beb-a596-c810631fc474',
name: 'Platform'
}
]
],
topics: ['cdp', 'frontend', 'node', 'template']
},
{
id: 'cdp-node-backend-template',
description: 'Core delivery platform Node.js Backend Template',
id: 'cdp-node-journey-test-suite-template',
description: 'Git repository for cdp-node-env-test-suite-template',
primaryLanguage: 'JavaScript',
url: `https://github.com/${githubOrg}/cdp-node-backend-template`,
url: 'https://github.com/DEFRA/cdp-node-journey-test-suite-template',
isArchived: false,
isTemplate: true,
isPrivate: false,
createdAt: '2023-06-20T12:10:50+00:00',
createdAt: '2024-01-24T14:49:52+00:00',
teams: [
{
github: 'cdp-platform',
teamId: 'aabe63e7-87ef-4beb-a596-c810631fc474',
name: 'Platform'
}
]
],
topics: ['cdp', 'template', 'test-suite', 'journey']
},
{
id: 'cdp-dotnet-backend-template',
description:
'C# ASP.NET Minimial API template with MongoDB, FluentValidation, Swagger and Serilog logging',
primaryLanguage: 'C#',
url: `https://github.com/${githubOrg}/cdp-dotnet-backend-template`,
id: 'cdp-perf-test-suite-template',
description: 'Git repository for cdp-perf-test-suite-template',
primaryLanguage: 'Shell',
url: 'https://github.com/DEFRA/cdp-perf-test-suite-template',
isArchived: false,
isTemplate: true,
isPrivate: false,
createdAt: '2023-08-24T07:08:56+00:00',
createdAt: '2024-04-17T12:10:51+00:00',
teams: [
{
github: 'cdp-platform',
teamId: 'aabe63e7-87ef-4beb-a596-c810631fc474',
name: 'Platform'
}
]
],
topics: ['cdp', 'repository', 'template', 'test-suite', 'performance']
}
]
}
Expand Down
14 changes: 12 additions & 2 deletions src/server/admin/features/controllers/features-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ import { transformFeaturesToEntityRows } from '~/src/server/admin/features/trans
const listFeaturesController = {
handler: async (request, h) => {
const featureToggles = await findAllFeatureToggles(request)
const entityRows = transformFeaturesToEntityRows(featureToggles)
const rows = transformFeaturesToEntityRows(featureToggles)

return h.view('admin/features/views/features-list', {
pageTitle: 'Admin - Feature Toggles',
entityRows
tableData: {
headers: [
{ id: 'feature', text: 'Feature', width: '15' },
{ id: 'status', text: 'Status', width: '10' },
{ id: 'activated', text: 'Activated', width: '10' },
{ id: 'actions', text: 'Actions', width: '20' }
],
rows,
noResult: 'No feature flags found'
}
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,58 @@ function transformFeaturesToEntityRows(features) {
}

function transformFeatureToEntityRow(feature) {
return [
{
kind: 'text',
value: feature.title
},
{
kind: 'text',
value: feature.enabled ? 'Active' : 'Not active'
},
...(feature.enabled
? [
{
kind: 'date',
value: feature.created
},
{
kind: 'button',
value: 'Deactivate',
url: feature.urlPrefix + '/delete',
classes: 'app-button--small app-button--destructive'
}
]
: [
{
kind: 'text',
value: noValue
},
{
kind: 'button',
value: 'Activate',
url: feature.urlPrefix,
classes: 'app-button--small'
}
])
]
return {
cells: [
{
headers: 'feature',
entity: { kind: 'text', value: feature.title }
},
{
headers: 'status',
entity: {
kind: 'text',
value: feature.enabled ? 'Active' : 'Not active'
}
},
...(feature.enabled
? [
{
headers: 'activated',
entity: {
kind: 'date',
value: feature.created
}
},
{
headers: 'actions',
entity: {
kind: 'button',
value: 'Deactivate',
url: feature.urlPrefix + '/delete',
classes: 'app-button--small app-button--destructive'
}
}
]
: [
{
headers: 'activated',
entity: {
kind: 'text',
value: noValue
}
},
{
headers: 'actions',
entity: {
kind: 'button',
value: 'Activate',
url: feature.urlPrefix,
classes: 'app-button--small'
}
}
])
]
}
}

export { transformFeaturesToEntityRows, transformFeatureToEntityRow }
Loading

0 comments on commit 3f3d808

Please sign in to comment.