Skip to content

CORE-2017: multi-year and future subscriptions #623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/skaffold-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
call-workflow-passing-data:
uses: cyverse-de/github-workflows/.github/workflows/skaffold-build.yml@v0.0.7
uses: cyverse-de/github-workflows/.github/workflows/skaffold-build.yml@v0.1.9
with:
build-prerelease: ${{ contains(github.ref_name, '-rc') }}
secrets:
Expand Down
3 changes: 2 additions & 1 deletion public/static/locales/en/subscriptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,12 @@
"save": "Save",
"searchUsers": "Search Users",
"selectedUser": "Selected User",
"subAddonsUpdated": "Add-ons successfully updated.",
"startDate": "Start Date",
"subAddonsUpdated": "Add-ons successfully updated.",
"submit": "Submit",
"subscriptionAddonError": "Failed to submit add-on request.",
"subscriptionDetailsTabLabel": "Subscription Details",
"subscriptionPeriods": "Subscription Periods",
"subscriptionUpdated": "Subscription successfully updated.",
"true": "True",
"updateSubAddonError": "Failed to update subscription add-ons.",
Expand Down
34 changes: 32 additions & 2 deletions src/components/subscriptions/edit/EditSubscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { FastField, Field, Form, Formik } from "formik";
import { mapPropsToValues, formatSubscriptions } from "./formatters";

import DEDialog from "components/utils/DEDialog";
import { Button, MenuItem } from "@mui/material";
import { Button, Grid, MenuItem } from "@mui/material";

import FormCheckbox from "components/forms/FormCheckbox";
import FormNumberField from "components/forms/FormNumberField";
import FormTextField from "components/forms/FormTextField";
import { announce } from "components/announcer/CyVerseAnnouncer";
import { nonEmptyField } from "components/utils/validations";
import { minValue, nonEmptyField } from "components/utils/validations";

import ErrorTypographyWithDialog from "components/error/ErrorTypographyWithDialog";
import SubscriptionErrorHandler from "../error/SubscriptionErrorHandler";
Expand All @@ -25,6 +26,7 @@ import { useTranslation } from "i18n";
import ids from "../ids";
import Usages from "./Usages";
import { SUBSCRIPTIONS_QUERY_KEY } from "serviceFacades/subscriptions";
import FormTimestampField from "components/forms/FormTimestampField";

function EditSubscriptionDialog(props) {
const { open, onClose, parentId, subscription } = props;
Expand Down Expand Up @@ -228,6 +230,34 @@ function EditSubscriptionForm(props) {
))}
</FastField>

<Field
component={FormNumberField}
id={buildID(parentId, ids.EDIT_SUB_DLG.PERIODS)}
label={t("subscriptionPeriods")}
name="periods"
validate={(value) => minValue(value, i18nUtil)}
/>

<Grid container spacing={1}>
<Grid item>
<Field
name="start_date"
component={FormTimestampField}
helperText={t("startDate")}
id={buildID(parentId, ids.EDIT_SUB_DLG.START_DATE)}
/>
</Grid>

<Grid item>
<Field
name="end_date"
component={FormTimestampField}
helperText={t("endDate")}
id={buildID(parentId, ids.EDIT_SUB_DLG.END_DATE)}
/>
</Grid>
</Grid>

<Field
name="paid"
label={t("paid")}
Expand Down
13 changes: 12 additions & 1 deletion src/components/subscriptions/edit/formatters.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import dateConstants from "components/utils/dateConstants";

import { bytesInGiB, bytesToGiB } from "../utils";
import { formatDateObject } from "components/utils/DateFormatter";

export function mapPropsToValues(subscription) {
let values = {
Expand Down Expand Up @@ -31,13 +34,21 @@ export function mapPropsToValues(subscription) {
}

export function formatSubscriptions(values) {
const { username, paid, plan_name } = values;
const { username, paid, periods, plan_name, start_date, end_date } = values;

const submission = {
username,
plan_name,
paid,
periods,
start_date: start_date
? formatDateObject(new Date(start_date), dateConstants.ISO_8601)
: undefined,
end_date: end_date
? formatDateObject(new Date(end_date), dateConstants.ISO_8601)
: undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

};
console.log(submission);
return submission;
}

Expand Down
3 changes: 3 additions & 0 deletions src/components/subscriptions/ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ const ids = {
},

EDIT_SUB_DLG: {
END_DATE: "endDate",
PAID: "paid",
PERIODS: "subscriptionPeriods",
PLAN_NAME: "planName",
PLAN_TYPES: "planTypes",
QUOTAS: "quotas",
QUOTAS_RESOURCE_TYPE: "quotasResourceType",
START_DATE: "startDate",
USAGES: "usages",
USAGES_RESOURCE_TYPE: "usagesResourceType",
USERNAME: "username",
Expand Down