Unverified Commit 506cf6d6 authored by Tao Feng's avatar Tao Feng Committed by GitHub

feat: redirect dashboard group to search filter after clicking (#655)

Signed-off-by: 's avatarTao Feng <fengtao04@gmail.com>
parent ee0474fd
......@@ -99,8 +99,8 @@ exports[`strict null compilation`] = {
[255, 6, 11, "No overload matches this call.\\n The last overload gave the following error.\\n Type \'(() => SubmitSearchRequest) | null\' is not assignable to type \'ActionCreator<any>\'.\\n Type \'null\' is not assignable to type \'ActionCreator<any>\'.", "2296208050"],
[270, 4, 18, "No overload matches this call.\\n The last overload gave the following error.\\n Argument of type \'(dispatch: any, ownProps: any) => ActionCreator<unknown>\' is not assignable to parameter of type \'DispatchFromProps\'.\\n Type \'(dispatch: any, ownProps: any) => ActionCreator<unknown>\' is missing the following properties from type \'DispatchFromProps\': submitSearch, onInputChange, onSelectInlineResult", "2926224796"]
],
"js/components/common/Table/index.tsx:2645527205": [
[190, 22, 13, "Type \'unknown\' is not assignable to type \'ReactNode\'.\\n Type \'unknown\' is not assignable to type \'ReactPortal\'.", "971959308"]
"js/components/common/Table/index.tsx:2588109192": [
[189, 22, 13, "Type \'unknown\' is not assignable to type \'ReactNode\'.\\n Type \'unknown\' is not assignable to type \'ReactPortal\'.", "971959308"]
],
"js/components/common/Tags/TagInput/index.tsx:3754832290": [
[63, 22, 6, "Type \'undefined\' is not assignable to type \'GetAllTagsRequest\'.", "1979467425"],
......@@ -265,10 +265,10 @@ exports[`strict null compilation`] = {
"js/pages/DashboardPage/DashboardOwnerEditor/index.spec.tsx:4125678807": [
[29, 19, 11, "Type \'{ manager_id: null; manager_fullname: null; manager_email: null; profile_url: string; role_name: null; display_name: null; github_username: null; team_name: null; last_name: null; full_name: null; ... 6 more ...; user_id: string; }\' is not assignable to type \'User\'.\\n Types of property \'display_name\' are incompatible.\\n Type \'null\' is not assignable to type \'string\'.", "2041815528"]
],
"js/pages/DashboardPage/index.spec.tsx:644863281": [
"js/pages/DashboardPage/index.spec.tsx:3245519479": [
[53, 4, 8, "Argument of type \'Partial<Location<{} | null | undefined>> | undefined\' is not assignable to parameter of type \'Partial<Location<{} | null | undefined>>\'.\\n Type \'undefined\' is not assignable to type \'Partial<Location<{} | null | undefined>>\'.", "2700611480"],
[212, 10, 18, "Type \'null\' is not assignable to type \'number\'.", "2901767208"],
[213, 10, 29, "Type \'null\' is not assignable to type \'number\'.", "1157138603"]
[213, 10, 18, "Type \'null\' is not assignable to type \'number\'.", "2901767208"],
[214, 10, 29, "Type \'null\' is not assignable to type \'number\'.", "1157138603"]
],
"js/pages/ProfilePage/index.spec.tsx:4086464143": [
[41, 6, 4, "Argument of type \'null\' is not assignable to parameter of type \'Partial<Location<{} | null | undefined>>\'.", "2087897566"]
......
......@@ -36,7 +36,7 @@ export type FilterOptions = { [id: string]: boolean };
export interface FilterReducerState {
[ResourceType.dashboard]?: ResourceFilterReducerState;
[ResourceType.table]: ResourceFilterReducerState;
[ResourceType.table]?: ResourceFilterReducerState;
}
export interface ResourceFilterReducerState {
......
......@@ -58,6 +58,7 @@ const setup = (
statusCode: 200,
dashboard: dashboardMetadata,
getDashboard: jest.fn(),
searchDashboardGroup: jest.fn(),
...routerProps,
...propOverrides,
};
......
......@@ -11,6 +11,8 @@ import { getDashboard } from 'ducks/dashboard/reducer';
import { GetDashboardRequest } from 'ducks/dashboard/types';
import { GlobalState } from 'ducks/rootReducer';
import { logClick } from 'ducks/utilMethods';
import { UpdateSearchStateRequest } from 'ducks/search/types';
import { updateSearchState } from 'ducks/search/reducer';
import Breadcrumb from 'components/common/Breadcrumb';
import BookmarkIcon from 'components/common/Bookmark/BookmarkIcon';
......@@ -65,6 +67,7 @@ export interface DispatchFromProps {
searchIndex?: string;
source?: string;
}) => GetDashboardRequest;
searchDashboardGroup: (dashboardGroup: string) => UpdateSearchStateRequest;
}
export type DashboardPageProps = RouteComponentProps<MatchProps> &
......@@ -100,6 +103,15 @@ export class DashboardPage extends React.Component<
}
}
searchGroup = (e) => {
const { dashboard, searchDashboardGroup } = this.props;
logClick(e, {
target_type: 'dashboard_group',
label: dashboard.group_name,
});
searchDashboardGroup(dashboard.group_name);
};
mapStatusToBoolean = (status: string): boolean => {
if (status === LAST_RUN_SUCCEEDED) {
return true;
......@@ -181,15 +193,14 @@ export class DashboardPage extends React.Component<
/>
<div className="body-2">
Dashboard in&nbsp;
<a
id="dashboard-group-link"
onClick={logClick}
href={dashboard.group_url}
target="_blank"
rel="noopener noreferrer"
<button
type="button"
className="btn btn-link body-2"
data-type="dashboard-group-link"
onClick={this.searchGroup}
>
{dashboard.group_name}
</a>
</button>
</div>
</div>
{/* <div className="header-section header-links">links here</div> */}
......@@ -316,6 +327,17 @@ export class DashboardPage extends React.Component<
}
}
function searchDashboardGroup(
dashboardGroup: string
): UpdateSearchStateRequest {
return updateSearchState({
filters: {
[ResourceType.dashboard]: { group_name: dashboardGroup },
},
submitSearch: true,
});
}
export const mapStateToProps = (state: GlobalState) => {
return {
isLoading: state.dashboard.isLoading,
......@@ -325,7 +347,7 @@ export const mapStateToProps = (state: GlobalState) => {
};
export const mapDispatchToProps = (dispatch: any) => {
return bindActionCreators({ getDashboard }, dispatch);
return bindActionCreators({ getDashboard, searchDashboardGroup }, dispatch);
};
export default connect<StateFromProps, DispatchFromProps>(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment