Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
15 changes: 15 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
runs-on: 'ubuntu-22.04'
timeout-minutes: 30
container: debian:trixie-slim
needs: js_tests

strategy:
fail-fast: false
Expand Down Expand Up @@ -98,7 +99,9 @@ jobs:
run: yarn cypress run --browser chromium

js_tests:
name: JS Tests
runs-on: ubuntu-22.04
needs: lint

strategy:
matrix:
Expand All @@ -114,3 +117,15 @@ jobs:
cache: 'npm'
- run: yarn
- run: yarn jest --passWithNoTests

lint:
name: Lint JS Code
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
- run: yarn
- run: yarn lint --max-warnings=0
133 changes: 45 additions & 88 deletions cypress/config.yml
Original file line number Diff line number Diff line change
@@ -1,96 +1,53 @@
# Linkspace configuration. Also see the files in the "environments"
# directory that extend this configuration.
#
# Your application's name
appname: "Linkspace"
# Webdriver integration testing configuration

# The default layout to use for your application (located in
# views/layouts/main.tt)
appname: "Linkspace Integration Tests"
layout: "main"

# when the charset is set to UTF-8 Dancer2 will handle for you
# all the magic of encoding and decoding. You should not care
# about unicode within your app when this setting is set (recommended).
charset: "UTF-8"

# template engine
# simple: default and very basic template engine
# template_toolkit: TT

template: "template_toolkit"

logger: LogReport

session: "YAML"

engines:
session:
YAML:
session_dir: "/tmp/dancer-sessions"
cookie_duration: 3600
cookie_name: linkspace.session
is_secure: 1 # Comment out or remove if using HTTP

session: "Simple"
gads:
header: "HEADER"
hostlocal: 1 # Whether to fetch files such as jquery.js locally
dateformat: "yyyy-MM-dd" # In CLDR format. Not all options available for datetime picker
email_from: '"Linkspace" <user@example.com>' # Emails are sent from this
aup: 0 # Whether to show an acceptable use policy
login_instance: 1 # The config values used for login page
default_instance: 1 # The default instance on login, if more than one
url: https://example.com/ # Used for URLs in overnight email alerts
# legacy_menu: 0
# aup_accept: I accept these terms # Use to change default accept button
message_prefix: |
This email has been generated and sent from Linkspace. Replies
will be directed to the sender of the message.
user_status: 0 # Whether to show user status on login
user_status_message: |
You must accept that you will treat this system with
respect. And be gentle please.
header: "Example Application"
hostlocal: 1
dateformat: "yyyy-MM-dd"
email_from: "Linkspace Integration Tests <nobody@example.com>"
aup: 0
login_instance: 1
default_instance: 1
url: "http://invalidhost.example.com/"
user_status: 0
uploads: "/tmp/uploads"

plugins:
LogReport:
session_messages: [ NOTICE, MISTAKE, WARNING, ERROR, FAULT, ALERT, FAILURE, PANIC ]
DBIC:
default:
dsn: dbi:Pg:database=linkspace;host=postgres # or dbi:mysql:database=dbname;mysql_enable_utf8=1;host=localhost
schema_class: GADS::Schema
user: linkspace
password: linkspace
options:
RaiseError: 1
PrintError: 1
quote_names: 1
# mysql_enable_utf8: 1
Auth::Extensible:
no_default_pages: 1
no_login_handler: 1
record_lastlogin: 1
mailer:
module: Mail::Message
options:
via: sendmail
sendmail_options:
- "-f"
- "support@example.com"
mail_from: '"Linkspace Database" <user@example.com>'
password_reset_text: GADS::reset_text
welcome_text: GADS::welcome_text
realms:
dbic:
provider: DBIC
user_as_object: 1
users_resultset: User
roles_resultset: Permission
user_roles_resultset: UserPermission
roles_role_column: name
roles_key: permission
password_expiry_days: 60
users_pwchanged_column: pwchanged
users_pwresetcode_column: resetpw
encryption_algorithm: SHA-512
user_valid_conditions:
deleted: ~
account_request: 0
LogReport:
session_messages: [ NOTICE, MISTAKE, ERROR, FAULT, ALERT, FAILURE, PANIC ]
DBIC:
default:
dsn: dbi:Pg:database=linkspace;host=postgres
schema_class: GADS::Schema
user: linkspace
password: linkspace
options:
RaiseError: 1
PrintError: 1
quote_names: 1
Auth::Extensible:
no_default_pages: 1
no_login_handler: 1
record_lastlogin: 1
realms:
dbic:
provider: DBIC
user_as_object: 1
users_resultset: User
roles_resultset: Permission
user_roles_resultset: UserPermission
roles_role_column: name
roles_key: permission
password_expiry_days: 5
users_pwchanged_column: pwchanged
users_pwresetcode_column: resetpw
encryption_algorithm: SHA-512
user_valid_conditions:
deleted: ~
account_request: 0
44 changes: 22 additions & 22 deletions cypress/e2e/functionality/02-homepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Mauris tempus, mi nec sodales semper, metus neque blandit sem, non scelerisque n
.find("a")
.eq(0)
.click();
cy.get("[aria-label='Edit Modal']").find("button.btn-cancel").click();
cy.get(".edit-widget-modal").find("button.btn-cancel").click();
cy.get(".ld-widget").should("have.length", 0);
});

