Skip to content

Commit

Permalink
Add to other api updates
Browse files Browse the repository at this point in the history
  • Loading branch information
RachelElysia committed Mar 13, 2024
1 parent 44e7085 commit 77b0686
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions frontend/__mocks__/configMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const DEFAULT_CONFIG_MOCK: IConfig = {
integrations: {
jira: [],
zendesk: [],
google_calendar: [],
},
logging: {
debug: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ const Calendars = (): JSX.Element => {

const validateForm = () => {
const errors: ICalendarsFormErrors = {};
if (!email) {

// Must set all keys or no keys at all
if (!email && (!!domain || !!privateKey)) {
errors.email = "Email must be present";
}
if (!domain) {
if (!domain && (!!email || !!privateKey)) {
errors.email = "Domain must be present";
}
if (!privateKey) {
if (!privateKey && (!!email || !!domain)) {
errors.privateKey = "Private key must be present";
}

Expand Down Expand Up @@ -99,7 +101,7 @@ const Calendars = (): JSX.Element => {
);
refetchConfig();
})
.catch( data: IApiError ) => {
.catch(() => {
renderFlash(
"error",
<>
Expand Down Expand Up @@ -127,6 +129,7 @@ const Calendars = (): JSX.Element => {
name="email"
value={email}
parseTarget
onBlur={validateForm}
tooltip={
<>
The email address for this Google
Expand All @@ -141,6 +144,7 @@ const Calendars = (): JSX.Element => {
name="domain"
value={domain}
parseTarget
onBlur={validateForm}
tooltip={
<>
The Google Workspace domain this <br /> service account is
Expand All @@ -152,9 +156,10 @@ const Calendars = (): JSX.Element => {
<InputField
label="Private key"
onChange={handleInputChange}
name="private key"
name="privateKey"
value={privateKey}
parseTarget
onBlur={validateForm}
tooltip={
<>
The private key for this Google <br /> Workspace service account.
Expand All @@ -180,9 +185,11 @@ const Calendars = (): JSX.Element => {
</p>
);
};

return (
<div className={`${baseClass}`}>
{isLoadingAppConfig ? <Spinner includeContainer={false} /> : renderForm()}
{isLoadingAppConfig && <Spinner includeContainer={false} />}
{renderForm()}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ const Integrations = (): JSX.Element => {
integrations: {
jira: integrations?.jira,
zendesk: zendeskIntegrations,
google_calendar: integrations?.google_calendar,
},
});
}
Expand All @@ -236,6 +237,7 @@ const Integrations = (): JSX.Element => {
integrations: {
zendesk: integrations?.zendesk,
jira: jiraIntegrations,
google_calendar: integrations?.google_calendar,
},
});
};
Expand Down Expand Up @@ -287,13 +289,15 @@ const Integrations = (): JSX.Element => {
integrations: {
jira: integrationSubmitData,
zendesk: zendeskIntegrations,
google_calendar: integrations?.google_calendar,
},
});
}
return configAPI.update({
integrations: {
zendesk: integrationSubmitData,
jira: jiraIntegrations,
google_calendar: integrations?.google_calendar,
},
});
};
Expand Down Expand Up @@ -416,7 +420,9 @@ const Integrations = (): JSX.Element => {
onCancel={toggleAddIntegrationModal}
onSubmit={onAddSubmit}
backendValidators={backendValidators}
integrations={integrations || { jira: [], zendesk: [] }}
integrations={
integrations || { jira: [], zendesk: [], google_calendar: [] }
}
testingConnection={testingConnection}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ const ManagePolicyAutomationsModal = ({
webhook_settings: { failing_policies_webhook: webhook },
} = automationsConfig;

const { jira, zendesk } = availableIntegrations || {};
const { jira, zendesk, google_calendar: googleCalendar } =
availableIntegrations || {};
const allIntegrations: IIntegration[] = [];
jira && allIntegrations.push(...jira);
zendesk && allIntegrations.push(...zendesk);
Expand Down Expand Up @@ -263,6 +264,7 @@ const ManagePolicyAutomationsModal = ({
integrations: {
jira: newJira,
zendesk: newZendesk,
google_calendar: googleCalendar,
},
});

Expand Down

0 comments on commit 77b0686

Please sign in to comment.