1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

feat: remove applications from project list that do not exist (#6377)

This commit is contained in:
Jaanus Sellin 2024-02-28 16:26:53 +02:00 committed by GitHub
parent 4392fa5890
commit df93827002
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 35 additions and 2 deletions

View File

@ -10,6 +10,11 @@ const StyledTag = styled('div')(({ theme }) => ({
fontSize: theme.fontSizes.smallerBody,
}));
const StyledList = styled('ul')(({ theme }) => ({
padding: theme.spacing(0, 0, 0.5, 2),
margin: theme.spacing(0),
}));
interface ISdkCellProps {
row: {
original: ProjectApplicationSchema;
@ -42,7 +47,7 @@ export const SdkCell: VFC<ISdkCellProps> = ({ row }) => {
<Highlighter search={searchQuery}>
{sdk.name}
</Highlighter>
<ul>
<StyledList>
{sdk.versions.map((version) => (
<li key={version}>
<Highlighter search={searchQuery}>
@ -50,7 +55,7 @@ export const SdkCell: VFC<ISdkCellProps> = ({ row }) => {
</Highlighter>
</li>
))}
</ul>
</StyledList>
</StyledTag>
))}
</>

View File

@ -56,6 +56,7 @@ beforeAll(async () => {
afterEach(async () => {
await db.stores.clientMetricsStoreV2.deleteAll();
await db.stores.clientInstanceStore.deleteAll();
await db.stores.clientApplicationsStore.deleteAll();
await db.stores.featureToggleStore.deleteAll();
});
@ -388,3 +389,25 @@ test('should show correct number of total', async () => {
total: 2,
});
});
test('should not show if metrics exist, but application does not', async () => {
await app.createFeature('toggle-name-1');
await app.request
.post('/api/client/metrics')
.set('Authorization', defaultToken.secret)
.send(metrics)
.expect(202);
await app.services.clientMetricsServiceV2.bulkAdd();
const { body } = await app.request
.get('/api/admin/projects/default/applications?sortOrder=desc&limit=1')
.expect('Content-Type', /json/)
.expect(200);
expect(body).toMatchObject({
applications: [],
total: 0,
});
});

View File

@ -614,6 +614,11 @@ class ProjectStore implements IProjectStore {
),
)
.from('applications as a')
.innerJoin(
'client_applications as ca',
'a.app_name',
'ca.app_name',
)
.leftJoin('client_instances as ci', function () {
this.on('ci.app_name', '=', 'a.app_name').andOn(
'ci.environment',