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

Disable Lift export when Frontier is empty #3440

Merged
merged 9 commits into from
Nov 18, 2024
Merged

Disable Lift export when Frontier is empty #3440

merged 9 commits into from
Nov 18, 2024

Conversation

andracc
Copy link
Collaborator

@andracc andracc commented Nov 11, 2024

Resolves #3441

This change is Reviewable

Copy link

codecov bot commented Nov 11, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.69%. Comparing base (9238e55) to head (ec4ca0c).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/components/ProjectExport/ExportButton.tsx 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3440      +/-   ##
==========================================
+ Coverage   74.64%   74.69%   +0.05%     
==========================================
  Files         285      285              
  Lines       10999    10999              
  Branches     1339     1338       -1     
==========================================
+ Hits         8210     8216       +6     
+ Misses       2406     2400       -6     
  Partials      383      383              
Flag Coverage Δ
backend 83.71% <ø> (+0.05%) ⬆️
frontend 66.67% <75.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link
Collaborator

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r2, all commit messages.
Reviewable status: 1 of 2 files reviewed, 3 unresolved discussions (waiting on @andracc)


src/components/ProjectExport/ExportButton.tsx line 16 at r2 (raw file):

  projectId: string;
  buttonProps?: ButtonProps & { "data-testid"?: string };
  disabled?: boolean;

It looks like this new optional prop isn't been used.


src/components/ProjectExport/ExportButton.tsx line 22 at r2 (raw file):

export default function ExportButton(props: ExportButtonProps): ReactElement {
  const dispatch = useAppDispatch();
  const [exports, setExports] = useState<boolean>(false);

The <boolean> can be dropped, since the type is implied from the default value.


src/components/ProjectExport/ExportButton.tsx line 43 at r2 (raw file):

          setExports(true);
        }
      });

Because setExports is a function that takes a boolean, you should be able to condense this to

await isFrontierNonempty(props.propjectId).then(setExports);

(There's no performance concern for updating a state to what it already is, because rerenders are only triggered when states and props change.)


src/components/ProjectExport/ExportButton.tsx line 53 at r2 (raw file):

        <LoadingButton
          loading={loading}
          disabled={loading}

Since the LoadingButton has a disabled prop, probably better to update that with loading || !exports than to conflict with it via the buttonProps.

Copy link
Collaborator

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on @andracc)


src/components/ProjectExport/ExportButton.tsx line 43 at r2 (raw file):

Previously, imnasnainaec (D. Ror.) wrote…

Because setExports is a function that takes a boolean, you should be able to condense this to

await isFrontierNonempty(props.propjectId).then(setExports);

(There's no performance concern for updating a state to what it already is, because rerenders are only triggered when states and props change.)

One more possible simplification---since we're not doing any special error handling in this situation, the whole useEffect can be:

  useEffect(() => {
    isFrontierNonempty(props.projectId).then(setExports);
  }, [props.projectId]);

Also, we want the second argument: [props.projectId]. That dependency array makes the useEffect only re-run when the projectId changes (e.g., when the user switches projects from within the project settings).

Copy link
Collaborator

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @andracc)

@andracc andracc marked this pull request as ready for review November 18, 2024 19:17
@andracc andracc merged commit cb9dcd1 into master Nov 18, 2024
18 checks passed
@andracc andracc deleted the empty-frontier branch November 18, 2024 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable export button when frontier is empty
2 participants