Skip to content

Commit

Permalink
Merge branch 'master' into technical/upgrade-js-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinovega committed Dec 6, 2023
2 parents 44b7cc7 + a834f9c commit 6016ddc
Show file tree
Hide file tree
Showing 112 changed files with 19,856 additions and 5,086 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -499,3 +499,23 @@ We'd like to thank all the contributors who worked on this release!

- evolutions are broken with mongoDB [#607](https://github.com/MAIF/daikoku/issues/607)

## [v16.3.4] - 2023-12-04

## :star: New Features

- Use otoroshi's elasticsearch to get api subscriptions last usage [#611](https://github.com/MAIF/daikoku/issues/611)
- create a link with the elasticsearch from an otoroshi [#593](https://github.com/MAIF/daikoku/issues/593)
- linked documentation pages [#588](https://github.com/MAIF/daikoku/issues/588)

## :heart: Contributors

We'd like to thank all the contributors who worked on this release!

- [@quentinovega](https://github.com/quentinovega)

## [v16.3.6] - 2023-12-04

## :beetle: Bug Fixes

- API Key metadata not refresh [#618](https://github.com/MAIF/daikoku/issues/618)

3 changes: 2 additions & 1 deletion daikoku/app/controllers/AdminApiController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import storage.drivers.postgres.PostgresDataStore
import storage.{DataStore, Repo}

import scala.concurrent.ExecutionContext
import scala.io.Source
import scala.util.{Failure, Success, Using}

class StateController(DaikokuAction: DaikokuAction,
Expand Down Expand Up @@ -616,7 +617,7 @@ class AdminApiSwaggerController(
ctrl1.pathForIntegrationApi()

def swagger() = Action {
Using(scala.io.Source.fromFile("./public/swaggers/admin-api-openapi.json")) {
Using(Source.fromResource("public/swaggers/admin-api-openapi.json")) {
source =>
source.mkString
} match {
Expand Down
3 changes: 2 additions & 1 deletion daikoku/app/controllers/TenantController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ class TenantController(DaikokuAction: DaikokuAction,
avatar = tenant.style.map(_.logo),
users = Set.empty,
authorizedOtoroshiGroups = Set.empty,
contact = tenant.contact
contact = tenant.contact,
apisCreationPermission = true.some
)
val adminApiPlan = FreeWithoutQuotas(
id = UsagePlanId(IdGenerator.token),
Expand Down
2 changes: 1 addition & 1 deletion daikoku/app/domain/CommonServices.scala
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ object CommonServices {
def allTeams(research: String, limit: Int, offset: Int)(implicit ctx: DaikokuActionContext[JsValue], env: Env, ec: ExecutionContext) = {
_TenantAdminAccessTenant(AuditTrailEvent("@{user.name} has accessed to all teams list"))(ctx) {
for {
teams <- env.dataStore.teamRepo.forTenant(ctx.tenant).findWithPagination(Json.obj("name" -> Json.obj("$regex" -> research)), offset, limit, Some(Json.obj("_humanReadableId" -> 1)))
teams <- env.dataStore.teamRepo.forTenant(ctx.tenant).findWithPagination(Json.obj("_deleted" -> false, "name" -> Json.obj("$regex" -> research)), offset, limit, Some(Json.obj("_humanReadableId" -> 1)))
} yield {
TeamWithCount(teams._1, teams._2)
}
Expand Down
9 changes: 9 additions & 0 deletions daikoku/app/jobs/OtoroshiVerifierJob.scala
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ class OtoroshiVerifierJob(client: OtoroshiClient,
.forAllTenant()
.findNotDeleted(query)
//Get just parent sub (childs will be processed after)
//FIXME: Rewrite the following 2 request in 1 with a proper sql request
adminApis <- env.dataStore.apiRepo
.forAllTenant()
.find(
Json.obj(
"visibility" -> ApiVisibility.AdminOnly.name
))
subscriptions <- env.dataStore.apiSubscriptionRepo
.forAllTenant()
.findNotDeleted(
Expand All @@ -314,6 +321,8 @@ class OtoroshiVerifierJob(client: OtoroshiClient,
.from(allSubscriptions.map(s =>
s.parent.map(_.asJson).getOrElse(s.id.asJson)))
.toSeq))))
.map(_.filterNot(sub =>
adminApis.flatMap(_.possibleUsagePlans).contains(sub.plan)))
} yield {
subscriptions.map(subscription => {
for {
Expand Down
14 changes: 7 additions & 7 deletions daikoku/javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion daikoku/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@dnd-kit/sortable": "7.0.2",
"@dnd-kit/utilities": "3.2.1",
"@fortawesome/fontawesome-free": "6.4.2",
"@maif/react-forms": "^1.6.1",
"@maif/react-forms": "^1.6.3",
"@popperjs/core": "^2.11.8",
"@tanstack/react-query": "5.4.3",
"@tanstack/react-table": "^8.10.7",
Expand Down
12 changes: 12 additions & 0 deletions daikoku/javascript/src/components/backoffice/apis/TeamApiInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { type, constraints, format, Schema } from '@maif/react-forms';
import * as Services from '../../../services';
import { I18nContext } from '../../../core';
import { AssetChooserByModal, MimeTypeFilter } from '../../../contexts/modals/AssetsChooserModal';
import { ITeamSimple } from '../../../types';

const Image = ({
value,
Expand Down Expand Up @@ -38,6 +39,17 @@ const Image = ({
);
};

const getTeams = (): Promise<Array<ITeamSimple>> => new Promise((resolve, reject) => {
setTimeout(() => {
const teams = [
{_id: '1', name: 'foo'},
{_id: '2', name: 'bar'},
{_id: '3', name: 'avengers'},
]//@ts-ignore
resolve(teams);
}, 300);
});

const reservedVersionCharacters = [';', '/', '?', ':', '@', '&', '=', '+', '$', ','];
export const teamApiInfoForm = (translate: any, team: any, tenant: any) => {
const schema: Schema = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import { getApolloContext } from "@apollo/client";
import { format, type } from "@maif/react-forms";
import { createColumnHelper } from '@tanstack/react-table';
import { useContext, useEffect, useRef, useState } from 'react';
import { useSelector } from 'react-redux';
import { toastr } from 'react-redux-toastr';
import {getApolloContext} from "@apollo/client";
import {format, type} from "@maif/react-forms";
import {createColumnHelper} from '@tanstack/react-table';
import {useContext, useEffect, useRef, useState} from 'react';
import {useSelector} from 'react-redux';
import {toastr} from 'react-redux-toastr';

import { ModalContext } from '../../../contexts';
import { CustomSubscriptionData } from '../../../contexts/modals/SubscriptionMetadataModal';
import { I18nContext } from '../../../core';
import {ModalContext} from '../../../contexts';
import {CustomSubscriptionData} from '../../../contexts/modals/SubscriptionMetadataModal';
import {I18nContext} from '../../../core';
import * as Services from '../../../services';
import { IApi, IState, ISubscriptionWithApiInfo, ITeamSimple, IUsagePlan, isError } from "../../../types";
import { SwitchButton, Table, TableRef } from '../../inputs';
import {IApi, isError, IState, ITeamSimple, IUsagePlan} from "../../../types";
import {SwitchButton, Table, TableRef} from '../../inputs';
import {
api as API,
BeautifulTitle,
Can,
Option,
Spinner,
formatDate,
formatPlanType,
manage,
Option,
queryClient,
Spinner,
} from '../../utils';
import { useQuery } from "@tanstack/react-query";
import {useQuery} from "@tanstack/react-query";

type TeamApiSubscriptionsProps = {
api: IApi,
Expand Down Expand Up @@ -125,36 +126,36 @@ export const TeamApiSubscriptions = ({ api }: TeamApiSubscriptionsProps) => {
return filters.clientIds.includes(subscription.apiKey.clientId)
}


return apiApiSubscriptions
.filter(filterByMetadata)
.filter(filterByTags)
.filter(filterByClientIds)
}
})
}
)
const lastUsagesQuery = useQuery({
queryKey: ['usages'],
queryFn: () => Services.getSubscriptionsLastUsages(api.team, subscriptionsQuery.data?.map(s => s._id) || [])
.then(lastUsages => {
if (isError(lastUsages)) {
return subscriptionsQuery.data as IApiSubscriptionGqlWithUsage[]
} else {
return (subscriptionsQuery.data ?? []).map(s => ({ ...s, lastUsage: lastUsages.find(u => u.subscription === s._id)?.date } as IApiSubscriptionGqlWithUsage))
}
}),
enabled: !!subscriptionsQuery.data && !isError(subscriptionsQuery.data)
.then((apiApiSubscriptions) => Services.getSubscriptionsLastUsages(api.team, subscriptionsQuery.data?.map(s => s._id) || [])
.then(lastUsages => {
if (isError(lastUsages)) {
return subscriptionsQuery.data as IApiSubscriptionGqlWithUsage[]
} else {
return (apiApiSubscriptions ?? [])
.map(s => ({
...s,
lastUsage: lastUsages.find(u => u.subscription === s._id)?.date
} as IApiSubscriptionGqlWithUsage));
}
}))
})

useEffect(() => {
document.title = `${currentTeam.name} - ${translate('Subscriptions')}`;
}, []);

useEffect(() => {
if (api && lastUsagesQuery.data) {
if (api && subscriptionsQuery.data) {
tableRef.current?.update()
}
}, [api, lastUsagesQuery.data])
}, [api, subscriptionsQuery.data])

useEffect(() => {
tableRef.current?.update()
Expand Down Expand Up @@ -288,7 +289,9 @@ export const TeamApiSubscriptions = ({ api }: TeamApiSubscriptionsProps) => {
const updateMeta = (sub: IApiSubscriptionGql) => openSubMetadataModal({
save: (updates: CustomSubscriptionData) => {
Services.updateSubscription(currentTeam, { ...sub, ...updates })
.then(() => tableRef.current?.update());
.then(() => {
queryClient.invalidateQueries(['subscriptions'])
});
},
api: sub.api._id,
plan: sub.plan._id,
Expand Down Expand Up @@ -406,10 +409,10 @@ export const TeamApiSubscriptions = ({ api }: TeamApiSubscriptionsProps) => {
defaultSort="name"
columns={columns(usagePlans)}
fetchItems={() => {
if (lastUsagesQuery.isLoading || lastUsagesQuery.error) {
if (subscriptionsQuery.isLoading || subscriptionsQuery.error) {
return []
} else {
return lastUsagesQuery.data ?? []
return subscriptionsQuery.data ?? []
}
}}
ref={tableRef}
Expand Down
2 changes: 1 addition & 1 deletion daikoku/version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ThisBuild / version := "16.4.0-dev"
version in ThisBuild := "16.4.0-dev"
6 changes: 3 additions & 3 deletions docs/devmanual/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<span class="home-icon"></span>Daikoku
</a>
<div class="version-number">
16.3.1
16.3.5
</div>
</div>
<div class="nav-toc">
Expand Down Expand Up @@ -126,7 +126,7 @@
<span class="home-icon"></span>Daikoku
</a>
<div class="version-number">
16.3.1
16.3.5
</div>
</div>
<div class="nav-toc">
Expand Down Expand Up @@ -366,7 +366,7 @@ <h2><a href="#rights-and-permissions-in-daikoku" name="rights-and-permissions-in
<script type="text/javascript" src="lib/prettify/prettify.js"></script>
<script type="text/javascript" src="lib/prettify/lang-scala.js"></script>
<script type="text/javascript">jQuery(function(){window.prettyPrint && prettyPrint()});</script>
<script type="text/javascript">jQuery(function(jq){initOldVersionWarnings(jq, '16.3.1', '')});</script>
<script type="text/javascript">jQuery(function(jq){initOldVersionWarnings(jq, '16.3.5', '')});</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/elasticlunr/0.9.5/elasticlunr.js"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-112498312-1"></script>
<script>
Expand Down
6 changes: 3 additions & 3 deletions docs/devmanual/adminusage/1-tenants.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<span class="home-icon"></span>Daikoku
</a>
<div class="version-number">
16.3.1
16.3.5
</div>
</div>
<div class="nav-toc">
Expand Down Expand Up @@ -126,7 +126,7 @@
<span class="home-icon"></span>Daikoku
</a>
<div class="version-number">
16.3.1
16.3.5
</div>
</div>
<div class="nav-toc">
Expand Down Expand Up @@ -350,7 +350,7 @@ <h3><a href="#display-mode" name="display-mode" class="anchor"><span class="anch
<script type="text/javascript" src="../lib/prettify/prettify.js"></script>
<script type="text/javascript" src="../lib/prettify/lang-scala.js"></script>
<script type="text/javascript">jQuery(function(){window.prettyPrint && prettyPrint()});</script>
<script type="text/javascript">jQuery(function(jq){initOldVersionWarnings(jq, '16.3.1', '')});</script>
<script type="text/javascript">jQuery(function(jq){initOldVersionWarnings(jq, '16.3.5', '')});</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/elasticlunr/0.9.5/elasticlunr.js"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-112498312-1"></script>
<script>
Expand Down
6 changes: 3 additions & 3 deletions docs/devmanual/adminusage/2-users.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<span class="home-icon"></span>Daikoku
</a>
<div class="version-number">
16.3.1
16.3.5
</div>
</div>
<div class="nav-toc">
Expand Down Expand Up @@ -126,7 +126,7 @@
<span class="home-icon"></span>Daikoku
</a>
<div class="version-number">
16.3.1
16.3.5
</div>
</div>
<div class="nav-toc">
Expand Down Expand Up @@ -318,7 +318,7 @@ <h2><a href="#impersonate-user" name="impersonate-user" class="anchor"><span cla
<script type="text/javascript" src="../lib/prettify/prettify.js"></script>
<script type="text/javascript" src="../lib/prettify/lang-scala.js"></script>
<script type="text/javascript">jQuery(function(){window.prettyPrint && prettyPrint()});</script>
<script type="text/javascript">jQuery(function(jq){initOldVersionWarnings(jq, '16.3.1', '')});</script>
<script type="text/javascript">jQuery(function(jq){initOldVersionWarnings(jq, '16.3.5', '')});</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/elasticlunr/0.9.5/elasticlunr.js"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-112498312-1"></script>
<script>
Expand Down
6 changes: 3 additions & 3 deletions docs/devmanual/adminusage/3-sessions.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<span class="home-icon"></span>Daikoku
</a>
<div class="version-number">
16.3.1
16.3.5
</div>
</div>
<div class="nav-toc">
Expand Down Expand Up @@ -126,7 +126,7 @@
<span class="home-icon"></span>Daikoku
</a>
<div class="version-number">
16.3.1
16.3.5
</div>
</div>
<div class="nav-toc">
Expand Down Expand Up @@ -298,7 +298,7 @@ <h2><a href="#admin-sessions" name="admin-sessions" class="anchor"><span class="
<script type="text/javascript" src="../lib/prettify/prettify.js"></script>
<script type="text/javascript" src="../lib/prettify/lang-scala.js"></script>
<script type="text/javascript">jQuery(function(){window.prettyPrint && prettyPrint()});</script>
<script type="text/javascript">jQuery(function(jq){initOldVersionWarnings(jq, '16.3.1', '')});</script>
<script type="text/javascript">jQuery(function(jq){initOldVersionWarnings(jq, '16.3.5', '')});</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/elasticlunr/0.9.5/elasticlunr.js"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-112498312-1"></script>
<script>
Expand Down
Loading

0 comments on commit 6016ddc

Please sign in to comment.