Skip to content

Commit

Permalink
fix(edge/stack): edge stack env table pagination and action [EE-6836] (
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarzhou-portainer committed May 20, 2024
1 parent 014a590 commit 659abe5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export function EnvironmentActions({ environment }: Props) {
} = useCurrentStateAndParams();

return (
<div className="space-x-2">
{environment.Snapshots.length > 0 && (
<div>
{environment.Snapshots.length > 0 && environment.Edge.AsyncMode && (
<Link
to="edge.browse.containers"
params={{ environmentId: environment.Id, edgeStackId }}
className="!text-inherit hover:!no-underline"
className="hover:!no-underline"
data-cy="browse-snapshot-link"
>
<Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ import { EnvironmentId } from '@/react/portainer/environments/types';
import { isBE } from '@/react/portainer/feature-flags/feature-flags.service';

import { Datatable } from '@@/datatables';
import { useTableStateWithoutStorage } from '@@/datatables/useTableState';
import { PortainerSelect } from '@@/form-components/PortainerSelect';
import { createPersistedStore } from '@@/datatables/types';
import { useTableState } from '@@/datatables/useTableState';

import { useEdgeStack } from '../../queries/useEdgeStack';

import { EdgeStackEnvironment } from './types';
import { columns } from './columns';

const tableKey = 'edge-stacks-environment';

const settingsStore = createPersistedStore(tableKey);

export function EnvironmentsDatatable() {
const {
params: { stackId },
Expand All @@ -40,7 +45,7 @@ export function EnvironmentsDatatable() {
'status',
(value) => (value ? parseInt(value, 10) : undefined)
);
const tableState = useTableStateWithoutStorage('name');
const tableState = useTableState(settingsStore, tableKey);
const environmentsQuery = useEnvironmentList({
pageLimit: tableState.pageSize,
page: page + 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export function LogsActions({ environmentId, edgeStackId }: Props) {
return (
<>
<Button
color="none"
className="p-0"
color="link"
title="Retrieve logs"
onClick={handleCollectLogs}
data-cy="edge-stack-logs-collect-button"
Expand All @@ -48,11 +49,12 @@ export function LogsActions({ environmentId, edgeStackId }: Props) {
/>
</Button>
<Button
color="none"
data-cy="edge-stack-logs-download-button"
className="p-0"
color="link"
title="Download logs"
disabled={status !== 'collected'}
onClick={handleDownloadLogs}
data-cy="edge-stack-logs-download-button"
>
<Icon
icon={clsx({
Expand All @@ -62,7 +64,8 @@ export function LogsActions({ environmentId, edgeStackId }: Props) {
/>
</Button>
<Button
color="none"
className="p-0"
color="link"
title="Delete logs"
disabled={status !== 'collected'}
onClick={handleDeleteLogs}
Expand Down

0 comments on commit 659abe5

Please sign in to comment.