Skip to content

Commit

Permalink
feat #728: Aggregation Mode for Validation date
Browse files Browse the repository at this point in the history
  • Loading branch information
helakaraa committed Sep 12, 2024
1 parent d8e480b commit 0b12f59
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ interface IApiSubscriptionGql extends ISubscriptionCustomization {
_id: string;
adminCustomName: string;
enabled: boolean;
validUntil: string;
api: {
_id: string;
name: string;
Expand Down Expand Up @@ -196,7 +197,6 @@ export const TeamApiSubscriptions = ({
tableRef.current?.update();
}
}, [api, subscriptionsQuery.data]);

useEffect(() => {
tableRef.current?.update();
}, [filters]);
Expand All @@ -211,6 +211,7 @@ export const TeamApiSubscriptions = ({
meta: { style: { textAlign: "left" } },
filterFn: (row, _, value) => {
const sub = row.original;

const displayed: string =
sub.team._id === currentTeam._id
? sub.customName || sub.apiKey.clientName
Expand All @@ -223,7 +224,7 @@ export const TeamApiSubscriptions = ({
sortingFn: "basic",
cell: (info) => {
const sub = info.row.original;
const titleDate = `<div>
let titleDate = `<div>
<strong>${translate("validationDate.apikey.badge.title")}</strong> :
${sub.validUntil ? formatDate(sub.validUntil, language) : "N/A"}
</div>`;
Expand All @@ -236,6 +237,10 @@ export const TeamApiSubscriptions = ({
<li>${translate("aggregated.apikey.badge.apikey.name")}: ${sub.parent.adminCustomName}</li>
</ul>
</div>`;
titleDate = `<div>
<strong>${translate("validationDate.apikey.badge.title")}</strong> :
${sub.parent.validUntil ? formatDate(sub.parent.validUntil, language) : "N/A"}
</div>`;
return (
<div className="d-flex flex-row justify-content-between">
<span>{info.getValue()}</span>
Expand Down Expand Up @@ -386,8 +391,8 @@ export const TeamApiSubscriptions = ({
}),
];

const updateMeta = (sub: IApiSubscriptionGql) =>
openSubMetadataModal({
const updateMeta = (sub: IApiSubscriptionGql) => {
return openSubMetadataModal({
save: (updates: CustomSubscriptionData) => {
Services.updateSubscription(currentTeam, { ...sub, ...updates }).then(
() => {
Expand All @@ -404,6 +409,7 @@ export const TeamApiSubscriptions = ({
(p) => sub.plan._id === p._id
)!,
});
};

const regenerateApiKeySecret = useMutation({
mutationFn: (sub: IApiSubscriptionGql) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const SubscriptionMetadataModal = <T extends IWithTesting>(
}
};

const schema = {
let schema = {
customMetadata: {
type: type.object,
label: translate("Additional metadata"),
Expand Down Expand Up @@ -119,12 +119,15 @@ export const SubscriptionMetadataModal = <T extends IWithTesting>(
label: translate("sub.meta.modal.admin.custom.name.label"),
help: translate("sub.meta.modal.admin.custom.name.help"),
},
validUntil: {
};

if (!props.subscription?.parent) {
schema["validUntil"] = {
type: type.date,
label: translate("sub.meta.modal.valid.until.label"),
help: translate("sub.meta.modal.valid.until.help"),
},
};
};
}

const mandatoryMetadataSchema = (plan?: IUsagePlan) => ({
metadata: {
Expand Down Expand Up @@ -218,7 +221,6 @@ export const SubscriptionMetadataModal = <T extends IWithTesting>(
},
[[], []]
);

const value = {
metadata: Object.fromEntries(maybeMetadata),
customMetadata: Object.fromEntries(maybeCustomMetadata),
Expand Down
1 change: 1 addition & 0 deletions daikoku/javascript/src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,7 @@ export const graphql = {
_id
adminCustomName
enabled
validUntil
api {
_id
name
Expand Down
5 changes: 3 additions & 2 deletions daikoku/javascript/src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ export interface IBaseSubscription {
team: string;
api: string;
createdAt: string;
validUntil: string;
validUntil?: string;
by: string;
customName: string | null;
enabled: boolean;
Expand Down Expand Up @@ -443,7 +443,8 @@ export interface ISubscriptionCustomization {
customMaxPerDay?: number;
customReadOnly?: boolean;
adminCustomName?: string;
validUntil: string;
validUntil?: string;
parent : string | null;
}

export interface ISubscriptionExtended extends ISubscription {
Expand Down

0 comments on commit 0b12f59

Please sign in to comment.