mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-22 03:28:52 +00:00
feat(Storybook): allow opening a given page via cmdline
- syntax: `Storybook <page name>`, e.g. `Storybook CountdownPill` opens up the corresponding page from the file under `storybook/pages/CountdownPillPage.qml` - the idea: for example being able to run squish tests against Storybook (pages) - also adjusted Makefile, so that it's possible to do the same via `make`, e.g. `make run-storybook ARGS=CountdownPill`; unknown options/arguments are ignored
This commit is contained in:
parent
b04a9a4dd2
commit
9ff9c4b01a
2
Makefile
2
Makefile
@ -365,7 +365,7 @@ storybook-build: | storybook-configure
|
|||||||
|
|
||||||
run-storybook: storybook-build
|
run-storybook: storybook-build
|
||||||
echo -e "\033[92mRunning:\033[39m Storybook"
|
echo -e "\033[92mRunning:\033[39m Storybook"
|
||||||
$(STORYBOOK_BUILD_PATH)/bin/Storybook
|
$(STORYBOOK_BUILD_PATH)/bin/Storybook ${ARGS}
|
||||||
|
|
||||||
run-storybook-tests: storybook-build
|
run-storybook-tests: storybook-build
|
||||||
echo -e "\033[92mRunning:\033[39m Storybook Tests"
|
echo -e "\033[92mRunning:\033[39m Storybook Tests"
|
||||||
|
@ -41,6 +41,13 @@ int main(int argc, char *argv[])
|
|||||||
QGuiApplication::setOrganizationDomain(QStringLiteral("status.im"));
|
QGuiApplication::setOrganizationDomain(QStringLiteral("status.im"));
|
||||||
QGuiApplication::setApplicationName(QStringLiteral("Status Desktop Storybook"));
|
QGuiApplication::setApplicationName(QStringLiteral("Status Desktop Storybook"));
|
||||||
|
|
||||||
|
QCommandLineParser cmdParser;
|
||||||
|
cmdParser.addHelpOption();
|
||||||
|
cmdParser.addPositionalArgument(QStringLiteral("page"), QStringLiteral("Open the given page on startup"));
|
||||||
|
if (!cmdParser.parse(app.arguments())) {
|
||||||
|
qWarning() << "Error (ignored) while parsing cmd line arguments:" << cmdParser.errorText();
|
||||||
|
}
|
||||||
|
|
||||||
qputenv("QT_QUICK_CONTROLS_HOVER_ENABLED", QByteArrayLiteral("1"));
|
qputenv("QT_QUICK_CONTROLS_HOVER_ENABLED", QByteArrayLiteral("1"));
|
||||||
auto chromiumFlags = qgetenv("QTWEBENGINE_CHROMIUM_FLAGS");
|
auto chromiumFlags = qgetenv("QTWEBENGINE_CHROMIUM_FLAGS");
|
||||||
if(!chromiumFlags.contains("--disable-seccomp-filter-sandbox")) {
|
if(!chromiumFlags.contains("--disable-seccomp-filter-sandbox")) {
|
||||||
@ -62,8 +69,8 @@ int main(int argc, char *argv[])
|
|||||||
for (const auto& path : additionalImportPaths)
|
for (const auto& path : additionalImportPaths)
|
||||||
engine.addImportPath(path);
|
engine.addImportPath(path);
|
||||||
|
|
||||||
engine.rootContext()->setContextProperty(
|
engine.rootContext()->setContextProperty(QStringLiteral("pagesFolder"),
|
||||||
"pagesFolder", QML_IMPORT_ROOT + QStringLiteral("/pages"));
|
QML_IMPORT_ROOT + QStringLiteral("/pages"));
|
||||||
|
|
||||||
qmlRegisterType<PagesModelInitialized>("Storybook", 1, 0, "PagesModel");
|
qmlRegisterType<PagesModelInitialized>("Storybook", 1, 0, "PagesModel");
|
||||||
qmlRegisterType<SectionsDecoratorModel>("Storybook", 1, 0, "SectionsDecoratorModel");
|
qmlRegisterType<SectionsDecoratorModel>("Storybook", 1, 0, "SectionsDecoratorModel");
|
||||||
@ -117,6 +124,11 @@ int main(int argc, char *argv[])
|
|||||||
if (!obj && url == objUrl)
|
if (!obj && url == objUrl)
|
||||||
QCoreApplication::exit(-1);
|
QCoreApplication::exit(-1);
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
|
|
||||||
|
const auto args = cmdParser.positionalArguments();
|
||||||
|
if (!args.isEmpty())
|
||||||
|
engine.setInitialProperties({{QStringLiteral("currentPage"), args.constFirst()}});
|
||||||
|
|
||||||
engine.load(url);
|
engine.load(url);
|
||||||
|
|
||||||
return QGuiApplication::exec();
|
return QGuiApplication::exec();
|
||||||
|
@ -26,7 +26,12 @@ ApplicationWindow {
|
|||||||
palette.base: Theme.palette.indirectColor1
|
palette.base: Theme.palette.indirectColor1
|
||||||
font.pixelSize: 13
|
font.pixelSize: 13
|
||||||
|
|
||||||
onCurrentPageChanged: testsReRunTimer.restart()
|
onCurrentPageChanged: {
|
||||||
|
testsReRunTimer.restart()
|
||||||
|
settings.setValue("currentPage", currentPage)
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: currentPage = settings.value("currentPage")
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: d
|
id: d
|
||||||
@ -335,7 +340,6 @@ ApplicationWindow {
|
|||||||
Settings {
|
Settings {
|
||||||
id: settings
|
id: settings
|
||||||
|
|
||||||
property alias currentPage: root.currentPage
|
|
||||||
property alias loadAsynchronously: settingsLayout.loadAsynchronously
|
property alias loadAsynchronously: settingsLayout.loadAsynchronously
|
||||||
property alias runTestsAutomatically: settingsLayout.runTestsAutomatically
|
property alias runTestsAutomatically: settingsLayout.runTestsAutomatically
|
||||||
property alias darkMode: darkModeCheckBox.checked
|
property alias darkMode: darkModeCheckBox.checked
|
||||||
|
Loading…
x
Reference in New Issue
Block a user