Expand All @@ -80,10 +80,10 @@ Mauris tempus, mi nec sodales semper, metus neque blandit sem, non scelerisque n
.find("a")
.eq(0)
.click();
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find("input[name='title']", { timeout: 10000 })
.should("be.visible");
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find(".modal-footer__right")
.find("button.btn-primary").click();
cy.get(".ld-widget").should("have.length", 1);
Expand All @@ -92,38 +92,38 @@ Mauris tempus, mi nec sodales semper, metus neque blandit sem, non scelerisque n

it("Should edit a shared dashboard widget", () => {
cy.get(".ld-widget").find(".ld-edit-button").click();
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find("input[name='title']", { timeout: 10000 })
.should("be.visible");
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find("input[name='title']")
.type("With a new title");
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find(".modal-footer__right")
.find("button.btn-primary").click();
cy.get(".ld-widget").find("h4").contains("With a new title");
});

it("Should edit a shared dashboard widget with a lot of text", () => {
cy.get(".ld-widget").find(".ld-edit-button").click();
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find("input[name='title']", { timeout: 10000 })
.should("be.visible");
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find("div[contenteditable='true']")
.clear()
.type(bigLipsum);
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find(".modal-footer__right")
.find("button.btn-primary").click();
});

it("Should delete a shared dashboard widget", () => {
cy.get(".ld-widget").find(".ld-edit-button").click();
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find("input[name='title']", { timeout: 10000 })
.should("be.visible");
cy.get("[aria-label='Edit Modal']").find("button.btn-cancel").click();
cy.get(".edit-widget-modal").find("button.btn-cancel").click();
cy.get(".ld-widget").should("have.length", 0);
});
});
Expand All @@ -141,7 +141,7 @@ Mauris tempus, mi nec sodales semper, metus neque blandit sem, non scelerisque n
.find("a")
.eq(0)
.click();
cy.get("[aria-label='Edit Modal']").find("button.btn-cancel").click();
cy.get(".edit-widget-modal").find("button.btn-cancel").click();
cy.get(".ld-widget").should("have.length", 1);
});

