Skip to content
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

Snapshot management small fixes #208

Merged
merged 13 commits into from
Jun 28, 2022
3 changes: 2 additions & 1 deletion models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ export interface SMSnapshotConfig {
ignore_unavailable?: boolean;
include_global_state?: boolean;
partial?: boolean;
date_expression?: string;
date_format?: string;
date_format_timezone?: string;
}

export interface SMCreation {
Expand Down
4 changes: 2 additions & 2 deletions public/index_management_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Main from "./pages/Main";
import { CoreServicesContext } from "./components/core_services";
import "./app.scss";

export function renderApp(coreStart: CoreStart, params: AppMountParameters) {
export function renderApp(coreStart: CoreStart, params: AppMountParameters, landingPage: string) {
const http = coreStart.http;

const indexService = new IndexService(http);
Expand Down Expand Up @@ -51,7 +51,7 @@ export function renderApp(coreStart: CoreStart, params: AppMountParameters) {
<DarkModeContext.Provider value={isDarkMode}>
<ServicesContext.Provider value={services}>
<CoreServicesContext.Provider value={coreStart}>
<Main {...props} />
<Main {...props} landingPage={landingPage} />
</CoreServicesContext.Provider>
</ServicesContext.Provider>
</DarkModeContext.Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface CronScheduleProps {
timezone?: string;
onChangeTimezone?: (timezone: string) => void;
timezoneError?: string;
frequencyTitle?: string;
}

const CronSchedule = ({
Expand All @@ -45,6 +46,7 @@ const CronSchedule = ({
timezone,
onChangeTimezone,
timezoneError,
frequencyTitle = "Schedule frequency",
}: CronScheduleProps) => {
const { minute: initMin, hour: initHour, dayOfWeek: initWeek, dayOfMonth: initMonth } = parseCronExpression(cronExpression);

Expand Down Expand Up @@ -152,7 +154,7 @@ const CronSchedule = ({

return (
<>
<CustomLabel title="Schedule frequency" />
<CustomLabel title={frequencyTitle} />
<EuiSelect id="creationCronScheduleType" options={CRON_SCHEDULE_FREQUENCY_TYPE} value={frequencyType} onChange={onTypeChange} />

<EuiSpacer size="m" />
Expand All @@ -161,13 +163,15 @@ const CronSchedule = ({
<EuiFlexItem style={{ maxWidth: 400 }}>
{frequencyType === "custom" ? (
<>
<CustomLabel title="Cron expression" helpText={cronExpressionHelpText} />
<EuiFieldText
value={cronExpression}
onChange={(e) => {
onCronExpressionChange(e.target.value);
}}
/>
<CustomLabel title="Cron expression" />
<EuiFormRow helpText={cronExpressionHelpText}>
<EuiFieldText
value={cronExpression}
onChange={(e) => {
onCronExpressionChange(e.target.value);
}}
/>
</EuiFormRow>
</>
) : (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React, { ChangeEvent } from "react";
import { EuiFormRow, EuiSelect, EuiButton, EuiFlexGroup, EuiFlexItem } from "@elastic/eui";
import "brace/theme/github";
import "brace/mode/json";
import { FeatureChannelList } from "../../../../../server/models/interfaces";
import CustomLabel from "../../../../components/CustomLabel";

interface NotificationProps {
channelId: string;
channels: FeatureChannelList[];
loadingChannels: boolean;
onChangeChannelId: (value: ChangeEvent<HTMLSelectElement>) => void;
getChannels: () => void;
}

const Notification = ({ channelId, channels, loadingChannels, onChangeChannelId, getChannels }: NotificationProps) => {
return (
<>
<CustomLabel title="Select notification channels" />
<EuiFlexGroup gutterSize="s" style={{ maxWidth: 600 }}>
<EuiFlexItem>
<EuiFormRow>
<EuiSelect
id="channel-id"
placeholder="Select channel ID"
hasNoInitialSelection
isLoading={loadingChannels}
options={channels.map((channel) => ({ value: channel.config_id, text: channel.name }))}
value={channelId}
onChange={onChangeChannelId}
data-test-subj="create-policy-notification-channel-id"
/>
</EuiFormRow>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton
iconType="refresh"
onClick={getChannels}
disabled={loadingChannels}
className="refresh-button"
data-test-subj="channel-notification-refresh"
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton iconType="popout" href="notifications-dashboards#/channels" target="_blank">
Manage channels
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</>
);
};

export default Notification;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import Notification from "./Notification";

export default Notification;
7 changes: 5 additions & 2 deletions public/pages/CreateSnapshotPolicy/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const getDefaultSMPolicy = (): SMPolicy => ({
schedule: {
cron: {
expression: "0 20 * * *",
timezone: "America/Los_Angeles",
timezone: "UTC",
},
},
},
Expand All @@ -34,10 +34,13 @@ export const maxAgeUnitOptions = [
{ value: "h", text: "Hours" },
];

export const DEFAULT_INDEX_OPTIONS = [{ label: "*" }, { label: "-.opendistro_security" }];
export const DEFAULT_INDEX_OPTIONS = [{ label: "*" }];

export const ERROR_PROMPT = {
NAME: "Name must be provided.",
REPO: "Repository must be provided.",
TIMEZONE: "Time zone must be provided.",
};

export const DEFAULT_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
export const DEFAULT_DATE_FORMAT_TIMEZONE = "UTC";
Loading