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

Save draft #1340

Merged
merged 59 commits into from
Feb 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
d974f43
fix: Add optional access to navigator.vendor deprecated property
ptbrowne Feb 12, 2024
0294863
docs: Add table of contents
ptbrowne Feb 12, 2024
af8a102
refactor: Extract keys early
ptbrowne Feb 13, 2024
56929a9
refactor: Use query cache & invalidation to facilitate mutation
ptbrowne Feb 13, 2024
aea33b7
feat: Add useMutate helper
ptbrowne Feb 13, 2024
38dbb98
refactor: Remove config through useMutate
ptbrowne Feb 13, 2024
42d977a
feat: Add draft published state
ptbrowne Feb 13, 2024
f81c149
feat: Ability to turn config into draft/publish it from chart list
ptbrowne Feb 13, 2024
c995497
refactor: Extract saveState from component
ptbrowne Feb 13, 2024
3844279
fix: Config for existing chart is correctly fetched
ptbrowne Feb 13, 2024
23dae00
refactor: Rename for clarity
ptbrowne Feb 13, 2024
1d5792c
feat: Use menu instead of tooltip
ptbrowne Feb 13, 2024
64b6359
fix fetch data
ptbrowne Feb 15, 2024
9663353
refactor: Rename method
ptbrowne Feb 15, 2024
4303529
refactor: Decompose effect in both parts
ptbrowne Feb 15, 2024
9d77f58
feat: Show warning if viewing chart still in draft
ptbrowne Feb 15, 2024
ba80167
feat: Add save draft button
ptbrowne Feb 15, 2024
867311c
fix: Add required chartId prop
ptbrowne Feb 15, 2024
af92a08
feat: Add translations for chart features
ptbrowne Feb 15, 2024
22ad15a
refactor: Add docs and explicit the version
ptbrowne Feb 15, 2024
e6f5479
fix: Inverted message
ptbrowne Feb 15, 2024
98d73f7
feat: Add published state as non optional
ptbrowne Feb 15, 2024
dded7a7
fix: button in button
ptbrowne Feb 16, 2024
79786d3
feat: Make create and update config simpler, they take a config and w…
ptbrowne Feb 16, 2024
f32fb11
Show SaveAsDraft button inside layout options
ptbrowne Feb 16, 2024
e51afff
feat: Hide save as draft button if not logged in
ptbrowne Feb 16, 2024
5134a9c
refactor: Rename SaveDraft button
ptbrowne Feb 16, 2024
5000dde
feat: Ability to dismiss snack
ptbrowne Feb 16, 2024
fd452c9
fix: Can save in draft a new chart
ptbrowne Feb 16, 2024
ec1baed
refactor: Reduce case
ptbrowne Feb 16, 2024
a9c297c
refactor: Remove unnnecessary type
ptbrowne Feb 16, 2024
1aa90d2
fix: Remove target blank
ptbrowne Feb 16, 2024
fc0d75b
feat: Show arrow for menu
ptbrowne Feb 16, 2024
6c2842e
fix: Remove config call does not check incoming data from userId, che…
ptbrowne Feb 16, 2024
424bbf2
fix: Gap
ptbrowne Feb 16, 2024
431703f
feat: Show edit button on chart page if it's a draft
ptbrowne Feb 16, 2024
07aded3
refactor: Extract Confirmation Dialog from actions
ptbrowne Feb 16, 2024
ac7621a
feat: Refactor actions to be able to show the primary one as button
ptbrowne Feb 16, 2024
31897ca
fix: Typo
ptbrowne Feb 16, 2024
2097c22
refactor: Split component and make title of visualisation table dynamic
ptbrowne Feb 16, 2024
a0fd5e0
feat: Show drafts and published configs separately
ptbrowne Feb 16, 2024
394ea79
feat: Show actions differently for drafts & published
ptbrowne Feb 16, 2024
2981ece
feat: Show only small check, less things to translate
ptbrowne Feb 16, 2024
8dfdbf2
feat: Make button a bit more lively
ptbrowne Feb 16, 2024
b54f3fd
feat: Add translations
ptbrowne Feb 16, 2024
18a823f
fix: Menu item takes the whole width
ptbrowne Feb 16, 2024
8f5e588
fix: Correct import
ptbrowne Feb 16, 2024
e11e4b9
fix: Missing published state
ptbrowne Feb 16, 2024
d1ebad4
fix: Unused
ptbrowne Feb 16, 2024
6b5846c
refactor: Extract row actions and confirmation dialog from profile-ta…
ptbrowne Feb 19, 2024
e9710a7
feat: Add xsmall variant to button sizes
ptbrowne Feb 19, 2024
4b541df
feat: Show delete in red
ptbrowne Feb 19, 2024
822381f
fix: Make all tables look the same
ptbrowne Feb 19, 2024
dd8bca6
refactor: Extract rename dialog
ptbrowne Feb 20, 2024
ce7c21b
feat: Wrap th cells into table row and extract styling to table
ptbrowne Feb 20, 2024
47a83d6
fix: Delete should correctly work
ptbrowne Feb 20, 2024
75ad1c9
fix: Correctly call confirmation if required
ptbrowne Feb 20, 2024
76b02cf
fix: Typo
ptbrowne Feb 20, 2024
076b30b
fix: Width exceeded 100%
ptbrowne Feb 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions app/pages/v/[chartId].tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { Trans } from "@lingui/macro";
import { Box, Button, Stack, Theme, Typography } from "@mui/material";
import { Alert, Box, Button, Stack, Theme, Typography } from "@mui/material";
import { makeStyles } from "@mui/styles";
import { Config, PUBLISHED_STATE } from "@prisma/client";
import { GetServerSideProps } from "next";
import ErrorPage from "next/error";
import Head from "next/head";
import NextLink from "next/link";
import { useRouter } from "next/router";
import React, { useState } from "react";
import React, { useEffect, useState } from "react";

import { ChartPublished } from "@/components/chart-published";
import { PublishSuccess } from "@/components/hint";
import { ContentLayout } from "@/components/layout";
import { PublishActions } from "@/components/publish-actions";
import {
Config,
Config as ChartConfig,
ConfiguratorStateProvider,
ConfiguratorStatePublished,
getChartConfig,
Expand All @@ -30,9 +31,8 @@ type PageProps =
}
| {
status: "found";
config: {
key: string;
data: Config;
config: Omit<Config, "data"> & {
data: ChartConfig;
};
};

Expand Down Expand Up @@ -74,7 +74,7 @@ const VisualizationPage = (props: Serialized<PageProps>) => {

// Keep initial value of publishSuccess
const [publishSuccess] = useState(() => !!query.publishSuccess);
const { status } = deserializeProps(props);
const { status, config } = deserializeProps(props);

const { key, state } = React.useMemo(() => {
if (props.status === "found") {
Expand Down Expand Up @@ -166,6 +166,16 @@ const VisualizationPage = (props: Serialized<PageProps>) => {
</Box>
)}

{config.published_state === PUBLISHED_STATE.DRAFT && (
<Box mt={2} mb={5}>
<Alert severity="warning">
<Trans id="hint.publication.draft">
This chart is still in draft.
</Trans>
ptbrowne marked this conversation as resolved.
Show resolved Hide resolved
</Alert>
</Box>
)}

<ConfiguratorStateProvider chartId="published" initialState={state}>
<ChartPublished configKey={key} />
</ConfiguratorStateProvider>
Expand Down