Skip to content

Commit

Permalink
provide mock data in LogsPage.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiastz committed Dec 21, 2023
1 parent 96ca632 commit 96c29cf
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions app/packages/klogs/src/components/LogsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,21 +333,23 @@ const LogsPage: FunctionComponent<IPluginPageProps> = ({ instance }) => {
timeStart: Math.floor(Date.now() / 1000) - 900,
});

const { isError, isLoading, error, data, refetch } = useQuery<ILogsData, APIError>(
['klogs/logs', options.query, options.order, options.orderBy, options.timeStart, options.timeEnd],
() => {
const path = `/api/plugins/klogs/logs?query=${encodeURIComponent(options.query)}&order=${
options.order
}&orderBy=${encodeURIComponent(options.orderBy)}&timeStart=${options.timeStart}&timeEnd=${options.timeEnd}`;

return apiContext.client.get<ILogsData>(path, {
headers: {
'x-kobs-cluster': instance.cluster,
'x-kobs-plugin': instance.name,
},
});
},
);
const data: ILogsData = {/* TODO: provide mock data here */}

Check failure on line 336 in app/packages/klogs/src/components/LogsPage.tsx

View workflow job for this annotation

GitHub Actions / Node.js (klogs)

Replace `/*·TODO:·provide·mock·data·here·*/}` with `⏎····/*·TODO:·provide·mock·data·here·*/⏎··};`

// const { isError, isLoading, error, data, refetch } = useQuery<ILogsData, APIError>(
// ['klogs/logs', options.query, options.order, options.orderBy, options.timeStart, options.timeEnd],
// () => {
// const path = `/api/plugins/klogs/logs?query=${encodeURIComponent(options.query)}&order=${
// options.order
// }&orderBy=${encodeURIComponent(options.orderBy)}&timeStart=${options.timeStart}&timeEnd=${options.timeEnd}`;
//
// return apiContext.client.get<ILogsData>(path, {
// headers: {
// 'x-kobs-cluster': instance.cluster,
// 'x-kobs-plugin': instance.name,
// },
// });
// },
// );

/**
* selectField is used to add a field as parameter, when it isn't present and to remove a fields from as parameter,
Expand Down Expand Up @@ -416,10 +418,9 @@ const LogsPage: FunctionComponent<IPluginPageProps> = ({ instance }) => {
actions={<LogsActions instance={instance} options={options} />}
>
<UseQueryWrapper
error={error}
isError={isError}
isLoading={isLoading}
refetch={refetch}
error={null}
isError={false}
isLoading={false}
errorTitle="Failed to get logs"
isNoData={!data || !data.documents || data.documents.length === 0}
noDataTitle="No logs were found"
Expand Down

0 comments on commit 96c29cf

Please sign in to comment.