Skip to content

Commit

Permalink
Rename isPublic to isPublicView for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanfranklin committed Nov 12, 2024
1 parent 05f631c commit 8364d17
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 42 deletions.
2 changes: 1 addition & 1 deletion react/src/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function AppRouter() {
</ProtectedRoute>
}
/>
<Route path={ROUTES.PUBLIC_PROJECT} element={<MapProject isPublic />} />
<Route path={ROUTES.PUBLIC_PROJECT} element={<MapProject isPublicView />} />
<Route path={ROUTES.CALLBACK} element={<Callback />} />
<Route
path={ROUTES.STREETVIEW_CALLBACK}
Expand Down
10 changes: 5 additions & 5 deletions react/src/components/AssetsPanel/AssetsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ interface Props {
featureCollection: FeatureCollection;

/**
* Whether or not the map project is public.
* Whether or not the map project is a public view.
*/
isPublic: boolean;
isPublicView: boolean;

/**
* active project id
Expand All @@ -70,7 +70,7 @@ interface Props {
* A panel component that displays info on feature assets
*/
const AssetsPanel: React.FC<Props> = ({
isPublic,
isPublicView,
featureCollection,
projectId,
}) => {
Expand All @@ -81,8 +81,8 @@ const AssetsPanel: React.FC<Props> = ({
</div>
<div className={styles.middleSection}>
<FeatureFileTree
projectId={projectId}
isPublic={isPublic}
projectId={project.id}
isPublicView={isPublicView}
featureCollection={featureCollection}
/>
</div>
Expand Down
6 changes: 3 additions & 3 deletions react/src/components/FeatureFileTree/FeatureFileTree.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const renderWithRouter = (ui: React.ReactElement, { route = '/' } = {}) => {
describe('FeatureFileTree', () => {
const defaultProps = {
featureCollection: featureCollection,
isPublic: false,
isPublicView: false,
projectId: 1,
};

Expand Down Expand Up @@ -73,7 +73,7 @@ describe('FeatureFileTree', () => {

it('does not show delete button for public projects', () => {
const { queryByTestId } = renderWithRouter(
<FeatureFileTree {...defaultProps} isPublic={true} />,
<FeatureFileTree {...defaultProps} isPublicView={true} />,
{ route: '/?selectedFeature=1' }
);

Expand All @@ -84,7 +84,7 @@ describe('FeatureFileTree', () => {

it('does not show delete button when no feature is selected', () => {
const { queryByTestId } = renderWithRouter(
<FeatureFileTree {...defaultProps} isPublic={true} />
<FeatureFileTree {...defaultProps} isPublicView={false} />
);

// Verify delete button is not present
Expand Down
6 changes: 3 additions & 3 deletions react/src/components/FeatureFileTree/FeatureFileTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface FeatureFileTreeProps {
/**
* Whether or not the map project is public.
*/
isPublic: boolean;
isPublicView: boolean;

/**
* active project id
Expand All @@ -44,7 +44,7 @@ interface FeatureFileTreeProps {
*/
const FeatureFileTree: React.FC<FeatureFileTreeProps> = ({
featureCollection,
isPublic,
isPublicView,
projectId,
}) => {
const { mutate: deleteFeature, isLoading } = useDeleteFeature();
Expand Down Expand Up @@ -169,7 +169,7 @@ const FeatureFileTree: React.FC<FeatureFileTreeProps> = ({
<FeatureIcon featureType={featureNode.featureType} />
)}
<span className={styles.fileName}>{featureNode.name}</span>
{!isPublic && isSelected && (
{!isPublicView && isSelected && (
<Button
size="small"
type="primary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import styles from './ManageMapProjectModal.module.css';
import { Modal, ModalHeader, ModalBody } from 'reactstrap';

interface ManageMapProjectModalProps {
isPublic: boolean;
isPublicView: boolean;
}

const ManageMapProjectModal: React.FC<ManageMapProjectModalProps> = ({
isPublic,
isPublicView,
}) => {
const navigate = useNavigate();
const location = useLocation();
Expand All @@ -24,7 +24,7 @@ const ManageMapProjectModal: React.FC<ManageMapProjectModalProps> = ({
<ModalHeader toggle={closeModal}>TODO</ModalHeader>
<ModalBody>
<div className={styles.root}>
Manage Map Project TODO, isPublic: {isPublic}
Manage Map Project TODO, isPublicView: {isPublicView}
</div>
</ModalBody>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('MapProjectNavBar', () => {
it('renders the public nav items for public maps', () => {
const { getByText, queryByText } = render(
<BrowserRouter>
<MapProjectNavBar isPublic={true} />
<MapProjectNavBar isPublicView={true} />
</BrowserRouter>
);
expect(getByText('Assets')).toBeDefined();
Expand All @@ -22,7 +22,7 @@ describe('MapProjectNavBar', () => {
it('renders all nav items for non-public maps', () => {
const { getByText } = render(
<BrowserRouter>
<MapProjectNavBar isPublic={false} />
<MapProjectNavBar isPublicView={false} />
</BrowserRouter>
);

Expand Down
6 changes: 3 additions & 3 deletions react/src/components/MapProjectNavBar/MapProjectNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ const navItems: NavItem[] = [
];

interface NavBarPanelProps {
isPublic?: boolean;
isPublicView?: boolean;
}

const MapProjectNavBar: React.FC<NavBarPanelProps> = ({ isPublic = false }) => {
const MapProjectNavBar: React.FC<NavBarPanelProps> = ({ isPublicView = false }) => {
const location = useLocation();
const queryParams = new URLSearchParams(location.search);
const activePanel = queryParams.get(queryPanelKey);

return (
<div className={styles.root}>
{navItems
.filter((item) => (isPublic ? item.showWhenPublic : true))
.filter((item) => (isPublicView ? item.showWhenPublic : true))
.map((item) => {
const updatedQueryParams = new URLSearchParams(location.search);

Expand Down
9 changes: 5 additions & 4 deletions react/src/hooks/features/useFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ import { useGet } from '@hazmapper/requests';

interface UseFeaturesParams {
projectId: number;
isPublic: boolean;
isPublicView: boolean;
assetTypes: string[];
options?: object;
}

export const useFeatures = ({
projectId,
isPublic,
isPublicView,
assetTypes,
options = {},
}: UseFeaturesParams): UseQueryResult<FeatureCollection> => {
const featuresRoute = isPublic ? 'public-projects' : 'projects';
// TODO can be reworked as /projects can be used and /public-projects can be removed since we are no longer a WSO2 API
const featuresRoute = isPublicView ? 'public-projects' : 'projects';
let endpoint = `/${featuresRoute}/${projectId}/features/`;
if (assetTypes?.length) {
endpoint += `?assetType=${assetTypes.join(',')}`;
Expand All @@ -32,7 +33,7 @@ export const useFeatures = ({

const query = useGet<FeatureCollection>({
endpoint,
key: ['activeProjectFeatures', { projectId, isPublic, assetTypes }],
key: ['activeProjectFeatures', { projectId, isPublicView, assetTypes }],
options: { ...defaultQueryOptions, ...options },
});
return query;
Expand Down
6 changes: 3 additions & 3 deletions react/src/hooks/projects/useProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ export const useProjects = (): UseQueryResult<Project[]> => {

interface UseProjectParams {
projectUUID?: string;
isPublic: boolean;
isPublicView: boolean;
options: object;
}

export const useProject = ({
projectUUID,
isPublic,
isPublicView,
options,
}: UseProjectParams): UseQueryResult<Project> => {
const projectRoute = isPublic ? 'public-projects' : 'projects';
const projectRoute = isPublicView ? 'public-projects' : 'projects';
const endpoint = `/${projectRoute}/?uuid=${projectUUID}`;
const query = useGet<Project>({
endpoint,
Expand Down
8 changes: 4 additions & 4 deletions react/src/hooks/tileServers/useTileServers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import { TileServerLayer } from '@hazmapper/types';

interface UseTileServerParams {
projectId?: number;
isPublic: boolean;
isPublicView: boolean;
options?: object;
}

export const useTileServers = ({
projectId,
isPublic,
isPublicView,
options = {},
}: UseTileServerParams): UseQueryResult<TileServerLayer[]> => {
const tileServersRoute = isPublic ? 'public-projects' : 'projects';
const tileServersRoute = isPublicView ? 'public-projects' : 'projects';
const endpoint = `/${tileServersRoute}/${projectId}/tile-servers/`;

const query = useGet<TileServerLayer[]>({
endpoint,
key: ['tile-servers', { projectId, isPublic }],
key: ['tile-servers', { projectId, isPublicView }],
options,
});

Expand Down
22 changes: 11 additions & 11 deletions react/src/pages/MapProject/MapProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ interface MapProjectProps {
* Whether or not the map project is public.
* @default false
*/
isPublic?: boolean;
isPublicView?: boolean;
}

/**
* A component that displays a map project including initial loading/error components
*/
const MapProject: React.FC<MapProjectProps> = ({ isPublic = false }) => {
const MapProject: React.FC<MapProjectProps> = ({ isPublicView = false }) => {
const { projectUUID } = useParams();

const {
Expand All @@ -34,7 +34,7 @@ const MapProject: React.FC<MapProjectProps> = ({ isPublic = false }) => {
error,
} = useProject({
projectUUID,
isPublic,
isPublicView,
options: { enabled: !!projectUUID },
});

Expand All @@ -61,7 +61,7 @@ const MapProject: React.FC<MapProjectProps> = ({ isPublic = false }) => {
);
}

return <LoadedMapProject isPublic={isPublic} activeProject={activeProject} />;
return <LoadedMapProject isPublicView={isPublicView} activeProject={activeProject} />;
};

interface LoadedMapProject {
Expand All @@ -73,15 +73,15 @@ interface LoadedMapProject {
/**
* Whether or not the map project is public.
*/
isPublic;
isPublicView;
}

/**
* A component that displays a map project (a map and related data)
*/
const LoadedMapProject: React.FC<LoadedMapProject> = ({
activeProject,
isPublic,
isPublicView,
}) => {
const [selectedAssetTypes, setSelectedAssetTypes] = useState<string[]>(
Object.keys(assetTypeOptions)
Expand Down Expand Up @@ -112,7 +112,7 @@ const LoadedMapProject: React.FC<LoadedMapProject> = ({
error: featuresError,
} = useFeatures({
projectId: activeProject.id,
isPublic,
isPublicView,
assetTypes: formattedAssetTypes,
});

Expand All @@ -122,7 +122,7 @@ const LoadedMapProject: React.FC<LoadedMapProject> = ({
error: tileServerLayersError,
} = useTileServers({
projectId: activeProject.id,
isPublic,
isPublicView,
});

const location = useLocation();
Expand Down Expand Up @@ -157,8 +157,8 @@ const LoadedMapProject: React.FC<LoadedMapProject> = ({
<div className={styles.panelContainer}>
{activePanel === Panel.Assets && (
<AssetsPanel
projectId={activeProject.id}
isPublic={isPublic}
project={activeProject}
isPublicView={isPublicView}
featureCollection={featureCollection}
/>
)}
Expand All @@ -175,7 +175,7 @@ const LoadedMapProject: React.FC<LoadedMapProject> = ({
</div>
)}
{activePanel === Panel.Manage && (
<ManageMapProjectModal isPublic={isPublic} />
<ManageMapProjectModal isPublicView={isPublicView} />
)}
<div className={styles.map}>
<Map
Expand Down

0 comments on commit 8364d17

Please sign in to comment.