Skip to content

Commit 0bd5596

Browse files
committed
rename NotificationsSettings --> NotificationsConfig
1 parent eadc28a commit 0bd5596

File tree

8 files changed

+62
-62
lines changed

8 files changed

+62
-62
lines changed

jupyter_scheduler/models.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class NotificationEvent(str, Enum):
2727
STOPPED = "Stopped"
2828

2929

30-
class NotificationsSettings(BaseModel):
31-
"""Represents settings for sending notifications.
30+
class NotificationsConfig(BaseModel):
31+
"""Represents configuration for notifications.
3232
3333
Attributes:
3434
send_to (List[str]): A list of symbols (e.g., email addresses) to which notifications should be sent.
@@ -117,7 +117,7 @@ class CreateJob(BaseModel):
117117
name: str
118118
output_filename_template: Optional[str] = OUTPUT_FILENAME_TEMPLATE
119119
compute_type: Optional[str] = None
120-
notifications_settings: Optional[NotificationsSettings] = None
120+
notifications_config: Optional[NotificationsConfig] = None
121121

122122
@root_validator
123123
def compute_input_filename(cls, values) -> Dict:
@@ -178,7 +178,7 @@ class DescribeJob(BaseModel):
178178
status: Status = Status.CREATED
179179
status_message: Optional[str] = None
180180
downloaded: bool = False
181-
notifications_settings: Optional[NotificationsSettings] = None
181+
notifications_config: Optional[NotificationsConfig] = None
182182

183183
class Config:
184184
orm_mode = True
@@ -243,7 +243,7 @@ class CreateJobDefinition(BaseModel):
243243
compute_type: Optional[str] = None
244244
schedule: Optional[str] = None
245245
timezone: Optional[str] = None
246-
notifications_settings: Optional[NotificationsSettings] = None
246+
notifications_config: Optional[NotificationsConfig] = None
247247

248248
@root_validator
249249
def compute_input_filename(cls, values) -> Dict:
@@ -269,7 +269,7 @@ class DescribeJobDefinition(BaseModel):
269269
create_time: int
270270
update_time: int
271271
active: bool
272-
notifications_settings: Optional[NotificationsSettings] = None
272+
notifications_config: Optional[NotificationsConfig] = None
273273

274274
class Config:
275275
orm_mode = True
@@ -289,7 +289,7 @@ class UpdateJobDefinition(BaseModel):
289289
active: Optional[bool] = None
290290
compute_type: Optional[str] = None
291291
input_uri: Optional[str] = None
292-
notifications_settings: Optional[NotificationsSettings] = None
292+
notifications_config: Optional[NotificationsConfig] = None
293293

294294

295295
class ListJobDefinitionsQuery(BaseModel):

src/components/notification-config.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,25 @@ export function NotificationsConfig(
4141
): JSX.Element | null {
4242
const trans = useTranslator('jupyterlab');
4343
const [selectedEvents, setSelectedEvents] = useState<string[]>(
44-
props.model.notificationsSettings?.selectedEvents || []
44+
props.model.notificationsConfig?.selectedEvents || []
4545
);
4646
const [enableNotification, setEnableNotification] = useState<boolean>(
47-
props.model.notificationsSettings?.enableNotification ?? true
47+
props.model.notificationsConfig?.enableNotification ?? true
4848
);
4949
const [sendToInput, setSendToInput] = useState<string>(
50-
props.model.notificationsSettings?.sendTo?.join(', ') || ''
50+
props.model.notificationsConfig?.sendTo?.join(', ') || ''
5151
);
5252
const [includeOutput, setIncludeOutput] = useState<boolean>(
53-
props.model.notificationsSettings?.includeOutput || false
53+
props.model.notificationsConfig?.includeOutput || false
5454
);
5555

5656
const enableNotificationChange = (e: React.ChangeEvent<HTMLInputElement>) => {
5757
const updatedEnableNotification = e.target.checked;
5858
setEnableNotification(updatedEnableNotification);
5959
props.handleModelChange({
6060
...props.model,
61-
notificationsSettings: {
62-
...props.model.notificationsSettings,
61+
notificationsConfig: {
62+
...props.model.notificationsConfig,
6363
enableNotification: updatedEnableNotification
6464
}
6565
});
@@ -73,8 +73,8 @@ export function NotificationsConfig(
7373
setSelectedEvents(updatedEvents);
7474
props.handleModelChange({
7575
...props.model,
76-
notificationsSettings: {
77-
...props.model.notificationsSettings,
76+
notificationsConfig: {
77+
...props.model.notificationsConfig,
7878
selectedEvents: updatedEvents
7979
}
8080
});
@@ -93,12 +93,12 @@ export function NotificationsConfig(
9393
.map(email => email.trim())
9494
.filter(email => email);
9595
const updatedNotification = {
96-
...props.model.notificationsSettings,
96+
...props.model.notificationsConfig,
9797
sendTo: emailArray
9898
};
9999
props.handleModelChange({
100100
...props.model,
101-
notificationsSettings: updatedNotification
101+
notificationsConfig: updatedNotification
102102
});
103103
}, [sendToInput, props.model, props.handleModelChange]);
104104

@@ -117,8 +117,8 @@ export function NotificationsConfig(
117117
setIncludeOutput(updatedValue);
118118
props.handleModelChange({
119119
...props.model,
120-
notificationsSettings: {
121-
...props.model.notificationsSettings,
120+
notificationsConfig: {
121+
...props.model.notificationsConfig,
122122
includeOutput: updatedValue
123123
}
124124
});
@@ -133,7 +133,7 @@ export function NotificationsConfig(
133133
props.handleModelChange({
134134
...props.model,
135135
notifications: {
136-
...props.model.notificationsSettings,
136+
...props.model.notificationsConfig,
137137
selectedEvents: updatedEvents
138138
}
139139
});

src/components/notification-detail.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import { useTranslator } from '../hooks';
55
import { Scheduler } from '../handler';
66
import { LabeledValue } from '../components/labeled-value';
77

8-
type INotificationsSettingsItemProps = {
8+
type INotificationsConfigItemProps = {
99
label: string;
1010
value: string | boolean;
1111
};
1212

13-
type INotificationsSettingsDetailsProps = {
14-
notificationsSettings: Scheduler.INotificationsSettings;
13+
type INotificationsConfigDetailsProps = {
14+
notificationsConfig: Scheduler.INotificationsConfig;
1515
};
1616

17-
function NotificationsSettingsItem(props: INotificationsSettingsItemProps) {
17+
function NotificationsConfigItem(props: INotificationsConfigItemProps) {
1818
const displayValue =
1919
typeof props.value === 'boolean'
2020
? props.value
@@ -31,8 +31,8 @@ function NotificationsSettingsItem(props: INotificationsSettingsItemProps) {
3131
);
3232
}
3333

34-
export function NotificationsSettingsDetails(
35-
props: INotificationsSettingsDetailsProps
34+
export function NotificationsConfigDetails(
35+
props: INotificationsConfigDetailsProps
3636
): JSX.Element {
3737
const trans = useTranslator('jupyterlab');
3838

@@ -44,8 +44,8 @@ export function NotificationsSettingsDetails(
4444
</FormLabel>
4545
<Stack spacing={2}>
4646
<FormLabel component="legend">{trans.__('Send to')}</FormLabel>
47-
{props.notificationsSettings.send_to.map((email, idx) => (
48-
<NotificationsSettingsItem
47+
{props.notificationsConfig.send_to.map((email, idx) => (
48+
<NotificationsConfigItem
4949
key={idx}
5050
label={trans.__(`Send to ${idx + 1}`)}
5151
value={email}
@@ -54,16 +54,16 @@ export function NotificationsSettingsDetails(
5454
<FormLabel component="legend">
5555
{trans.__('Notification Events')}
5656
</FormLabel>
57-
{props.notificationsSettings.events.map((event, idx) => (
58-
<NotificationsSettingsItem
57+
{props.notificationsConfig.events.map((event, idx) => (
58+
<NotificationsConfigItem
5959
key={idx}
6060
label={trans.__(`Event ${idx + 1}`)}
6161
value={event}
6262
/>
6363
))}
64-
<NotificationsSettingsItem
64+
<NotificationsConfigItem
6565
label={trans.__('Include output')}
66-
value={props.notificationsSettings.include_output}
66+
value={props.notificationsConfig.include_output}
6767
/>
6868
</Stack>
6969
</CardContent>

src/handler.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ export namespace Scheduler {
363363
compute_type?: string;
364364
schedule?: string;
365365
timezone?: string;
366-
notifications_settings?: INotificationsSettings;
366+
notifications_settings?: INotificationsConfig;
367367
}
368368

369369
export interface IUpdateJobDefinition {
@@ -372,7 +372,7 @@ export namespace Scheduler {
372372
timezone?: string;
373373
active?: boolean;
374374
input_uri?: string;
375-
notifications_settings?: INotificationsSettings;
375+
notifications_settings?: INotificationsConfig;
376376
}
377377

378378
export interface IDescribeJobDefinition {
@@ -391,7 +391,7 @@ export namespace Scheduler {
391391
create_time: number;
392392
update_time: number;
393393
active: boolean;
394-
notifications_settings?: INotificationsSettings;
394+
notifications_settings?: INotificationsConfig;
395395
}
396396

397397
export interface IEmailNotifications {
@@ -401,7 +401,7 @@ export namespace Scheduler {
401401
no_alert_for_skipped_rows: boolean;
402402
}
403403

404-
export interface INotificationsSettings {
404+
export interface INotificationsConfig {
405405
send_to: string[];
406406
events: string[];
407407
include_output: boolean;
@@ -424,7 +424,7 @@ export namespace Scheduler {
424424
output_filename_template?: string;
425425
output_formats?: string[];
426426
compute_type?: string;
427-
notifications_settings?: INotificationsSettings;
427+
notifications_settings?: INotificationsConfig;
428428
}
429429

430430
export interface ICreateJobFromDefinition {
@@ -473,7 +473,7 @@ export namespace Scheduler {
473473
start_time?: number;
474474
end_time?: number;
475475
downloaded: boolean;
476-
notifications_settings?: INotificationsSettings;
476+
notifications_settings?: INotificationsConfig;
477477
}
478478

479479
export interface ICreateJobResponse {

src/mainviews/create-job.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ export function CreateJob(props: ICreateJobProps): JSX.Element {
131131

132132
if (
133133
envList[0].notifications_enabled &&
134-
!props.model.notificationsSettings
134+
!props.model.notificationsConfig
135135
) {
136-
newModel.notificationsSettings = { enableNotification: true };
136+
newModel.notificationsConfig = { enableNotification: true };
137137
}
138138

139139
props.handleModelChange(newModel);
@@ -336,11 +336,11 @@ export function CreateJob(props: ICreateJobProps): JSX.Element {
336336
jobOptions.parameters = serializeParameters(props.model.parameters);
337337
}
338338

339-
if (props.model.notificationsSettings?.enableNotification) {
339+
if (props.model.notificationsConfig?.enableNotification) {
340340
jobOptions.notifications_settings = {
341-
send_to: props.model.notificationsSettings.sendTo ?? [],
342-
events: props.model.notificationsSettings.selectedEvents ?? [],
343-
include_output: props.model.notificationsSettings.includeOutput ?? false
341+
send_to: props.model.notificationsConfig.sendTo ?? [],
342+
events: props.model.notificationsConfig.selectedEvents ?? [],
343+
include_output: props.model.notificationsConfig.includeOutput ?? false
344344
};
345345
}
346346

@@ -391,11 +391,11 @@ export function CreateJob(props: ICreateJobProps): JSX.Element {
391391
);
392392
}
393393

394-
if (props.model.notificationsSettings?.enableNotification) {
394+
if (props.model.notificationsConfig?.enableNotification) {
395395
jobDefinitionOptions.notifications_settings = {
396-
send_to: props.model.notificationsSettings.sendTo ?? [],
397-
events: props.model.notificationsSettings.selectedEvents ?? [],
398-
include_output: props.model.notificationsSettings.includeOutput ?? false
396+
send_to: props.model.notificationsConfig.sendTo ?? [],
397+
events: props.model.notificationsConfig.selectedEvents ?? [],
398+
include_output: props.model.notificationsConfig.includeOutput ?? false
399399
};
400400
}
401401

src/mainviews/detail-view/job-definition.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from '../../components/labeled-value';
2424
import { JupyterFrontEnd } from '@jupyterlab/application';
2525
import { ListJobsTable } from '../list-jobs';
26-
import { NotificationsSettingsDetails } from '../../components/notification-detail';
26+
import { NotificationsConfigDetails } from '../../components/notification-detail';
2727
import { Scheduler as SchedulerTokens } from '../../tokens';
2828
import { SchedulerService } from '../../handler';
2929
import { timestampLocalize } from './job-detail';
@@ -289,9 +289,9 @@ export function JobDefinition(props: IJobDefinitionProps): JSX.Element {
289289
{DefinitionButtonBar}
290290
{JobDefinition}
291291
{JobsList}
292-
{props.model.notificationsSettings && (
293-
<NotificationsSettingsDetails
294-
notificationsSettings={props.model.notificationsSettings}
292+
{props.model.notificationsConfig && (
293+
<NotificationsConfigDetails
294+
notificationsConfig={props.model.notificationsConfig}
295295
/>
296296
)}
297297
{AdvancedOptions}

src/mainviews/detail-view/job-detail.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
} from '../../components/labeled-value';
2424
import { JobFileLink } from '../../components/job-file-link';
2525
import { JupyterFrontEnd } from '@jupyterlab/application';
26-
import { NotificationsSettingsDetails } from '../../components/notification-detail';
26+
import { NotificationsConfigDetails } from '../../components/notification-detail';
2727
import { Scheduler, SchedulerService } from '../../handler';
2828
import { Scheduler as SchedulerTokens } from '../../tokens';
2929
import { useEventLogger, useTranslator } from '../../hooks';
@@ -352,9 +352,9 @@ export function JobDetail(props: IJobDetailProps): JSX.Element {
352352
{JobButtonBar}
353353
{CoreOptions}
354354
{Parameters}
355-
{props.model.notificationsSettings && (
356-
<NotificationsSettingsDetails
357-
notificationsSettings={props.model.notificationsSettings}
355+
{props.model.notificationsConfig && (
356+
<NotificationsConfigDetails
357+
notificationsConfig={props.model.notificationsConfig}
358358
/>
359359
)}
360360
{AdvancedOptions}

src/model.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export type ModelWithScheduleFields = {
7474
scheduleMinute: string;
7575
};
7676

77-
export type NotificationsSettings = {
77+
export type NotificationsConfig = {
7878
sendTo?: string[];
7979
includeOutput?: boolean;
8080
enableNotification?: boolean;
@@ -107,7 +107,7 @@ export interface ICreateJobModel
107107
tags?: string[];
108108
// Is the create button disabled due to a submission in progress?
109109
createInProgress?: boolean;
110-
notificationsSettings?: NotificationsSettings;
110+
notificationsConfig?: NotificationsConfig;
111111
}
112112

113113
export const defaultScheduleFields: ModelWithScheduleFields = {
@@ -319,7 +319,7 @@ export interface IJobDetailModel {
319319
outputPrefix?: string;
320320
job_files: Scheduler.IJobFile[];
321321
downloaded: boolean;
322-
notificationsSettings?: Scheduler.INotificationsSettings;
322+
notificationsConfig?: Scheduler.INotificationsConfig;
323323
}
324324

325325
export interface IJobDefinitionModel {
@@ -346,7 +346,7 @@ export interface IJobDefinitionModel {
346346
startTime?: number;
347347
endTime?: number;
348348
outputPrefix?: string;
349-
notificationsSettings?: Scheduler.INotificationsSettings;
349+
notificationsConfig?: Scheduler.INotificationsConfig;
350350
}
351351

352352
const convertParameters = (parameters: {
@@ -396,7 +396,7 @@ export function convertDescribeJobtoJobDetail(
396396
startTime: describeJob.start_time,
397397
endTime: describeJob.end_time,
398398
downloaded: describeJob.downloaded,
399-
notificationsSettings: describeJob.notifications_settings
399+
notificationsConfig: describeJob.notifications_settings
400400
};
401401
}
402402

@@ -425,7 +425,7 @@ export function convertDescribeDefinitiontoDefinition(
425425
updateTime: describeDefinition.update_time,
426426
schedule: describeDefinition.schedule,
427427
timezone: describeDefinition.timezone,
428-
notificationsSettings: describeDefinition.notifications_settings
428+
notificationsConfig: describeDefinition.notifications_settings
429429
};
430430
}
431431

0 commit comments

Comments
 (0)