Skip to content
Snippets Groups Projects
Unverified Commit 4e4a69c3 authored by Anton Kulyk's avatar Anton Kulyk Committed by GitHub
Browse files

Show not found view when opening archived model (#28443)

* Add `isArchived` method to `Question` class

* Show nice not found view when opening archived model
parent 442ecdd3
No related branches found
No related tags found
No related merge requests found
......@@ -918,6 +918,10 @@ class QuestionInner {
return table ? table.id : null;
}
isArchived(): boolean {
return this._card && this._card.archived;
}
getUrl({
originalQuestion,
clean = true,
......
......@@ -2,9 +2,11 @@ import React, { useEffect, useCallback, useMemo, useState } from "react";
import _ from "underscore";
import { connect } from "react-redux";
import { replace } from "react-router-redux";
import { useMount } from "react-use";
import type { Location, LocationDescriptor } from "history";
import { useMount } from "react-use";
import { NotFound } from "metabase/containers/ErrorPages";
import * as Urls from "metabase/lib/urls";
import Actions from "metabase/entities/actions";
......@@ -168,6 +170,10 @@ function ModelDetailPage({
[model, onChangeCollection],
);
if (model.isArchived()) {
return <NotFound />;
}
return (
<>
<ModelDetailPageView
......
......@@ -864,5 +864,16 @@ describe("ModelDetailPage", () => {
"true",
);
});
it("shows 404 when opening an archived model", async () => {
const model = getStructuredModel({ archived: true });
const modelName = model.displayName() as string;
await setup({ model });
expect(screen.queryByText(modelName)).not.toBeInTheDocument();
expect(
screen.getByText("The page you asked for couldn't be found."),
).toBeInTheDocument();
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment