(core) updates from grist-core

This commit is contained in:
Paul Fitzpatrick
2023-08-21 09:15:53 -04:00
19 changed files with 221 additions and 55 deletions

View File

@@ -355,7 +355,7 @@ export class GristDoc extends DisposableWithEvents {
this.autoDispose(subscribe(urlState().state, async (_use, state) => {
// Only start a tour or tutorial when the full interface is showing, i.e. not when in
// embedded mode.
if (state.params?.style === 'light') {
if (state.params?.style === 'singlePage') {
return;
}

View File

@@ -19,7 +19,7 @@ import {LocalPlugin} from 'app/common/plugin';
import {DismissedPopup, DismissedReminder, UserPrefs} from 'app/common/Prefs';
import {isOwner, isOwnerOrEditor} from 'app/common/roles';
import {getTagManagerScript} from 'app/common/tagManager';
import {getDefaultThemePrefs, Theme, ThemeAppearance, ThemeColors, ThemePrefs,
import {getDefaultThemePrefs, Theme, ThemeColors, ThemePrefs,
ThemePrefsChecker} from 'app/common/ThemePrefs';
import {getThemeColors} from 'app/common/Themes';
import {getGristConfig} from 'app/common/urlUtils';
@@ -450,14 +450,26 @@ export class AppModelImpl extends Disposable implements AppModel {
private _getCurrentThemeObs() {
return Computed.create(this, this.themePrefs, prefersDarkModeObs(),
(_use, themePrefs, prefersDarkMode) => {
let appearance: ThemeAppearance;
if (!themePrefs.syncWithOS) {
appearance = themePrefs.appearance;
} else {
let {appearance, syncWithOS} = themePrefs;
const urlParams = urlState().state.get().params;
if (urlParams?.themeAppearance) {
appearance = urlParams?.themeAppearance;
}
if (urlParams?.themeSyncWithOs !== undefined) {
syncWithOS = urlParams?.themeSyncWithOs;
}
if (syncWithOS) {
appearance = prefersDarkMode ? 'dark' : 'light';
}
const nameOrColors = themePrefs.colors[appearance];
let nameOrColors = themePrefs.colors[appearance];
if (urlParams?.themeName) {
nameOrColors = urlParams?.themeName;
}
let colors: ThemeColors;
if (typeof nameOrColors === 'string') {
colors = getThemeColors(nameOrColors);

View File

@@ -20,3 +20,7 @@ export function COMMENTS(): Observable<boolean> {
export function HAS_FORMULA_ASSISTANT() {
return Boolean(getGristConfig().featureFormulaAssistant);
}
export function WHICH_FORMULA_ASSISTANT() {
return getGristConfig().assistantService;
}

View File

@@ -392,7 +392,7 @@ const cssPageContainer = styled(cssVBox, `
padding-bottom: ${bottomFooterHeightPx}px;
min-width: 240px;
}
.interface-light & {
.interface-singlePage & {
padding-bottom: 0;
}
}
@@ -434,7 +434,7 @@ export const cssLeftPane = styled(cssVBox, `
display: none;
}
}
.interface-light & {
.interface-singlePage & {
display: none;
}
&-overlap {
@@ -501,7 +501,7 @@ const cssRightPane = styled(cssVBox, `
display: none;
}
}
.interface-light & {
.interface-singlePage & {
display: none;
}
`);
@@ -519,7 +519,7 @@ const cssHeader = styled('div', `
}
}
.interface-light & {
.interface-singlePage & {
display: none;
}
`);
@@ -556,7 +556,7 @@ const cssBottomFooter = styled ('div', `
display: none;
}
}
.interface-light & {
.interface-singlePage & {
display: none;
}
`);

View File

@@ -36,7 +36,7 @@ export function makeViewLayoutMenu(viewSection: ViewSectionRec, isReadonly: bool
];
const viewRec = viewSection.view();
const isLight = urlState().state.get().params?.style === 'light';
const isSinglePage = urlState().state.get().params?.style === 'singlePage';
const sectionId = viewSection.table.peek().rawViewSectionRef.peek();
const anchorUrlState = viewInstance.getAnchorLinkForSection(sectionId);
@@ -57,7 +57,7 @@ export function makeViewLayoutMenu(viewSection: ViewSectionRec, isReadonly: bool
const showRawData = (use: UseCB) => {
return !use(viewSection.isRaw)// Don't show raw data if we're already in raw data.
&& !isLight // Don't show raw data in light mode.
&& !isSinglePage // Don't show raw data in single page mode.
;
};
@@ -84,7 +84,7 @@ export function makeViewLayoutMenu(viewSection: ViewSectionRec, isReadonly: bool
menuItemCmd(allCommands.editLayout, t("Edit Card Layout"),
dom.cls('disabled', isReadonly))),
dom.maybe(!isLight, () => [
dom.maybe(!isSinglePage, () => [
menuDivider(),
menuItemCmd(allCommands.viewTabOpen, t("Widget options"), testId('widget-options')),
menuItemCmd(allCommands.sortFilterTabOpen, t("Advanced Sort & Filter")),
@@ -111,12 +111,12 @@ export function makeViewLayoutMenu(viewSection: ViewSectionRec, isReadonly: bool
*/
export function makeCollapsedLayoutMenu(viewSection: ViewSectionRec, gristDoc: GristDoc) {
const isReadonly = gristDoc.isReadonly.get();
const isLight = urlState().state.get().params?.style === 'light';
const isSinglePage = urlState().state.get().params?.style === 'singlePage';
const sectionId = viewSection.table.peek().rawViewSectionRef.peek();
const anchorUrlState = { hash: { sectionId, popup: true } };
const rawUrl = urlState().makeUrl(anchorUrlState);
return [
dom.maybe((use) => !use(viewSection.isRaw) && !isLight && !use(gristDoc.maximizedSectionId),
dom.maybe((use) => !use(viewSection.isRaw) && !isSinglePage && !use(gristDoc.maximizedSectionId),
() => menuItemLink(
{ href: rawUrl}, t("Show raw data"), testId('show-raw-data'),
dom.on('click', (ev) => {

View File

@@ -6,7 +6,7 @@ import {movable} from 'app/client/lib/popupUtils';
import {logTelemetryEvent} from 'app/client/lib/telemetry';
import {ColumnRec, ViewFieldRec} from 'app/client/models/DocModel';
import {ChatMessage} from 'app/client/models/entities/ColumnRec';
import {HAS_FORMULA_ASSISTANT} from 'app/client/models/features';
import {HAS_FORMULA_ASSISTANT, WHICH_FORMULA_ASSISTANT} from 'app/client/models/features';
import {getLoginOrSignupUrl, urlState} from 'app/client/models/gristUrlState';
import {buildHighlightedCode} from 'app/client/ui/CodeHighlight';
import {autoGrow} from 'app/client/ui/forms';
@@ -879,7 +879,7 @@ class ChatHistory extends Disposable {
'"Please calculate the total invoice amount."'
),
),
cssAiMessageBullet(
(WHICH_FORMULA_ASSISTANT() === 'OpenAI') ? cssAiMessageBullet(
cssTickIcon('Tick'),
dom('div',
t(
@@ -891,7 +891,7 @@ class ChatHistory extends Disposable {
}
),
),
),
) : null,
),
cssAiMessageParagraph(
t(