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

Incorporate requested UX changes to Snapshot Restore #333

Merged
merged 162 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
ede3cb1
Change alignment of Snapshot Management panels in pages/Main/Main.tsx
phestecAMZN Aug 24, 2022
a5fa7fb
Unify vertical button alignment across panels, ContentPanel.tsx
phestecAMZN Aug 24, 2022
6145593
Update jest snapshots, add ROUTE_STYLE variable
phestecAMZN Aug 24, 2022
f86a83f
Add placeholder restore button to Snapshots panel
phestecAMZN Aug 24, 2022
7a5545c
Merge branch 'opensearch-project:main' into main
phestecAMZN Aug 26, 2022
8001349
Comment out line 20 rollups_spec.js in cypress/integration/
phestecAMZN Aug 26, 2022
f27c4e4
Remove unused code and comment cypress/integration/rollups_spec.js
phestecAMZN Aug 26, 2022
cf0917a
Merge branch 'opensearch-project:main' into main
phestecAMZN Sep 1, 2022
391159f
Starting adaptation/use of existing code for Restore functionality
phestecAMZN Aug 29, 2022
983ed48
Adapt Snapshots.tsx to include RestoreSnapshotFlyout
phestecAMZN Aug 29, 2022
3558936
Add restoreSnapshot method to SMservice,RestoreSnapshotResponse int
phestecAMZN Aug 29, 2022
b3141bd
Implement RestoreSnapshotFlyout open/close
phestecAMZN Aug 29, 2022
7bfdb86
Make Snapshot name appear on RestoreSnapshotFlyout
phestecAMZN Aug 29, 2022
845cca2
Add/adapt restoreSnapshot to server/SnapshotManagementService
phestecAMZN Aug 29, 2022
703d93b
Add route for restoreSnapshot in server/routes.ts
phestecAMZN Aug 29, 2022
78095b7
Rudimentary restore from snapshot functionality reached, buggy
phestecAMZN Aug 29, 2022
e16528b
Fix index list-snapshot restore, restrict restore to single selection
phestecAMZN Aug 29, 2022
75e1dfe
Remove console.logs, commented out code
phestecAMZN Sep 6, 2022
02d651c
Create Advanced options accordion for Snapshot restore.
phestecAMZN Aug 30, 2022
bf4a4a5
Add initial restore/rename options to ui. Only visual functionality
phestecAMZN Aug 30, 2022
e8e46ea
Resolve radio button events not firing
phestecAMZN Aug 31, 2022
5cd9afc
Add AddPrefixInput, remove unused component RestoreSnapshotInitialOpt…
phestecAMZN Sep 1, 2022
a80656f
Fix issues with restore specific indices
phestecAMZN Sep 1, 2022
aa46d71
Begin cypress testing for snapshots
phestecAMZN Sep 1, 2022
3cf3711
Begin cypress testing Snapshots. Create repo and Create snapshot done
phestecAMZN Sep 2, 2022
b9ad019
Implement add_prefix functionality for snapshot restore
phestecAMZN Sep 2, 2022
fdfb43a
Implement rename indices option for restore snapshot
phestecAMZN Sep 2, 2022
5af4208
Remove console.logs, unusted variables in SnapshotFlyout, SMservice
phestecAMZN Sep 5, 2022
5cf239f
Add full stop to help text/errors, add RESTORE_OPTIONS enum
phestecAMZN Sep 7, 2022
934a27d
Add placeholder examples to rename options, add line breaks to help text
phestecAMZN Sep 7, 2022
81f99d7
Progress on custom index settings, ignore index settings
phestecAMZN Sep 7, 2022
3ebe37a
Implement custom index settings functionality
phestecAMZN Sep 8, 2022
6045bba
Successfully implement/debug custom index settings/ignore index setti…
phestecAMZN Sep 8, 2022
b3a0936
Progress on IndexList component, using cat.index.
phestecAMZN Sep 8, 2022
88bef4b
IndexList with pagination fully functional, todo: styling
phestecAMZN Sep 9, 2022
15f41a4
Add RestoreActivitiesPanel component folder, files (starter)
phestecAMZN Sep 9, 2022
366e5a5
Complete IndexList with pagination, sorting.
phestecAMZN Sep 9, 2022
70d56c8
Add maxWidth to RestoreSnapshotFlyout
phestecAMZN Sep 9, 2022
6a8a56c
Implement tabs on Snapshots page: Snapshots, Restore activities...
phestecAMZN Sep 10, 2022
2637b33
Merge branch 'opensearch-project:main' into main
phestecAMZN Sep 10, 2022
5e46117
Progress on catIndexRecovery, TODO - debug
phestecAMZN Sep 12, 2022
a08c1b4
Fix syntax bug - server/services/SnapshotManagementService.ts
phestecAMZN Sep 12, 2022
327d7da
Resolved some errors, getting a response but not correct response.
phestecAMZN Sep 12, 2022
fd77a64
Add back line 20 in rollups_spec, required by changes in 2.3 release.
phestecAMZN Sep 12, 2022
9caf86b
Implement code to use Index Recovery api. successful.
phestecAMZN Sep 12, 2022
efc525c
Current progress extracting data and displaying in Restore activities
phestecAMZN Sep 13, 2022
0a7f6ee
Implement Restore Activities with self updating until restore done
phestecAMZN Sep 13, 2022
c752956
Add clickable indexes link and hello world click handler
phestecAMZN Sep 13, 2022
988c9ef
Add toast if no snapshot selected upon restore activities click
phestecAMZN Sep 13, 2022
f35c282
Change danger toast to warning when no snapshot selected
phestecAMZN Sep 13, 2022
cc8afc6
Fix bug when both custom settings and ignore settings chosen
phestecAMZN Sep 13, 2022
1053f95
Add refresh button to restore activities page, remove auto refreshing
phestecAMZN Sep 13, 2022
fb7f19e
Remove unused getRepos func, add repo prop, trim state in RestoreFlyout
phestecAMZN Sep 15, 2022
f553dbe
Add increment to 2.3.0
phestecAMZN Sep 15, 2022
628e431
Remove index settings from options if none entered, RestoreFlyout
phestecAMZN Sep 15, 2022
09f57a8
Add rel="noopener noreferrer" to links in help text, use url from con…
phestecAMZN Sep 16, 2022
350f31a
Create CatSnapshotIndex in server/models/interfaces, apply in IndexList
phestecAMZN Sep 16, 2022
92d38f4
Add rel="noopener noreferrer" to links in IndexList, add CatSnapshotI…
phestecAMZN Sep 16, 2022
0532b0e
Changes to RestoreActivitesPanel to prep for listing indice
phestecAMZN Sep 16, 2022
653fc0d
Merge branch 'opensearch-project:main' into main
phestecAMZN Sep 16, 2022
5f4f5b5
Merge branch 'new_help_text' into help_text
phestecAMZN Sep 16, 2022
21f2bfc
Merge branch 'update_branch_to_latest' into index_list
phestecAMZN Sep 16, 2022
b185b41
Re do merge commit - forgot to save file.
phestecAMZN Sep 16, 2022
6d0a58b
Merge branch 'update_branch_to_latest' into index_settings
phestecAMZN Sep 16, 2022
44297f3
Merge branch 'update_branch_to_latest' into restore_activities
phestecAMZN Sep 16, 2022
4f4e5d6
Snapshots testing in progress
phestecAMZN Sep 18, 2022
ccca9bb
Current progress, cypress testing
phestecAMZN Sep 19, 2022
127f6c1
Add unit testing for AddPrefixInput, RenameInput components
phestecAMZN Sep 21, 2022
7ef5272
Add unit tests for SnapshotRenameOptions component
phestecAMZN Sep 21, 2022
e01c130
Add unit tests for SnapshotRestoreOption component
phestecAMZN Sep 21, 2022
0a78884
Add unit tests for SnapshotIndicesInput component
phestecAMZN Sep 22, 2022
9956737
Change 'Indices' to 'Index' if only 1 index.
phestecAMZN Sep 22, 2022
655b796
Replace anchor tags with EuiLinks set to external, rename options
phestecAMZN Sep 23, 2022
f862840
Change anchor tags to EuiLinks, IndexSettings
phestecAMZN Sep 23, 2022
02009be
Add rel attribute to EuiLink, IndexSettingsInput
phestecAMZN Sep 23, 2022
824c70f
Auto populate prefix field initially with "restored_"
phestecAMZN Sep 23, 2022
e397187
Merge branch 'pre_fill_prefix' into restore_activities
phestecAMZN Sep 23, 2022
1f1786e
Change Restore button to color="primary" (blue)
phestecAMZN Sep 23, 2022
2dba9dc
Make flyout close on restore, direct user to activities tab
phestecAMZN Sep 23, 2022
e248600
Title case flyout 'status', use EuiHealth for status color dot
phestecAMZN Sep 23, 2022
28ee07a
Add auto status check until 'DONE', RestoreActivities
phestecAMZN Sep 23, 2022
6d0ebd1
Add auto status update until 'SUCCESS', Snapshots panel
phestecAMZN Sep 23, 2022
0761ce1
Change tab implementation to be consistent with other plugins
phestecAMZN Sep 23, 2022
df492c5
Minor text and styling fixes, Snapshots panel
phestecAMZN Sep 26, 2022
a331d19
Fix styling to match main Snapshot page, RestoreFlyout
phestecAMZN Sep 26, 2022
e910c48
Update text to match mocks in Snapshots, RestoreSnapshotFlyout
phestecAMZN Sep 26, 2022
8c71551
Pre fill rename inputs, prefix input with default values from mock
phestecAMZN Sep 26, 2022
a7fa503
Change to title case for status in Restore activities panel
phestecAMZN Sep 26, 2022
12d08d0
Add warning banner if snapshot is partial, with checkbox to allow
phestecAMZN Sep 26, 2022
f8cd7b8
Fix behavior of IndexList, include size when active, else unknown
phestecAMZN Sep 27, 2022
20cad41
Merge branch 'index_list' into test_main
phestecAMZN Sep 27, 2022
af281e6
Functioning start/stop times in RestoreActivities
phestecAMZN Sep 27, 2022
7b794d4
Restore start/stop working. Auto updating working.
phestecAMZN Sep 27, 2022
9a436a9
Add EuiHealth to RestoreSnapshotFlyout
phestecAMZN Sep 28, 2022
e4e4193
Progress with restore monitoring, finally error free
phestecAMZN Sep 29, 2022
0b3c47d
Progress on restore/delete buttons correctly disabled edge cases
phestecAMZN Sep 29, 2022
d373b51
Add EuiOverlayMask when RestoreSnapshotFlyout active
phestecAMZN Sep 29, 2022
db1eb7d
Create user friendly error toasts with button to full error
phestecAMZN Sep 29, 2022
96890ae
Direct user to browser console for full error from error toasts
phestecAMZN Sep 29, 2022
018b5dd
Progress with restore success toast with button. Close
phestecAMZN Sep 30, 2022
8cf3fbd
Custom restore success toast with button to activities panel done
phestecAMZN Sep 30, 2022
1c3b254
Created custom error toast. Need to debug.
phestecAMZN Oct 1, 2022
bd60f93
Custom error and success toasts fully functional and error free.
phestecAMZN Oct 3, 2022
45577c7
Merge branch 'index_settings' into test_main
phestecAMZN Oct 3, 2022
9a7dd20
Add and debug Index Settings portion of Advanced Options. Successful.
phestecAMZN Oct 3, 2022
6936c8c
Merge branch 'help_text' into test_main
phestecAMZN Oct 3, 2022
5267c34
Remove stray console logs
phestecAMZN Oct 3, 2022
b178d96
Merge branch 'basic_integration' into test_main
phestecAMZN Oct 3, 2022
aed60fa
Add, update jest and cypress testing for snapshots & restore snapshots
phestecAMZN Oct 3, 2022
b04d870
Save small change snapshots_spec, forgot before prev commit
phestecAMZN Oct 3, 2022
2ba8b71
Merge branch 'main' of github.com:phestecAMZN/index-management-dashbo…
phestecAMZN Oct 4, 2022
b2f9132
Version bump 2.3.0 to 2.3 1
phestecAMZN Oct 4, 2022
98cc0ee
Add version bump 2.3.1 for OS in cypress-workflow.yml
phestecAMZN Oct 4, 2022
9315502
Remove 2.3.1 bump
phestecAMZN Oct 5, 2022
6609e8d
Merge branch 'main' of github.com:phestecAMZN/index-management-dashbo…
phestecAMZN Oct 6, 2022
f856c19
Change 2.3 to 2.3.0 cypress-workflow.yml
phestecAMZN Oct 7, 2022
db5918e
Change OSDB version to 2.3.1, opensearch_dashboards.json
phestecAMZN Oct 14, 2022
20e8c9e
Merge branch 'main' of github.com:phestecAMZN/index-management-dashbo…
phestecAMZN Oct 17, 2022
762c60d
Change 2.4 to 2.4.0 opensearch_dashboards.json
phestecAMZN Oct 17, 2022
d741039
Update for 2.4
phestecAMZN Oct 18, 2022
71bd131
Update help text, Snapshots.jsx
phestecAMZN Oct 18, 2022
c13a1d0
Merge branch 'main' of github.com:phestecAMZN/index-management-dashbo…
phestecAMZN Oct 18, 2022
d1a5a84
Remove Total size column from IndexList
phestecAMZN Oct 19, 2022
86e9c85
Disable restore if partial snapshot but not checked in banner
phestecAMZN Oct 19, 2022
fb0d869
Add status code and code meaning to toasts, error modal
phestecAMZN Oct 19, 2022
8cef14d
Progress making Restore activities panel independent
phestecAMZN Oct 19, 2022
c3022a3
RestoreActivitiesPanel no longer needs selected snapshot to access
phestecAMZN Oct 20, 2022
eeff511
Clean up unused code,console logs
phestecAMZN Oct 20, 2022
b03da8a
Modify error toasts to be more user friendly
phestecAMZN Oct 21, 2022
4fdab67
Merge branch 'main' of github.com:phestecAMZN/index-management-dashbo…
phestecAMZN Oct 21, 2022
88f6441
Handle bad regex input, handle bad JSON input, RestoreSnapshotFlyout
phestecAMZN Oct 21, 2022
8604d0a
Add check and toast for no indices selected, RestoreSnapshotFlyout
phestecAMZN Oct 22, 2022
eecb5fc
Remove unused interface, server/models/interfaces
phestecAMZN Oct 25, 2022
78040eb
Remove unused interface, console log.
phestecAMZN Oct 25, 2022
f729c39
Small style changes, RestoreSnapshotFlyout
phestecAMZN Oct 26, 2022
bad73ce
Merge branch 'main' of github.com:phestecAMZN/index-management-dashbo…
phestecAMZN Oct 26, 2022
ce07b21
Merge branch 'updated_main' into changes_copy
phestecAMZN Oct 27, 2022
72fe9d3
Resolve one missed conflict from previous merge
phestecAMZN Oct 27, 2022
5e9722b
Update snapshots_spec.js
phestecAMZN Oct 27, 2022
f2301d1
Remove unneeded cy.wait, snapshots_spec
phestecAMZN Oct 27, 2022
6582ad5
Fix small bug with refresh button, Restore activities panel
phestecAMZN Oct 27, 2022
1b7d215
Remove conflicts in server/models/interfaces
phestecAMZN Oct 27, 2022
b61ccec
Remove unused prop"ignore", change ternary to if() in toast helper
phestecAMZN Oct 27, 2022
20288f6
Change label text styling for radios and checkboxes in flyout
phestecAMZN Oct 28, 2022
cbbdce4
Create checkBoxLabel component in helper.jsx
phestecAMZN Oct 28, 2022
522cb27
Update jest snapshots for unit tests.
phestecAMZN Oct 28, 2022
acf0644
Remove default close button from Restore activities/indiceslist
phestecAMZN Oct 28, 2022
bf55375
Progress with regex validation, testing restore fail in progressd
phestecAMZN Oct 29, 2022
ba66e3e
Handle error case - bad connection - RestoreActivities
phestecAMZN Oct 31, 2022
c0c4ae8
Implement status for every index being restored, add to Indexlist.
phestecAMZN Oct 31, 2022
bf14908
Sort indexList alphabetically in RestoreActivities
phestecAMZN Oct 31, 2022
e9d91ae
Progress with form validation, RestoreSnapshotFlyout
phestecAMZN Nov 1, 2022
b6b3a49
All validations working on action click, RestoreSnapshotFlyout
phestecAMZN Nov 1, 2022
98e07c1
Refine validation ui on error, RestoreSnapshotFlyout
phestecAMZN Nov 1, 2022
1c49eca
Refine some toasts/errors
phestecAMZN Nov 1, 2022
4f0c6b4
Simplify toasts, make restore status more descriptive.
phestecAMZN Nov 2, 2022
3711075
Merge branch 'main' of github.com:phestecAMZN/index-management-dashbo…
phestecAMZN Nov 2, 2022
16638e9
Merge branch 'update_branch_november' into post_28_copy
phestecAMZN Nov 2, 2022
31a750b
Add interface "IndexItem", models/interfaces
phestecAMZN Nov 2, 2022
ad69d70
Remove missed console log, IndexList
phestecAMZN Nov 2, 2022
2b53c83
Update unit test snapshots
phestecAMZN Nov 2, 2022
7842df4
Update snapshots_spec to account for recent changes
phestecAMZN Nov 2, 2022
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/cypress-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches:
- "*"
env:
OPENSEARCH_DASHBOARDS_VERSION: '2.x'
OPENSEARCH_DASHBOARDS_VERSION: '2.4'
OPENSEARCH_VERSION: '2.4.0-SNAPSHOT'
jobs:
tests:
Expand Down
6 changes: 6 additions & 0 deletions cypress/integration/snapshots_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ describe("Snapshots", () => {

describe("Snapshot can be restored", () => {
it("Successfully restores indices from snapshot", () => {
// Must wait here before refreshing so snapshot status becomes 'success'
cy.wait(5000);

// Wait for snapshot to be created successfully
cy.get("button").contains("Refresh").click({ force: true });

// Select test snapshot
cy.get(`[data-test-subj="checkboxSelectRow-test_repo:test_snapshot"]`).check({ force: true });

Expand Down
29 changes: 27 additions & 2 deletions public/models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,20 @@ export interface Toast {
text?: JSX.Element;
}

export interface Column {
field: string;
name: string;
width: string;
truncateText?: boolean;
sortable: boolean;
}


export interface RestoreError {
reason?: string,
type?: string
reason?: string;
type?: string;
ok?: boolean;
error?: string;
}

export interface LatestActivities {
Expand Down Expand Up @@ -82,3 +93,17 @@ export enum RESTORE_OPTIONS {
customize_index_settings = "customize_index_settings",
ignore_index_settings = "ignore_index_settings",
}

export interface ModifiedStages {
START: string;
INIT: string;
INDEX: string;
VERIFY_INDEX: string;
TRANSLOG: string;
FINALIZE: string;
DONE: string;
}

export interface IndexItem {
index: string;
}
13 changes: 8 additions & 5 deletions public/pages/Snapshots/components/ErrorModal/ErrorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@

import { EuiModal, EuiText, EuiButton, EuiModalHeader, EuiModalFooter, EuiModalBody, EuiModalHeaderTitle } from "@elastic/eui";
import React from "react";
import { RestoreError } from "../../../../models/interfaces"


interface ErrorModalProps {
error: React.ErrorInfo;
onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
error: RestoreError;
snapshotId: string;
onClick: (event?: React.MouseEvent<HTMLButtonElement, MouseEvent> | React.KeyboardEvent<HTMLDivElement> | undefined) => void;
phestecAMZN marked this conversation as resolved.
Show resolved Hide resolved
phestecAMZN marked this conversation as resolved.
Show resolved Hide resolved
onClose: (event?: React.MouseEvent<HTMLButtonElement, MouseEvent> | React.KeyboardEvent<HTMLDivElement> | undefined) => void;
}

const ErrorModal = ({ onClick, error }: ErrorModalProps) => {
const ErrorModal = ({ onClick, error, snapshotId }: ErrorModalProps) => {

return (
<>
<EuiModal onClose={onClick}>
<EuiModalHeader color="danger" style={{ flexDirection: "column", alignItems: "flex-start" }}>
<EuiModalHeaderTitle><h1>{error.type}</h1></EuiModalHeaderTitle>
<EuiModalHeaderTitle><h1>{`Failed to restore snapshot ${snapshotId}`}</h1></EuiModalHeaderTitle>
</EuiModalHeader>

<EuiModalBody>
<EuiText size="m" color="danger">{error.reason}.</EuiText>
<EuiText size="m" color="danger">{error.reason ? error.reason : error}.</EuiText>
phestecAMZN marked this conversation as resolved.
Show resolved Hide resolved
</EuiModalBody>

<EuiModalFooter>
Expand Down
22 changes: 7 additions & 15 deletions public/pages/Snapshots/components/IndexList/IndexList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,19 @@

import { EuiInMemoryTable, EuiIcon, EuiFlyoutHeader, EuiTitle } from "@elastic/eui";
import React from "react";
import { CatSnapshotIndex } from "../../../../../server/models/interfaces";
import { Column } from "../../../../models/interfaces";
import { IndexItem } from "../../../../models/interfaces"

interface IndexListProps {
indices: CatSnapshotIndex[];
indices: IndexItem[];
snapshot: string;
title: string
columns: Column[];
onClick: (e: React.MouseEvent) => void;
}

const IndexList = ({ indices, snapshot, onClick, title }: IndexListProps) => {
indices = indices.filter((index) => index.index?.substring(0, 7) !== ".kibana");

const columns = [
{
field: "index",
name: "Index",
width: "100%",
truncateText: true,
sortable: true,
}
];
const IndexList = ({ indices, snapshot, onClick, title, columns }: IndexListProps) => {
indices = indices.filter((index) => index.index.substring(0, 7) !== ".kibana");

return (
<>
Expand All @@ -38,7 +30,7 @@ const IndexList = ({ indices, snapshot, onClick, title }: IndexListProps) => {
</EuiTitle>
</EuiFlyoutHeader>
<div style={{ padding: "1rem 1.5rem" }}>
<EuiInMemoryTable tableCaption="Indices" items={indices} columns={columns} tableLayout="auto" pagination={true} sorting={true} />
<EuiInMemoryTable tableCaption="Indices" items={indices} columns={columns} tableLayout="fixed" pagination={true} sorting={true} />
</div>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ import React, { useState, ChangeEvent } from "react";
import { RESTORE_SNAPSHOT_DOCUMENTATION_URL } from "../../../../utils/constants"

interface IndexSettingsInputProps {
getIndexSettings: (indexSettings: string) => void;
getIndexSettings: (indexSettings: string, ignore: boolean) => void;
showError: boolean;
inputError: string;
ignore: boolean;
}

const IndexSettingsInput = ({ getIndexSettings, ignore }: IndexSettingsInputProps) => {
const IndexSettingsInput = ({ getIndexSettings, ignore, showError, inputError }: IndexSettingsInputProps) => {
const [indexSettings, setIndexSettings] = useState("");

const onSettingsChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
setIndexSettings(e.target.value);
getIndexSettings(e.target.value);
getIndexSettings(e.target.value, ignore);
};

const title = ignore ? "Specify index settings to ignore" : "Specify custom index settings";
Expand All @@ -28,10 +30,8 @@ const IndexSettingsInput = ({ getIndexSettings, ignore }: IndexSettingsInputProp
? `Example: \nindex.refresh_interval,\nindex.max_script_fields `
: `Example: \n {\n\"index.number_of_replicas\": 0,\n\"index.auto_expand_replicas\": true\n}`;

return (
const indexSettingsLabel = (
<>
<EuiSpacer size="m" />

<EuiText size="xs">
<h4>{title}</h4>
</EuiText>
Expand All @@ -43,8 +43,15 @@ const IndexSettingsInput = ({ getIndexSettings, ignore }: IndexSettingsInputProp
</EuiLink>
</p>
</EuiText>
<EuiFormRow>
<EuiTextArea value={indexSettings} onChange={onSettingsChange} placeholder={placeholderText} />
</>
);

return (
<>
<EuiSpacer size="m" />

<EuiFormRow isInvalid={showError} error={inputError} label={indexSettingsLabel}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Not blocking for this PR, but I think we should use inputError as the condition for isInvalid, that way we can avoid having two separate fields for same purpose. Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isInvalid is stock Elastic ui prop for this component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is used in form validation to let it know when to add error styling.

<EuiTextArea value={indexSettings} onChange={onSettingsChange} placeholder={placeholderText} isInvalid={showError} />
</EuiFormRow>

<EuiSpacer size="m" />
Expand Down
72 changes: 41 additions & 31 deletions public/pages/Snapshots/components/RenameInput/RenameInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ import { RESTORE_SNAPSHOT_DOCUMENTATION_URL } from "../../../../utils/constants"
interface RenameInputProps {
getRenamePattern: (prefix: string) => void;
getRenameReplacement: (prefix: string) => void;
showPatternError: boolean;
showRenameError: boolean
}

const RenameInput = ({ getRenamePattern, getRenameReplacement }: RenameInputProps) => {
const RenameInput = ({ getRenamePattern, getRenameReplacement, showPatternError, showRenameError }: RenameInputProps) => {
const [renamePattern, setRenamePattern] = useState("(.+)");
const [renameReplacement, setRenameReplacement] = useState("restored_$1");
const badRenamePattern = "Please enter a valid Rename pattern.";
const badRenameReplacement = "Please enter a valid Rename replacement."
phestecAMZN marked this conversation as resolved.
Show resolved Hide resolved

const onPatternChange = (e: ChangeEvent<HTMLInputElement>) => {
setRenamePattern(e.target.value);
Expand All @@ -24,47 +28,53 @@ const RenameInput = ({ getRenamePattern, getRenameReplacement }: RenameInputProp
setRenameReplacement(e.target.value);
getRenameReplacement(e.target.value);
};
const patternText = `Define the format of renamed indices. Use $0 to include the \n
entire matching index name, $1 to include the content of the first\n
capture group, etc.`;

return (
<>
<EuiSpacer size="l" />
const renameText = `Define the format of renamed indices. Use $0 to include the\n
entire matching index name, $1 to include the content of the first\n
capture group, etc.`;

const patternLabel = (
<>
<EuiText size="xs">
<h4>Rename Pattern</h4>
</EuiText>
<EuiText size="xs" style={{ padding: "0px 0px 5px 0px" }}>
<p style={{ fontWeight: 200 }}>
Use regular expression to define how index names will be renamed.
<br />
By default, input (.+) to reuse the entire index name.{" "}
<EuiLink href={RESTORE_SNAPSHOT_DOCUMENTATION_URL} target="_blank" rel="noopener noreferrer" external={true}>
Learn more
</EuiLink>
</p>
<EuiText size="xs" style={{ padding: "0px 0px 5px 0px", fontWeight: "200" }}>
{patternText}{" "}
phestecAMZN marked this conversation as resolved.
Show resolved Hide resolved
<EuiLink href={RESTORE_SNAPSHOT_DOCUMENTATION_URL} target="_blank" rel="noopener noreferrer" external={true}>
Learn more
</EuiLink>
</EuiText>
<EuiFormRow>
<EuiFieldText value={renamePattern} onChange={onPatternChange} data-test-subj="renamePatternInput" />
</EuiFormRow>

<EuiSpacer size="m" />
</>
);

const renameLabel = (
<>
<EuiText size="xs">
<h4>Rename Replacement</h4>
</EuiText>
<EuiText size="xs" style={{ padding: "0px 0px 5px 0px" }}>
<p style={{ fontWeight: 200 }}>
Define the format of renamed indices. Use $0 to include the
<br />
entire matching index name, $1 to include the content of the first
<br />
capture group, etc.{" "}
<EuiLink href={RESTORE_SNAPSHOT_DOCUMENTATION_URL} target="_blank" rel="noopener noreferrer" external={true}>
Learn more
</EuiLink>
</p>
<EuiText size="xs" style={{ padding: "0px 0px 5px 0px", fontWeight: "200" }}>
{renameText}{" "}
<EuiLink href={RESTORE_SNAPSHOT_DOCUMENTATION_URL} target="_blank" rel="noopener noreferrer" external={true}>
Learn more
</EuiLink>
</EuiText>
<EuiFormRow>
<EuiFieldText value={renameReplacement} onChange={onReplacementChange} data-test-subj="renameReplacementInput" />
</>
);

return (
<>
<EuiSpacer size="l" />
<EuiFormRow error={badRenamePattern} isInvalid={showPatternError} label={patternLabel} >
<EuiFieldText value={renamePattern} onChange={onPatternChange} isInvalid={showPatternError} data-test-subj="renamePatternInput" />
</EuiFormRow>

<EuiSpacer size="m" />

<EuiFormRow error={badRenameReplacement} isInvalid={showRenameError} label={renameLabel}>
<EuiFieldText value={renameReplacement} onChange={onReplacementChange} isInvalid={showRenameError} data-test-subj="renameReplacementInput" />
</EuiFormRow>
</>
);
Expand Down
Loading