Skip to content

Commit 9d625fe

Browse files
authored
Merge pull request #5887 from bcgov/fix/5881
fix(5881): remove Gold DR cluster from creation UI
2 parents 9bed7f4 + b26b7dd commit 9d625fe

File tree

9 files changed

+19
-16
lines changed

9 files changed

+19
-16
lines changed

app/app/analytics/private-cloud/ActiveProducts.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useSnapshot } from 'valtio';
22
import LineChartCard from '@/components/analytics/LineChartCard';
3-
import { clusters } from '@/constants';
3+
import { clustersWithoutDR } from '@/constants';
44
import { downloadPrivateCloudActiveProducts } from '@/services/backend/analytics/private-cloud';
55
import { ActiveProduct } from '@/types/analytics-private';
66
import { formatDate } from '@/utils/js/date';
@@ -19,7 +19,7 @@ export default function ActiveProducts({ data }: { data: ActiveProduct[] }) {
1919
startDate,
2020
)} to ${formatDate(endDate)}.`}
2121
chartData={data}
22-
categories={['All Clusters'].concat(pageSnapshot.clusters?.length ? pageSnapshot.clusters : clusters)}
22+
categories={['All Clusters'].concat(pageSnapshot.clusters?.length ? pageSnapshot.clusters : clustersWithoutDR)}
2323
onExport={() => downloadPrivateCloudActiveProducts({ data: { ...pageSnapshot } })}
2424
/>
2525
);

app/app/analytics/private-cloud/FilterPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useSnapshot } from 'valtio';
22
import FormDateRangePicker from '@/components/generic/select/FormDateRangePicker';
33
import FormMultiSelect from '@/components/generic/select/FormMultiSelect';
44
import FormUserPicker from '@/components/generic/select/FormUserPicker';
5-
import { clusters, ministryOptions } from '@/constants';
5+
import { clustersWithoutDR, ministryOptions } from '@/constants';
66
import { Cluster, Ministry } from '@/prisma/client';
77
import { pageState } from './state';
88

@@ -36,7 +36,7 @@ export default function FilterPanel() {
3636
name="cluster"
3737
label="Cluster"
3838
value={pageSnapshot.clusters ?? []}
39-
data={clusters.map((v) => ({ label: v, value: v }))}
39+
data={clustersWithoutDR.map((v) => ({ label: v, value: v }))}
4040
onChange={(value) => (pageState.clusters = value as Cluster[])}
4141
/>
4242
</div>

app/app/analytics/private-cloud/MinistryDistribution.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useSnapshot } from 'valtio';
22
import MultipleDoughnutChartCard from '@/components/analytics/MultipleDoughnutChartCard';
3-
import { clusters } from '@/constants';
3+
import { clustersWithoutDR } from '@/constants';
44
import { mapClusterData, transformMinistryData } from '@/helpers/ministry-data';
55
import { downloadPrivateCloudMinistryDistribution } from '@/services/backend/analytics/private-cloud';
66
import type { MinistryDistribution } from '@/types/analytics-private';
@@ -9,7 +9,7 @@ import { pageState } from './state';
99

1010
export default function MinistryDistribution({ data }: { data: MinistryDistribution[][] }) {
1111
const pageSnapshot = useSnapshot(pageState);
12-
const selectedClusters = pageSnapshot.clusters?.length ? pageSnapshot.clusters : clusters;
12+
const selectedClusters = pageSnapshot.clusters?.length ? pageSnapshot.clusters : clustersWithoutDR;
1313
const allClusterData = transformMinistryData(data[0]);
1414
const startDate = pageSnapshot.dates?.[0] ?? new Date('2023-04-01T00:00:00.000Z');
1515
const endDate = pageSnapshot.dates?.[1] ?? new Date();

app/app/api/private-cloud/products/_operations/create.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import prisma from '@/core/prisma';
33
import { OkResponse, UnauthorizedResponse } from '@/core/responses';
44
import generateLicencePlate from '@/helpers/licence-plate';
55
import { sendRequestNatsMessage } from '@/helpers/nats-message';
6-
import { DecisionStatus, ProjectStatus, RequestType, EventType, TaskType } from '@/prisma/client';
6+
import { DecisionStatus, ProjectStatus, RequestType, EventType, TaskType, Cluster } from '@/prisma/client';
77
import { sendCreateRequestEmails, sendRequestApprovalEmails } from '@/services/ches/private-cloud';
88
import { createEvent, models, privateCloudRequestDetailInclude, tasks } from '@/services/db';
99
import { PrivateCloudCreateRequestBody } from '@/validation-schemas/private-cloud';
@@ -41,6 +41,8 @@ export default async function createOp({ session, body }: { session: Session; bo
4141
...rest
4242
} = body;
4343

44+
if (rest.cluster === Cluster.GOLDDR) rest.cluster = Cluster.GOLD;
45+
4446
const productData = {
4547
...rest,
4648
licencePlate,

app/app/private-cloud/requests/all/FilterPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useSnapshot } from 'valtio';
22
import FormMultiSelect from '@/components/generic/select/FormMultiSelect';
3-
import { ministryOptions, clusters } from '@/constants';
3+
import { ministryOptions, clustersWithoutDR } from '@/constants';
44
import { Cluster, DecisionStatus, Ministry, Prisma, RequestType } from '@/prisma/client';
55
import { pageState } from './state';
66

@@ -24,7 +24,7 @@ export default function FilterPanel() {
2424
name="cluster"
2525
label="Cluster"
2626
value={pageSnapshot.clusters ?? []}
27-
data={[...clusters.map((v) => ({ label: v, value: v }))]}
27+
data={[...clustersWithoutDR.map((v) => ({ label: v, value: v }))]}
2828
onChange={(value) => {
2929
pageState.clusters = value as Cluster[];
3030
pageState.page = 1;

app/components/form/ProjectDescriptionPrivate.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import MailLink from '@/components/generic/button/MailLink';
1010
import HookFormTextarea from '@/components/generic/input/HookFormTextarea';
1111
import FormSelect from '@/components/generic/select/FormSelect';
1212
import HookFormSingleSelect from '@/components/generic/select/HookFormSingleSelect';
13-
import { clusters, ministryOptions, privateCloudTeamEmail } from '@/constants';
13+
import { clustersWithoutDR, ministryOptions, privateCloudTeamEmail } from '@/constants';
1414
import { cn } from '@/utils/js';
1515
import HookFormTextInput from '../generic/input/HookFormTextInput';
1616

@@ -30,15 +30,15 @@ export default function ProjectDescriptionPrivate({
3030
formState: { errors },
3131
} = useFormContext();
3232

33-
const [clustersList, setClustersList] = useState(clusters);
33+
const [clustersList, setClustersList] = useState(clustersWithoutDR);
3434

3535
const { data: session } = useSession({
3636
required: true,
3737
});
3838

3939
useEffect(() => {
4040
if (session && !session?.permissions.viewAllPrivateCloudProducts) {
41-
setClustersList(clusters.filter((cluster) => cluster.indexOf('LAB') === -1));
41+
setClustersList(clustersWithoutDR.filter((cluster) => cluster.indexOf('LAB') === -1));
4242
}
4343
}, [session, setClustersList]);
4444

app/constants/private-cloud.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { productSorts } from './common';
33

44
export const privateCloudProductMemberRoles = Object.values(PrivateCloudProductMemberRole);
55
export const clusters = Object.values(Cluster);
6+
export const clustersWithoutDR = Object.values(Cluster).filter((cluster) => cluster !== 'GOLDDR');
67

78
export const clusterNames = [
89
{

app/services/db/analytics/private-cloud/active-products.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import _uniq from 'lodash-es/uniq';
2-
import { clusters } from '@/constants';
2+
import { clustersWithoutDR } from '@/constants';
33
import prisma from '@/core/prisma';
44
import { Cluster, RequestType, DecisionStatus } from '@/prisma/client';
55
import { dateToShortDateString, shortDateStringToDate } from '@/utils/js';
@@ -80,7 +80,7 @@ async function productsCreatedPerMonth(
8080
export async function getActiveProducts({
8181
licencePlatesList,
8282
dateFilter = {},
83-
clustersOptions = clusters,
83+
clustersOptions = clustersWithoutDR,
8484
}: {
8585
licencePlatesList: string[];
8686
dateFilter?: Record<string, any>;

app/services/db/analytics/private-cloud/ministry-distributions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { clusters } from '@/constants';
1+
import { clustersWithoutDR } from '@/constants';
22
import prisma from '@/core/prisma';
33
import { Prisma } from '@/prisma/client';
44

@@ -48,7 +48,7 @@ export async function getMinistryDistributions({
4848

4949
const result = await Promise.all([
5050
getAggByCluster(licencePlatesList, undefined, dateFilter),
51-
...clusters.map((cluster) => getAggByCluster(licencePlatesList, cluster, dateFilter)),
51+
...clustersWithoutDR.map((cluster) => getAggByCluster(licencePlatesList, cluster, dateFilter)),
5252
]);
5353

5454
return result;

0 commit comments

Comments
 (0)