Expand All @@ -157,10 +157,10 @@ Mauris tempus, mi nec sodales semper, metus neque blandit sem, non scelerisque n
.find("a")
.eq(0)
.click();
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find("input[name='title']", { timeout: 10000 })
.should("be.visible");
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find(".modal-footer__right")
.find("button.btn-primary").click();
cy.get(".ld-widget").should("have.length", 2);
Expand All @@ -170,13 +170,13 @@ Mauris tempus, mi nec sodales semper, metus neque blandit sem, non scelerisque n
it("Should edit a personal dashboard widget", () => {
cy.get("a.nav-link").eq(1).click();
cy.get(".ld-widget").eq(1).find(".ld-edit-button").click();
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find("input[name='title']", { timeout: 10000 })
.should("be.visible");
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find("input[name='title']")
.type("With a new title");
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find(".modal-footer__right")
.find("button.btn-primary").click();
cy.get(".ld-widget").eq(1).find("h4").contains("With a new title");
Expand All @@ -185,25 +185,25 @@ Mauris tempus, mi nec sodales semper, metus neque blandit sem, non scelerisque n
it("Should edit a personal dashboard widget with a lot of text", () => {
cy.get("a.nav-link").eq(1).click();
cy.get(".ld-widget").eq(1).find(".ld-edit-button").click();
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find("input[name='title']", { timeout: 10000 })
.should("be.visible");
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find("div[contenteditable='true']")
.clear()
.type(bigLipsum);
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find(".modal-footer__right")
.find("button.btn-primary").click();
});

it("Should delete a personal dashboard widget", () => {
cy.get("a.nav-link").eq(1).click();
cy.get(".ld-widget").eq(1).find(".ld-edit-button").click();
cy.get("[aria-label='Edit Modal']")
cy.get(".edit-widget-modal")
.find("input[name='title']", { timeout: 10000 })
.should("be.visible");
cy.get("[aria-label='Edit Modal']").find("button.btn-cancel").click();
cy.get(".edit-widget-modal").find("button.btn-cancel").click();
cy.get(".ld-widget").should("have.length", 1);
});
});
Expand Down
49 changes: 47 additions & 2 deletions lib/GADS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ get '/' => require_login sub {
id => $dashboard_id,
user => $user,
site => var('site'),
type => 'table'
);

my $dashboard = schema->resultset('Dashboard')->dashboard(%params)
Expand Down Expand Up @@ -1914,6 +1915,7 @@ get '/chronology/:id?' => require_login sub {
any qr{/(record|history|purge|purgehistory)/([0-9]+)} => require_login sub {

my ($action, $id) = splat;
my $view_query = query_parameters->get('view') || ''; # display as dashboard or record

my $user = logged_in_user;

Expand Down Expand Up @@ -1985,6 +1987,49 @@ any qr{/(record|history|purge|purgehistory)/([0-9]+)} => require_login sub {
return $return if $is_raw;
$return->{is_history} = $action eq 'history';
$return->{reports} = $layout->reports();

if ($layout->record_as_dashboard && $view_query ne 'full')
{
my $dashboard = schema->resultset('Dashboard')->record_dashboard(
current_id => $id,
instance_id => $layout->instance_id,
layout => $layout,
) or error __"A record overview dashboard has not been created for this table";

my $base_url = request->base;
my $tableIdentifier = $layout->identifier;

return template 'record/dashboard' => {
page => 'record/dashboard',
current_id => $id,
header_type => "table_title",
header_back_url => "${base_url}${tableIdentifier}/data",
layout_obj => $layout,
# Remove default excess padding top and left
content_block_main_custom_classes => "pt-0",
content_block_custom_classes => "ps-0",
breadcrumbs => [
Crumb($base_url."table/", "Tables"),
Crumb("$base_url" . $layout->identifier . '/data', "Table: " . $layout->name),
Crumb("", $id ? ucfirst($layout->record_name)." ID: " . $id : "New ".$layout->record_name)
],
readonly => !$layout->user_can('layout'),
dashboards_json => encode_json ([
+{
id => 1,
url => $record->url_dashboard,
name => 'Overview',
},
+{
id => 2,
url => $record->url_full,
name => 'Full record',
}
]),
dashboard => $dashboard,
};
}

template 'edit' => $return, $options;
};

Expand Down Expand Up @@ -3528,8 +3573,8 @@ prefix '/:layout_name' => sub {
my $params = params;
my $columns = ref param('column') ? param('column') : [ param('column') // () ]; # Ensure array
$view->columns($columns);
$view->global(param('viewType') eq 'global' ? 1 : 0);
$view->is_admin(param('viewType') eq 'admin' ? 1 : 0);
$view->global(param('view_type') eq 'global' ? 1 : 0);
$view->is_admin(param('view_type') eq 'admin' ? 1 : 0);
$view->group_id(param 'group_id');
$view->name (param 'name');
$view->filter->as_json(param 'filter');
Expand Down
Loading
Loading