forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Discover] Deangularize Skip to bottom button (elastic#69811)
Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
Showing
8 changed files
with
159 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/plugins/discover/public/application/components/skip_bottom_button/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export { SkipBottomButton } from './skip_bottom_button'; | ||
export { createSkipBottomButtonDirective } from './skip_bottom_button_directive'; |
41 changes: 41 additions & 0 deletions
41
...ins/discover/public/application/components/skip_bottom_button/skip_bottom_button.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import React from 'react'; | ||
import { mountWithIntl } from 'test_utils/enzyme_helpers'; | ||
import { ReactWrapper } from 'enzyme'; | ||
import { SkipBottomButton, SkipBottomButtonProps } from './skip_bottom_button'; | ||
// @ts-ignore | ||
import { findTestSubject } from '@elastic/eui/lib/test'; | ||
|
||
describe('Skip to Bottom Button', function () { | ||
let props: SkipBottomButtonProps; | ||
let component: ReactWrapper<SkipBottomButtonProps>; | ||
|
||
beforeAll(() => { | ||
props = { | ||
onClick: jest.fn(), | ||
}; | ||
}); | ||
|
||
it('should be clickable', function () { | ||
component = mountWithIntl(<SkipBottomButton {...props} />); | ||
component.simulate('click'); | ||
expect(props.onClick).toHaveBeenCalled(); | ||
}); | ||
}); |
53 changes: 53 additions & 0 deletions
53
src/plugins/discover/public/application/components/skip_bottom_button/skip_bottom_button.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import React from 'react'; | ||
import { EuiSkipLink } from '@elastic/eui'; | ||
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react'; | ||
|
||
export interface SkipBottomButtonProps { | ||
/** | ||
* Action to perform on click | ||
*/ | ||
onClick: () => void; | ||
} | ||
|
||
export function SkipBottomButton({ onClick }: SkipBottomButtonProps) { | ||
return ( | ||
<I18nProvider> | ||
<EuiSkipLink | ||
size="s" | ||
// @ts-ignore | ||
onClick={(event) => { | ||
// prevent the anchor to reload the page on click | ||
event.preventDefault(); | ||
// The destinationId prop cannot be leveraged here as the table needs | ||
// to be updated first (angular logic) | ||
onClick(); | ||
}} | ||
className="dscSkipButton" | ||
destinationId="" | ||
> | ||
<FormattedMessage | ||
id="discover.skipToBottomButtonLabel" | ||
defaultMessage="Skip to end of table" | ||
/> | ||
</EuiSkipLink> | ||
</I18nProvider> | ||
); | ||
} |
23 changes: 23 additions & 0 deletions
23
...discover/public/application/components/skip_bottom_button/skip_bottom_button_directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import { SkipBottomButton } from './skip_bottom_button'; | ||
|
||
export function createSkipBottomButtonDirective(reactDirective: any) { | ||
return reactDirective(SkipBottomButton, [['onClick', { watchDepth: 'reference' }]]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters